Plot Data

A Plot Data is generated each time a new plotting function (either Plot or Scatter) is called. The relevant data is written to file, and the filelocation, along with the specifications for how the data should be displayed, are saved in the PlotData object.

JS::PlotData objects can be modified in two ways – pre-facto and post-facto. Pre-facto specification relies on passing relevant line properties to the Plot or Scatter command which generated it. Alteratively, these same commands return references to the geneated JSL::PlotData object, which can then be modified via the member functions.

class JSL::PlotData

A holder class for the datalocation, and line specification for each plot added to an axis.

Public Functions

template<typename ...Ts>
inline PlotData(std::string data, int idx, PlotType t, NameValuePair<Ts>... args)

Constructor.

Parameters:
  • data – The relative filepath to the location where the associated data is stored.

  • idx – The id of the data (and the index of this object within the Axis::Data vector).

  • args – A variadic list of JSL::NameValuePair objects used for pre-facto changes to the line style

template<typename T>
inline void SetColour(T v)

Default template function - used to throw error messages if innapropriate colour specifications used. Note the spelling of colour!!

inline void SetColour(std::string c)

Sets the colour value of the line to the given string. No checks are made that this string corresponds to a valid gnuplot colour.**Note the spelling of colour!!**.

inline void SetColour(const char *c)

SetColour override for c-style string - simple converts to std::string then calls SetColour(std::string c) Note the spelling of colour!!

inline void SetColour(unsigned int r, unsigned int g, unsigned int b)

Sets the colour to that specified by the RGB value, converting it into a gnuplot-readable format Note the spelling of colour!!

Parameters:
  • r – The red value (between 0 and 255)

  • g – The green value (between 0 and 255)

  • b – The blue value (between 0 and 255)

inline void SetColour(std::vector<unsigned int> cs)

Sets the colour to that specified by the RGB value Note the spelling of colour!!

Parameters:

cs – A length-three vector corresponding to RGB values

template<typename T>
inline void SetPenSize(T v)

Default template function - used to throw error messages if innapropriate pensize specifications used.

inline void SetPenSize(int l)

Sets the width of the pen used to draw lines (and also the thickness of scatter-points)

template<typename T>
inline void SetPenType(T v)

Default template function - used to throw error messages if innapropriate pen type specification used.

inline void SetPenType(JSL::LineType t)

Sets the LineType (dashed, solid, etc) for the object.

Parameters:

t – The JSL::LineType specifier

template<typename T>
inline void SetScatterType(T t)

Default template function - used to throw error messages if innapropriate scatter type specification used.

inline void SetScatterType(ScatterType t)

Sets the LineType (circle, dot, square) for the object.

Parameters:

t – The JSL::ScatterType specifier

template<typename T>
inline void SetLegend(T t)

Default template function - used to throw error messages if innapropriate specification used.

inline void SetLegend(std::string s)

Sets the name for this plot on the legend.

inline std::string Write()

Formats the internal data and writes it to a string for use in a gnuplot script.

Returns:

A string containing the necessary data to plot the internal data

Private Functions

inline void DefaultInit()

Sets the default values of the members.

template<typename T, typename ...Ts>
inline void ParseLoop(NameValuePair<T> n1, NameValuePair<Ts>... ns)

Variadic function which parses the JSL::NameValuePairs provided to the function for pre-facto modification.

template<typename T>
inline void ParseNVPair(NameValuePair<T> nv)

Given a JSL::NameValuePair object, attempt to interpret it, given the Name value, passing the Value portion to the relevant templated function outlined above.

Private Members

std::string DataLocation

The file location for the x/y data used in this plot.

int Idx

The ID of this plot, pretty much only used to generate a default legend (i.e. Plot 1)

std::string dashType

The dashType specifier (either for linestyle - dash/solid, or scatterstyle - circle/dot/square etc.)

PlotType type

Denotes either Line plots or scatter plots etc.

std::string legend

The name associated with this data on the legend.

std::string colour

The colour used to plot the data - if not specified, uses the default gnuplot colour roster.

int penSize

The thickness of the pen used to write the data.