ltl::Gnuplot Class Reference
[Gnuplot interface]

Inherits fdostream.

List of all members.

Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

Gnuplot interface for MArrays and FVectors

Simple interface to call gnuplot and send MArray and FVector objects. An instance of a Gnuplot class encapsulates a pipe into gnuplot's stdin. It exports a stream interface to the user, so that any gnuplot command can be sent via operator<<. For convenience, functions handling the loops over elements and the necessary formatting to plot elements of 1-D MArray against index number, two 1-D MArray against each other, 2-D MArray surfaces, and elements of any stl-iterator compatible container are provided.

The follwing example code should be self-explanatory:

    MArray<float,1> A;

    Gnuplot gp;  // start a gnuplot session and open pipe
    Gnuplot gp ("gnuplot-cmd"); // alternative command string

    // plot elements of A against index number:
    gp << "plot '-' with lines\n";
    gp.send (A);

    MArray<float,1> X, Y;
    // add a plot of Y vs. X to previous plot
    gp << "replot '-' with points\n";
    gp.send (X,Y);

    MArray<float,2> S;
    // a surface plot of 2-D MArray S
    gp << "splot '-' with lines\n";
    gp.send (S);

    std::vector<float> v;
    float *f;
    // plot an iterator range
    gp << "plot '-' with points\n";
    gp.send_iter (v.begin(), v.end());
    gp << "replot '-' with points\n";
    gp.send_iter (f, f+10);

    double mx, my;
    int mb;
    gp.getMouse(mx, my, mb);

Gnuplot::send() works with MArrays up to dimension 2, FVectors. For stdlib containers use send with any valid iterator range, i.e. send(v.begin(),v.end())

Gnuplot inherits from std::ostream, so any gnuplot commands and data can be sent to Gnuplot via standard streamio operations, operator<<, setprecision(), etc.


Constructor & Destructor Documentation

ltl::Gnuplot::Gnuplot ( const std::string  cmd = ""  ) 

Construct with command to launch gnuplot. This will call gnuplot and open a pipe.

ltl::Gnuplot::~Gnuplot (  ) 

Member Function Documentation

void ltl::Gnuplot::getMouse ( double mx,
double my,
int mb 
)

Wait for mouse event in gnuplot window and return corrdinates and button

template<class T >
Gnuplot & ltl::Gnuplot::send_iter ( p,
const T &  last 
) [inline]

Any iterator range

References send().

template<class T >
Gnuplot & ltl::Gnuplot::send ( const ltl::MArray< T, 1 > &  A  )  [inline]

1-Dimensional MArray

1-Dimensional MArray Will be plotted against index number.

References ltl::indexPosInt(), and ltl::MArray< T, N >::shape().

Referenced by send(), and send_iter().

template<class T1 , class T2 >
Gnuplot & ltl::Gnuplot::send ( const ltl::MArray< T1, 1 > &  X,
const ltl::MArray< T2, 1 > &  Y 
) [inline]

Plot 2 MArrays against each other

References ltl::MArray< T, N >::maxIndex(), ltl::MArray< T, N >::minIndex(), and send().

template<class T >
Gnuplot & ltl::Gnuplot::send ( const ltl::MArray< T, 2 > &  A  )  [inline]
template<class T >
Gnuplot & ltl::Gnuplot::sendAsImage ( const ltl::MArray< T, 2 > &  A  )  [inline]

2-Dimensional MArray to be used with "plot '-' matrix with image" Note: T could be either a scalar or a blitz::TinyVector.

References ltl::MArray< T, N >::maxIndex(), and ltl::MArray< T, N >::minIndex().

void ltl::Gnuplot::interactive ( const string &  pname  ) 
template<class T >
Gnuplot& ltl::Gnuplot::send ( const T &  x  )  [inline, protected]

Handles container elements

References sendEntry().

template<class T , int N>
void ltl::Gnuplot::sendEntry ( const ltl::FVector< T, N > &  v  )  [inline, protected]

Referenced by send(), and sendEntry().

template<class T , int N>
void ltl::Gnuplot::sendEntry ( const ltl::FixedVector< T, N > &  v  )  [inline, protected]

References sendEntry().

template<class T >
void ltl::Gnuplot::sendEntry ( const T  v  )  [inline, protected]
template<class T , class U >
void ltl::Gnuplot::sendEntry ( const std::pair< T, U > &  v  )  [inline, protected]

References sendEntry().

void ltl::Gnuplot::allocReader (  )  [protected]

Member Data Documentation

FILE* ltl::Gnuplot::pout [protected]
std::string ltl::Gnuplot::pty_fn [protected]
FILE* ltl::Gnuplot::pty_fh [protected]
bool ltl::Gnuplot::debug_messages [protected]

Generated on 19 Feb 2015 for LTL by  doxygen 1.6.1