plot#

Hist1d.plot(ax=None, fname=None, xlabel='__auto__', ylabel='__auto__', title='__auto__', logscale=False, xlim=None, ylim=None, plot_fmt=None, savefig_kwargs={}, use_fixed_layout=None, fixed_layout_kwargs=None, make_me_nice=None, make_me_nice_kwargs=None, **plot_kwargs)[source]#

Plot the 1D histogram using matplotlib.pyplot.plot.

Parameters:
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 Hist1d.xlabel.

ylabelstr, default “__auto__”

Label for the y-axis.

If “__auto__”, use Hist1d.ylabel.

titlestr, default “__auto__”

Title of the plot.

If “__auto__”, use Hist1d.title.

logscalebool, optional

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 matplotlib.pyplot.plot.

savefig_kwargsdict, optional

Additional 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 passed to matplotlib.pyplot.plot.

use_fixed_layout

Deprecated since version 5.5.0: Does nothing.

fixed_layout_kwargs

Deprecated since version 5.5.0: Does nothing.

make_me_nice

Deprecated since version 5.5.0: Does nothing.

make_me_nice_kwargs

Deprecated since version 5.5.0: Does nothing.

Examples

import matplotlib.pyplot as plt

import atompy as ap

plt.style.use("atom")

hist = ap.Hist1d((1, 2, 3, 4), (0, 1, 2, 3, 4))
hist.plot(drawstyle="steps-mid")

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

../../../_images/plot1.png
import matplotlib.pyplot as plt

import atompy as ap

plt.style.use("atom")

hist = ap.Hist1d((1, 2, 3, 4), (0, 1, 2, 3, 4))

_, axs = plt.subplots(1, 2, layout="compressed")

hist.plot(axs[0], plot_fmt="o")
hist.pad_with(0).plot(axs[1], drawstyle="steps-mid")
plt.show()

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

../../../_images/plot_in_axes.png