flâneur — a map of the web's best reading

Plots with different scales — Matplotlib 3.5.3 documentation

matplotlib.org · 334 words · saved by 1 readers

The trick is to use two different axes that share the same x axis. You can use separate matplotlib.ticker formatters and locators as desired since the two axes are independent. Such axes are generated by calling the Axes.twinx method. Likewise, Axes.twiny is available to generate axes that share a y axis but have different top and bottom scales. References The use of the following functions, methods, classes and modules is shown in this example: matplotlib.axes.Axes.twinx / matplotlib.pyplot.twinx matplotlib.axes.Axes.twiny / matplotlib.pyplot.twiny matplotlib.axes.Axes.tick_params / matplotlib.pyplot.tick_params Download Python source code: two_scales.py Download Jupyter notebook: two_scales.ipynb Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery © Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2022 The Matplotlib development team. Created using Sphinx 4.5.0.

Explore this link on the map →

saved by