lucid  0.0.1
Lifting-based Uncertain Control Invariant Dynamics
Loading...
Searching...
No Matches
lucid::plt Namespace Reference

Lucid's matplotlib wrapper. More...

Classes

struct  FillBetweenKwargs
 Keyword arguments for fill_between. More...
 
struct  PlotKwargs
 Keyword arguments for the plot function. More...
 
struct  PlotSurfaceKwargs
 Keyword arguments for plot_surface. More...
 
struct  PlotWireframeKwargs
 Keyword arguments for plot_wireframe. More...
 
struct  SaveKwargs
 Keyword arguments for savefig. More...
 
struct  ScatterKwargs
 Keyword arguments for scatter. More...
 

Functions

bool xlim (double left, double right)
 Set the x-axis view limits.
 
bool ylim (double bottom, double top)
 Set the y-axis view limits.
 
std::array< double, 2 > xlim ()
 Get the x-axis view limits.
 
std::array< double, 2 > ylim ()
 Get the y-axis view limits.
 
void backend (const std::string &name)
 Set the backend used by matplotlib.
 
bool annotate (const std::string &text, const double x, const double y)
 Annotate the point xy with text.
 
int figure (const int fig_number=-1)
 Create a new figure or select an existing figure.
 
template<class ContainerX, class ContainerY>
bool plot (const ContainerX &x, const ContainerY &y, const PlotKwargs &kwargs={})
 Plot y versus x as lines and/or markers.
 
template<class ContainerX, class ContainerY, class ContainerZ>
bool plot_surface (const ContainerX &x, const ContainerY &y, const ContainerZ &z, const PlotSurfaceKwargs &kwargs={})
 Create a surface plot.
 
template<class ContainerX, class ContainerY, class ContainerZ>
bool plot_wireframe (const ContainerX &x, const ContainerY &y, const ContainerZ &z, const PlotWireframeKwargs &kwargs={})
 
template<class ContainerX, class ContainerY1, class ContainerY2>
bool fill_between (const ContainerX &x, const ContainerY1 &y1, const ContainerY2 &y2, const FillBetweenKwargs &kwargs={})
 Fill the area between two horizontal curves.
 
bool savefig (const std::string &filename, const SaveKwargs &kwargs={})
 Save the current figure as an image or vector graphic to a file.
 
void show (const bool block=true)
 Show the current figure.
 
template<class ContainerX, class ContainerY>
bool scatter (const ContainerX &x, const ContainerY &y, const ScatterKwargs &kwargs={})
 A scatter plot of y vs x with varying marker size and/or color.
 
template<class ContainerX, class ContainerY, class ContainerZ>
bool scatter (const ContainerX &x, const ContainerY &y, const ContainerZ &z, const ScatterKwargs &kwargs={})
 A scatter plot of y vs x vs z with varying marker size and/or color.
 

Detailed Description

Lucid's matplotlib wrapper.

Inspired by Benno Evers' matplotlib-cpp.

Function Documentation

◆ annotate()

bool lucid::plt::annotate ( const std::string & text,
const double x,
const double y )
inline

Annotate the point xy with text.

In the simplest form, the text is placed at (x, y).

Parameters
textannotation text
xx coordinate
yy coordinate
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.annotate.html

◆ backend()

void lucid::plt::backend ( const std::string & name)
inline

Set the backend used by matplotlib.

