plot#

DataXY.plot(ax=None, fname=None, xlabel='__auto__', ylabel='__auto__', title='__auto__', logscale_x=False, logscale_y=False, xlim=None, ylim=None, plot_fmt=None, savefig_kwargs={}, **plot_kwargs)[source]#

Plot the data using matplotlib.axes.Axes.plot().

Note

DataXY.plot_kwargs will also be passed to plot().

Parameters:
axmatplotlib.axes.Axes, optional

If a matplotilb axes is passed, plot data into it, else create a new axes.

fnamestr, optional

If provided, the plot will be saved to this file using matplotlib.figure.Figure.savefig().

xlabelstr, default “__auto__”

Label for the x-axis.

If “__auto__”, use DataXY.xlabel.

ylabelstr, default “__auto__”

Label for the y-axis.

If “__auto__”, use DataXY.ylabel.

titlestr, default “__auto__”

Title of the plot.

If “__auto__”, use DataXY.title.

logscale_xbool, default False

If True, use a logarithmic x scale.

logscale_ybool, default False

If True, use a logarithmic y scale.

xlimtuple[float | None, float | None], optional

Limits for the x-axis.

ylimtuple[float | None, float | None], optional

Limits for the y-axis.

plot_fmtstr, optional

format string for plot().

savefig_kwargsdict, optional

Dictionary of keyword arguments passed to savefig().

Returns:
tuple of matplotlib.figure.Figure, matplotlib.axes.Axes

A tuple containing the matplotlib Figure and Axes.

Other Parameters:
plot_kwargsdict, optional

Additional keyword arguments are merged with DataXY.plot_kwargs and passed to matplotlib.pyplot.plot.

Examples

import matplotlib.pyplot as plt
import numpy as np

import atompy as ap

plt.style.use("atom")

data = ap.DataXY.from_function(
    ap.gauss, np.linspace(-5, 5, 100), title="Normal distribution", xlabel="x"
)

data.plot()

(Source code, png, hires.png, pdf)

../../../_images/plot.png