Gökhan Sever wrote: > Hi, > > The code below should create a properly placed 2nd x-axis. You might need to > adjust the placement of the figure canvas to match into the window. > > import numpy as np > import matplotlib.pyplot as plt > from mpl_toolkits.axes_grid.parasite_axes import SubplotHost > > fig = plt.figure(figsize=(10,8)) > host = SubplotHost(fig, 111) > fig.add_subplot(host) > parx = host.twiny() > > parx.axis["top"].set_visible(False) > offset = 0, -50 > new_axisline = parx.get_grid_helper().new_fixed_axis > parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset) > parx.axis["bottom"].label.set_visible(True) > > hplt, = host.plot(np.random.rand(100)) > p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0, > color='green') > > plt.show() > > > There is also another example at: > http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisartist- with-parasiteaxes > > Hope this helps. Yes, that's very helpful. Just one thing. How would I get a bit more bottom margin on the main figure to leave more room for the extra axis?
I'm using this as an example. I experimented with plt.subplots_adjust, which seems like it might do the right thing. Is this the 'best' approach? (I really don't know what all these methods do, just guessing) import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid.parasite_axes import SubplotHost from matplotlib.backends.backend_pdf import PdfPages pdf = PdfPages('results.pdf') fig = plt.figure(figsize=(10,8)) host = SubplotHost(fig, 111) ax = fig.add_subplot(host) plt.subplots_adjust (bottom=0.1) parx = host.twiny() parx.axis["top"].set_visible(False) offset = 0, -30 new_axisline = parx.get_grid_helper().new_fixed_axis parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset) parx.axis["bottom"].label.set_visible(True) hplt, = host.plot(np.linspace(0,20,100), np.random.rand(100)) plt.xlabel ('Es/No') p2, = parx.plot(np.linspace(0,20,100)-5, np.random.rand(100)*5.0, color='green') parx.set_xlabel ('$Eb_{i}/No$') #plt.show() pdf.savefig (fig) plt.close() pdf.close() ------------------------------------------------------------------------------ Using storage to extend the benefits of virtualization and iSCSI Virtualization increases hardware utilization and delivers a new level of agility. Learn what those decisions are and how to modernize your storage and backup environments for virtualization. http://www.accelacomm.com/jaw/sfnl/114/51434361/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users