Plots with different scales — Matplotlib 3.5.3 documentation
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.
Note Go to the end to download the full example code. Two plots on the same Axes with different left and right scales. 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. See also Secondary Axis for the case where the two scales are not independent, but related (e.g., the same quantity in two…
saved by
related reading
- plotting - Two ListLinePlots together with two vertical axes - Mathematica Stack Exchangemathematica.stackexchange.com
- Create 2D bar graphs in different planes — Matplotlib 3.11.2 documentationmatplotlib.org
- Inset locator demo — Matplotlib 3.11.0 documentationmatplotlib.org
- Writing mathematical expressions — Matplotlib 3.11.2 documentationmatplotlib.org
- Pyplot tutorial — Matplotlib 3.11.0 documentationmatplotlib.org
- bspline - B-spline interpolation with Python - Stack Overflowstackoverflow.com
- Data vis do’s & don’ts | Datawrapper Blogdatawrapper.de
- The Architecture of Open Source Applications (Volume 2)matplotlibaosabook.org
- 7 Steps to Help You Make Your Matplotlib Bar Charts Beautiful | Towards Data Sciencetowardsdatascience.com
- From data to Viz | Find the graphic you needdata-to-viz.com
- Electric motor scaling laws and inertia in robot actuators | Robot Daycarerobot-daycare.com
- Ten Simple Rules for Better Figures | PLOS Computational Biologyjournals.plos.org