Python Forum

Full Version: Creating Plots & Sharing X Axis
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all

I am trying to create a plot in matplotlib where I have 2 x data sets, Data Set 1 which has a list of XY co-ordinates (where the Y values are always positive) and Data Set 2 which has the same X values but different Y values and these Y values are all negative.

I want to plot both data sets on the same plot but share the X axis.

I was hoping to create a plot similar to the one attached.

Does anyone have any ideas?

Thank you.
Did you try .twinx axes method?
ax1 = ax0.twinx()
ax1.plot(...) # ax0 and ax1 share x-axis.
scidam

Thanks.