pyphysim.extra package

Submodules

pyphysim.extra.pgfplotshelper module

This module contains useful functions to create pgfplots code (latex code using the pgfplots package) from python data.

One example of tex code for a plot using pgfplots is show below

\begin{tikzpicture}
  \begin{axis}[axis options]
    \addplot [plot options]
    plot [options]
    coordinates {
      (0, 0)
      (1, 1)
      (2, 4)
      (3, 9)};
    \addlegendentry{Legend of the last line};
  \end{axis}
\end{tikzpicture}
pyphysim.extra.pgfplotshelper.generate_pgfplots_plotline(x, y, errors=None, options=None, legend=None)[source]

This function generates the code corresponding to the “addplot” command in a pgfplots plot for the coordinates given in x and y.

If the parameter errors is also provided then error bars will be added in the y direction, while options to the addplot command can be passed as a string in the options argument.

Parameters
  • x (np.ndarray | list[float] | list[int]) – The data for the ‘x’ axis in the plot.

  • y (np.ndarray | list[float] | list[int]) – The data for the ‘x’ axis in the plot

  • errors (np.ndarray | list[float] | list[int], optional) – The error for plotting the errorbars.

  • options (str) – pgfplot options for the plot line. Ex: “color=red, solid, mark=square, mark options={solid}”

  • legend (str) – The legend for the plot line.

Module contents

Package containing extra functionality.