sciplot  0.3.1
A modern C++ plotting library powered by gnuplot

The class used to create a plot containing graphical elements. More...

#include <Plot.hpp>

Inheritance diagram for Plot:
[legend]
Collaboration diagram for Plot:
[legend]

Public Member Functions

 Plot ()
 Construct a default Plot object.
 
virtual ~Plot ()=default
 Virtual destructor to avoid memory leaks.
 
auto palette (const std::string &name) -> Plot &
 Set the palette of colors for the plot. More...
 
auto size (std::size_t width, std::size_t height) -> Plot &
 Set the size of the plot (in unit of points, with 1 inch = 72 points).
 
auto fontName (const std::string &name) -> Plot &
 Set the font name for the plot (e.g., Helvetica, Georgia, Times).
 
auto fontSize (std::size_t size) -> Plot &
 Set the font size for the plot (e.g., 10, 12, 16).
 
auto border () -> BorderSpecs &
 Set the border of the plot and return a reference to the corresponding specs object.
 
auto grid () -> GridSpecs &
 Set the grid of the plot and return a reference to the corresponding specs object.
 
auto xlabel (const std::string &label) -> AxisLabelSpecs &
 Set the label of the x-axis and return a reference to the corresponding specs object.
 
auto ylabel (const std::string &label) -> AxisLabelSpecs &
 Set the label of the y-axis and return a reference to the corresponding specs object.
 
auto xrange (const StringOrDouble &min, const StringOrDouble &max) -> Plot &
 Set the x-range of the plot (also possible with empty values or autoscale options (e.g. "", "*")).
 
auto yrange (const StringOrDouble &min, const StringOrDouble &max) -> Plot &
 Set the y-range of the plot (also possible with empty values or autoscale options (e.g. "", "*")).
 
auto boxWidthAbsolute (double val) -> Plot &
 Set the default width of boxes in plots containing boxes (in absolute mode). More...
 
auto boxWidthRelative (double val) -> Plot &
 Set the default width of boxes in plots containing boxes (in relative mode). More...
 
auto tics () -> TicsSpecs &
 Set the tics of the plot and return a reference to the corresponding specs object.
 
auto xtics () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major xtics on the bottom axis.
 
auto ytics () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major ytics on the left axis.
 
auto ztics () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major ztics.
 
auto rtics () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major rtics.
 
auto xticsMajorBottom () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major xtics on the bottom axis.
 
auto xticsMajorTop () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major xtics on the top axis.
 
auto xticsMinorBottom () -> TicsSpecsMinor &
 Return the specifications of the grid lines along minor xtics on the bottom axis.
 
auto xticsMinorTop () -> TicsSpecsMinor &
 Return the specifications of the grid lines along minor xtics on the top axis.
 
auto yticsMajorLeft () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major ytics on the left axis.
 
auto yticsMajorRight () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major ytics on the right axis.
 
auto yticsMinorLeft () -> TicsSpecsMinor &
 Return the specifications of the grid lines along minor ytics on the left axis.
 
auto yticsMinorRight () -> TicsSpecsMinor &
 Return the specifications of the grid lines along minor ytics on the right axis.
 
auto zticsMajor () -> TicsSpecsMajor &
 Return the specifications of the grid lines along major ztics.
 
auto zticsMinor () -> TicsSpecsMinor &
 Return the specifications of the grid lines along minor ztics.
 
auto rticsMajor () -> TicsSpecsMajor &
 Return the specifications of the grid lines along minor rtics.
 
auto rticsMinor () -> TicsSpecsMinor &
 Return the specifications of the grid lines along minor rtics.
 
auto styleFill () -> FillStyleSpecs &
 Return an object that permits fill style to be customized.
 
auto styleHistogram () -> HistogramStyleSpecs &
 Return an object that permits histogram style to be customized.
 
auto draw (const std::string &what, const std::string &use, const std::string &with) -> DrawSpecs &
 Draw plot object with given what, using and with expressions (e.g., plot.draw("sin(x)*cos(x)", "", "linespoints"), (e.g., plot.draw("file.dat", "1:2", "points"))).
 
auto legend () -> LegendSpecs &
 Set the legend of the plot and return a reference to the corresponding specs object.
 
auto samples (std::size_t value) -> void
 Set the number of sample points for analytical plots.
 
auto gnuplot (const std::string &command) -> void
 Use this method to provide gnuplot commands to be executed before the plotting calls.
 
auto savePlotData () const -> void
 Write the current plot data to the data file.
 
auto autoclean (bool enable=true) -> void
 Toggle automatic cleaning of temporary files (enabled by default). More...
 
auto cleanup () const -> void
 Delete all files used to store plot data or scripts.
 
