Below is the working code to plot two different data series with different units on the same graph, with the same x co-ordinates:
import pylab # generate some data x = range(0, 10) y1 = [i*i for i in x] y2 = [pylab.sin(0.4*i) for i in x] # the data share x axis but have different y units figure = pylab.gcf() # Get the current figure orig_axis = pylab.gca() # Get the current axis orig_axis.set_axis_off() # Turn it off to avoid complications # use this for the overlapping axes box = [0.14, 0.14, 0.72, 0.72] # This uses the first set of data axis1 = figure.add_axes(box, label = 'axis1') axis1.set_title('TITLE') axis1.plot(x, y1, '-^y') axis1.set_ylabel('AXIS 1 LABEL') axis1.set_xlabel('SHARED X LABEL') axis1.spines['right'].set_visible(False) # This uses the second set of data # Note the same box region is used but the label must be different axis2 = figure.add_axes(box, label = 'axis2') axis2.plot(x, y2, '-sb') axis2.yaxis.set_ticks_position('right') axis2.yaxis.set_label_position('right') axis2.set_ylabel('AXIS 2 LABEL') axis2.spines['bottom'].set_visible(False) axis2.spines['top'].set_visible(False) axis2.spines['left'].set_visible(False) # Write out to a file pylab.savefig('out.png', dpi = 100, transparent = True) Issues: 1) I can't use show() in this case because there is no Transparent parameter. 2) It's still a botch. 3) I tried using alpha but it didn't seem to work at all? Does anyone have a better implementation of this or better ideas? Many thanks James
------------------------------------------------------------------------------
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users