TBTK
|
Need a break? Support the development by playing Polarity Puzzles |
See more details about the Plotter in the API
If Python, Matplotlib, and NumPy is installed, TBTK allows for data to be plotted immediately from C++. The Plotter exists in the namespace TBTK::Visualization::MatPlotLib and below we assume that the following lines have been added at the top of the code.
We begin by listing some of the most common commands needed for setting up and configuring the Plotter.
Create a Plotter
Note: All Plotter objects use the same matplotlib instance as backend and can therefore interfere with each other when used simultaneously.
Setting the canvas size
Clear the canvas
Save the canvas to file
Set axis bounds
By default, the axes automatically scale to contain the data. It is possible to fix the axis bounds with the following calls.
These calls can also be combined into a single call.
We here provide a few examples of how the Plotter can be used. For more examples, including how to plot Properties, see the API.
1D data
If data is an std::vector<double> or a one-dimensional Array, it can be plotted using
By default, the x-axis will run from 0 to the number of data points minus one. If domain has the same type and size as data and contains custom values for the x-axis, we can also use
2D data
If data is an std::vector<std::vector<double>> or a two-dimensional Array, it can be plotted using