Hello I'm trying to make a graph with one Y axis and 4 X axis
I don't want to make separate graphs and was wondering if it is possible to put multiple X axis using the twinx() command.
The problem I'm having is that the final axis I'm trying to add ends up appearing on both sides of the graph and I just want it on the left.
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
import matplotlib.pyplot as plt
host = host_subplot(111, axes_class=AA.Axes)
par1 = host.twinx()
par2 = host.twinx()
new_fixed_axis = par2.get_grid_helper().new_fixed_axis
par2.axis["right"] = new_fixed_axis(loc="right",axes=par2,offset=(60, 0))
par2.axis["right"].toggle(all=True)
host.set_xlabel("Y axis")
host.set_ylabel("X axis 1 on the left")
par1.set_ylabel("X axis 2 on the right") par2.set_ylabel("X axis 3 on the right")
par3 = host.twinx()
new_fixed_axis = par3.get_grid_helper().new_fixed_axis
par3.axis["left"] = new_fixed_axis(loc="left",axes=par3,offset=(-60, 0))
par3.axis["left"].toggle(all=True)
par3.set_ylabel("X axis 4 on the left")
p1, = host.plot([1,2,3,4],[1,2,3,4], label="1")
p2, = par1.plot([1,2,3,4],[2,2,2,2], label="2")
p3, = par2.plot([1,2,3,4],[3,3,2,1], label="3")
p4, = par3.plot([1,2,3,4],[1,1,2.5,3.5], label="4")
plt.show()