When building multiple y axes in Matplotlib, is there a way to specify how to align the origin (and / or some ytick labels) of the right axis with a specific value of the left axis?
Here is my problem: I would like to build two datasets, as well as their difference (basically, I'm trying to reproduce this kind of graph ).
I can play it, but I need to manually adjust the ylim of the right axis so that the origin is aligned with the value I want from the left axis.
I have provided an example of a simplified version of the code used below. As you can see, I need to manually adjust the scale of the right axis to align the beginning of the right axis, as well as the square.
import numpy as np import scipy as sp import matplotlib.pyplot as plt grp1 = np.array([1.202, 1.477, 1.223, 1.284, 1.701, 1.724, 1.099, 1.242, 1.099, 1.217, 1.291, 1.305, 1.333, 1.246]) grp2 = np.array([1.802, 2.399, 2.559, 2.286, 2.460, 2.511, 2.296, 1.975]) fig = plt.figure(figsize=(6, 6)) ax = fig.add_axes([0.17, 0.13, 0.6, 0.7])