Stem Plot
- class MatPlus.StemPlot.StemPlot(x, y, lowerlimx=None, lowerlimy=None, upperlimx=None, upperlimy=None, linefmt='-', markerfmt='o', basefmt=' ', label=None, orientation='vertical')[source]
A class for creating Stem plots with customizable properties. The StemPlot class provides a simplified interface for creating stem plots with customizable axis limits and line properties such as line format, marker format, and base format.
Parameters:
- xarray-like
The x-values of the stem plot.
- yarray-like
The y-values of the stem plot.
- lowerlimxfloat, optional
The lower limit of the x-axis. Default is 90% of the minimum x-value.
- lowerlimyfloat, optional
The lower limit of the y-axis. Default is 90% of the minimum y-value.
- upperlimxfloat, optional
The upper limit of the x-axis. Default is 110% of the maximum x-value.
- upperlimyfloat, optional
The upper limit of the y-axis. Default is 110% of the maximum y-value.
- linefmtstr, optional
Format string for the vertical lines in the stem plot. Default is ‘-‘.
- markerfmtstr, optional
Format string for the markers at the stem heads. Default is ‘o’.
- basefmtstr, optional
Format string for the baseline. Default is ‘ ‘ (invisible).
- labelstr, optional
Label for the stem plot. Default is None.
- orientationstr, optional
Orientation of the stem plot, either ‘vertical’ or ‘horizontal’. Default is ‘vertical’.
Examples
>>> # Basic stem plot >>> x = [1, 2, 3, 4, 5] >>> y = [1, 4, 9, 16, 25] >>> stem = StemPlot(x, y) >>> stem.plot()
>>> # Stem plot with custom line and marker formats >>> stem = StemPlot(x, y, linefmt='--r', markerfmt='^g') >>> stem.plot()
>>> # Stem plot with a visible baseline >>> stem = StemPlot(x, y, basefmt='-', label="Quadratic Data") >>> stem.plot()
>>> # Horizontal stem plot >>> stem = StemPlot(x, y, orientation="horizontal") >>> stem.plot()