Skip to content

plasma_plots.tikz_backend

LaTeX versions of the plots, as TikZ/pgfplots code: backend="tikz".

Every accessor plot that draws with Matplotlib (array.plasma.plot.*, dataset.plasma.plot.*, out.plot.*) takes backend="tikz". The plot is drawn with Matplotlib as usual, off screen, and the drawn figure is converted by maxplotlib <https://github.com/max-models/maxplotlib>_ ([maxplotlib.backends.tikzfigure.figure_to_tikz()][maxplotlib.backends.tikzfigure.figure_to_tikz]) into a tikzfigure <https://github.com/max-models/tikzfigure>_ figure of pgfplots axes: every panel at the place and size it has in the Matplotlib figure, with its limits, log scales, labels and title typeset by LaTeX, its ticks, legend and colorbar. Lines, markers, fits, reference lines, bars, spans, contour lines and text are pgfplots code; meshes (also on mapped grids), images and the color strips of colorbars are images that Matplotlib renders, placed with \addplot graphics.

result = energy.plasma.plot.timeseries(fit=(0.0, 5.0), backend=“tikz”)

a standalone LaTeX document; also .tikz, .pdf, .png

result.save(“energy.tex”) result.fig # a tikzfigure.TikzFigure print(result.fig.generate_tikz()) # the tikzpicture, to paste into a paper plasma_plots.set_backend(“tikz”) # the default for every plot from now on

Saving as .tikz writes the tikzpicture (for \input into a document that loads pgfplots), .tex a standalone document; both write the images the figure refers to next to the file. .pdf and .png compile the figure with pdflatex. Text is converted from Matplotlib’s: mathtext ($\omega/\omega_{ci}$) is LaTeX math, and plain text is escaped.

Animations and interactive viewers have no TikZ version. maxplotlib is optional: pip install "plasma-plots[tikz]".

Attributes

NameDescription
OPTIONSNo description.

Functions

NameDescription
to_tikzConvert a drawn Matplotlib figure into a TikZ/pgfplots figure.

OPTIONSattributemodule attribute#

OPTIONS = {'raster_dpi': 300, 'max_markers': 2000, 'max_items': 500, 'max_points': 20000}

to_tikzfunction#

def to_tikz(figure, **options)

Convert a drawn Matplotlib figure into a TikZ/pgfplots figure.

Parameters

NameTypeDefaultDescription
figurematplotlib.figure.FigurerequiredThe figure, e.g. result.fig of a plotting function.
**options{}Passed to [maxplotlib.backends.tikzfigure.figure_to_tikz()][maxplotlib.backends.tikzfigure.figure_to_tikz], over OPTIONS: raster_dpi, max_markers, max_items, max_points, precision.

Returns

tikzfigure.TikzFigure
The figure: generate_tikz() for the tikzpicture, savefig to write .tikz, .tex, .pdf or .png.

Examples

>>> figure = to_tikz(plot_lineout(phi.isel(t=-1, eta2=0, eta3=0)).fig)
>>> figure.savefig("phi.tex")