Use 'AGG', 'PDF', 'PS', 'SVG', 'Cairo' in non-interactive mode (i.e. you won't be able to run show()). Use 'WebAgg', 'QtAgg', 'GTK3Agg', 'GTK3Cairo', 'wxAgg', 'TkAgg' for interactive mode. The interactive backend will only work if the required python packages are installed (e.g., tornado for 'WebAgg').

Note
This must be called before the first plot command to have any effect.
Parameters
nameThe name of the backend to use.
See also
https://matplotlib.org/stable/users/explain/figure/backends.html

◆ figure()

int lucid::plt::figure ( const int fig_number = -1)
inline

Create a new figure or select an existing figure.

Parameters
fig_numbernumber of the figure to select. If negative, a new figure is created.
Returns
the figure number

◆ fill_between()

template<class ContainerX, class ContainerY1, class ContainerY2>
bool lucid::plt::fill_between ( const ContainerX & x,
const ContainerY1 & y1,
const ContainerY2 & y2,
const FillBetweenKwargs & kwargs = {} )

Fill the area between two horizontal curves.

The curves are defined by the points (x, y1) and (x, y2). This creates one or multiple polygons describing the filled area. You may exclude some horizontal sections from filling using where. By default, the edges connect the given points directly. Use step if the filling should be a step function, i.e. constant in between x.

Template Parameters
ContainerXcontainer type for x
ContainerY1container type for y1
ContainerY2container type for y2
Parameters
xx coordinates of the nodes defining the curves.
y1y coordinates of the nodes defining the first curve. If it contains a single value, it is replicated for every element of x
y2y coordinates of the nodes defining the second curve. If it contains a single value, it is replicated for every element of x
kwargsadditional keywords arguments
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.fill_between.html

◆ plot()

template<class ContainerX, class ContainerY>
bool lucid::plt::plot ( const ContainerX & x,
const ContainerY & y,
const PlotKwargs & kwargs = {} )

Plot y versus x as lines and/or markers.

The coordinates of the points or line nodes are given by x, y. The optional parameter fmt is a convenient way for defining basic formatting like color, marker and linestyle.

Template Parameters
ContainerXcontainer type for x data
ContainerYcontainer type for y data
Parameters
xx data
yy data
kwargsadditional keywords
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html

◆ plot_surface()

template<class ContainerX, class ContainerY, class ContainerZ>
bool lucid::plt::plot_surface ( const ContainerX & x,
const ContainerY & y,
const ContainerZ & z,
const PlotSurfaceKwargs & kwargs = {} )

Create a surface plot.

By default, it will be colored in shades of a solid color, but it also supports colormapping by supplying the cmap argument.

Template Parameters
ContainerXcontainer type for x
ContainerYcontainer type for y
ContainerZcontainer type for z
Parameters
xdata value
ydata value
zdata value
kwargsadditional keywords arguments
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.plot_surface.html

◆ plot_wireframe()

template<class ContainerX, class ContainerY, class ContainerZ>
bool lucid::plt::plot_wireframe ( const ContainerX & x,
const ContainerY & y,
const ContainerZ & z,
const PlotWireframeKwargs & kwargs = {} )
Template Parameters
ContainerXcontainer type for x
ContainerYcontainer type for y
ContainerZcontainer type for z
Parameters
xdata value
ydata value
zdata value
kwargsadditional keywords arguments
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.plot_wireframe.html

◆ savefig()

bool lucid::plt::savefig ( const std::string & filename,
const SaveKwargs & kwargs = {} )
inline

Save the current figure as an image or vector graphic to a file.

Parameters
filenamethe path of the file to save the figure to
kwargsadditional keywords arguments
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html

◆ scatter() [1/2]

template<class ContainerX, class ContainerY, class ContainerZ>
bool lucid::plt::scatter ( const ContainerX & x,
const ContainerY & y,
const ContainerZ & z,
const ScatterKwargs & kwargs = {} )

A scatter plot of y vs x vs z with varying marker size and/or color.

Template Parameters
ContainerXx container type
ContainerYy container type
ContainerZy container type
Parameters
xdata points for the horizontal axis
ydata points for the vertical axis
zdata points for the depth axis
kwargsadditional keywords arguments
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html

◆ scatter() [2/2]

template<class ContainerX, class ContainerY>
bool lucid::plt::scatter ( const ContainerX & x,
const ContainerY & y,
const ScatterKwargs & kwargs = {} )

A scatter plot of y vs x with varying marker size and/or color.

Template Parameters
ContainerXx container type
ContainerYy container type
Parameters
xdata points for the horizontal axis
ydata points for the vertical axis
kwargsadditional keywords arguments
Returns
true if the function was successful
false if an error occurred
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html

◆ show()

void lucid::plt::show ( const bool block = true)
inline

Show the current figure.

Parameters
blockif true, the function will block until the figure is closed. If false, it will return immediately and the figure will be shown in a separate window.
See also
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.show.html

◆ xlim() [1/2]

std::array< double, 2 > lucid::plt::xlim ( )

Get the x-axis view limits.

Returns
array of two doubles: {left limit, right limit}

◆ xlim() [2/2]

bool lucid::plt::xlim ( double left,
double right )

Set the x-axis view limits.

Parameters
leftleft limit
rightright limit
Returns
true if the function was successful
false if an error occurred

◆ ylim() [1/2]

std::array< double, 2 > lucid::plt::ylim ( )

Get the y-axis view limits.

Returns
array of two doubles: {bottom limit, top limit}

◆ ylim() [2/2]

bool lucid::plt::ylim ( double bottom,
double top )

Set the y-axis view limits.

Parameters
bottombottom limit
toptop limit
Returns
true if the function was successful
false if an error occurred