Note

Go to the endto download the full example code.

Stem plot#

stem plots vertical lines from a baseline to the y-coordinate andplaces a marker at the tip.

importmatplotlib.pyplotaspltimportnumpyasnpx=np.linspace(0.1,2*np.pi,41)y=np.exp(np.sin(x))plt.stem(x,y)plt.show()
stem plot

The position of the baseline can be adapted usingbottom.The parameterslinefmt,markerfmt, andbasefmt control basic formatproperties of the plot. However, in contrast toplot not allproperties are configurable via keyword arguments. For more advancedcontrol adapt the line objects returned bypyplot.

markerline,stemlines,baseline=plt.stem(x,y,linefmt='grey',markerfmt='D',bottom=1.1)markerline.set_markerfacecolor('none')plt.show()
stem plot

References

The use of the following functions, methods, classes and modules is shownin this example:

Tags:plot-type: stemlevel: beginner

Gallery generated by Sphinx-Gallery