auto clear () -> void
 Clear all draw and gnuplot commands. More...
 
virtual auto repr () const -> std::string=0
 Convert this plot object into a gnuplot formatted string.
 

Protected Attributes

std::size_t m_id = 0
 The Plot id derived from m_counter upon construction (must be the first member due to constructor initialization order!)
 
bool m_autoclean = true
 Toggle automatic cleaning of temporary files (enabled by default)
 
std::string m_palette
 The name of the gnuplot palette to be used.
 
std::size_t m_width = 0
 The size of the plot in x.
 
std::size_t m_height = 0
 The size of the plot in y.
 
std::string m_datafilename
 The multi data set file where data given to plot (e.g., vectors) are saved.
 
std::string m_data
 The current plot data as a string.
 
std::size_t m_numdatasets = 0
 The current number of data sets in the data file.
 
FontSpecs m_font
 The font name and size in the plot.
 
BorderSpecs m_border
 The border style of the plot.
 
GridSpecs m_grid
 The vector of grid specs for the major and minor grid lines in the plot (for xtics, ytics, mxtics, etc.).
 
std::string m_xrange
 The x-range of the plot as a gnuplot formatted string (e.g., "set xrange [0:1]")
 
std::string m_yrange
 The y-range of the plot as a gnuplot formatted string (e.g., "set yrange [0:1]")
 
HistogramStyleSpecs m_style_histogram
 The specs for the histogram style of the plot.
 
TicsSpecs m_tics
 The specs of the tics of the plot.
 
TicsSpecsMajor m_xtics_major_bottom
 The specs for the major xtics at the bottom.
 
TicsSpecsMajor m_xtics_major_top
 The specs for the major xtics at the top.
 
TicsSpecsMinor m_xtics_minor_bottom
 The specs for the minor xtics at the bottom.
 
TicsSpecsMinor m_xtics_minor_top
 The specs for the minor xtics at the top.
 
TicsSpecsMajor m_ytics_major_left
 The specs for the major ytics at the left.
 
TicsSpecsMajor m_ytics_major_right
 The specs for the major ytics at the right.
 
TicsSpecsMinor m_ytics_minor_left
 The specs for the minor ytics at the left.
 
TicsSpecsMinor m_ytics_minor_right
 The specs for the minor ytics at the right.
 
TicsSpecsMajor m_ztics_major
 The specs for the major ztics.
 
TicsSpecsMinor m_ztics_minor
 The specs for the minor ztics.
 
TicsSpecsMajor m_rtics_major
 The specs for the major rtics.
 
TicsSpecsMinor m_rtics_minor
 The specs for the minor rtics.
 
AxisLabelSpecs m_xlabel
 The label of the x-axis.
 
AxisLabelSpecs m_ylabel
 The label of the y-axis.
 
AxisLabelSpecs m_rlabel
 The label of the r-axis.
 
std::string m_boxwidth
 The default width of boxes in plots containing boxes without given widths.
 
FillStyleSpecs m_style_fill
 The specs for the fill style of the plot elements in the plot that can be painted.
 
std::string m_samples
 The number of sample points for functions.
 
LegendSpecs m_legend
 The legend specs of the plot.
 
std::vector< DrawSpecsm_drawspecs
 The plot specs for each call to gnuplot plot function.
 
std::vector< std::string > m_customcmds
 The strings containing gnuplot custom commands.
 

Static Protected Attributes

static std::size_t m_counter = 0
 Counter of how many plot / singleplot objects have been instanciated in the application.
 

Detailed Description

The class used to create a plot containing graphical elements.

Member Function Documentation

◆ palette()

auto palette ( const std::string &  name) -> Plot&
inline

Set the palette of colors for the plot.

Parameters
nameAny palette name displayed in https://github.com/Gnuplotting/gnuplot-palettes, such as "viridis", "parula", "jet".

◆ boxWidthAbsolute()

auto boxWidthAbsolute ( double  val) -> Plot&
inline

Set the default width of boxes in plots containing boxes (in absolute mode).

In absolute mode, a unit width is equivalent to one unit of length along the x axis.

◆ boxWidthRelative()

auto boxWidthRelative ( double  val) -> Plot&
inline

Set the default width of boxes in plots containing boxes (in relative mode).

In relative mode, a unit width is equivalent to setting the boxes side by side.

◆ autoclean()

auto autoclean ( bool  enable = true) -> void
inline

Toggle automatic cleaning of temporary files (enabled by default).

Pass false if you want to keep your script / data files. Call cleanup() to remove those files manually.

◆ clear()

auto clear ( ) -> void
inline

Clear all draw and gnuplot commands.

Note
This method leaves all other plot properties untouched.

The documentation for this class was generated from the following file: