I've having a problem creating multiple x-axis and I'm hoping someone
here will be able to help me. I have two directly correlated values
(z and N) that I am using as the independent variables. What I would
like to do is plot my data vs. N, but then show the corresponding z
values on the top axis (there is a 1-to-1 correspondence between every
z and N value). I have tried twiny, but this requires me to plot the
line again and, since the z and N values are scaled differently, I end
up with 2 lines that don't match up.
I hope that was understandable. Any advice? Thanks.
-Jeffrey
I've having a problem creating multiple x-axis and I'm hoping someone
here will be able to help me. I have two directly correlated values
(z and N) that I am using as the independent variables. What I would
like to do is plot my data vs. N, but then show the corresponding z
values on the top axis (there is a 1-to-1 correspondence between every
z and N value). I have tried twiny, but this requires me to plot the
line again and, since the z and N values are scaled differently, I end
up with 2 lines that don't match up.
Hi Jeffrey,
Are you adverse to drawing two lines? If you use the 'twiny'
approach, you can simply manually set the top-axis limits to
correspond to what you need:
In [2]: plot([1,2,3], [4,5,6])
Out[2]: [<matplotlib.lines.Line2D instance at 0x91abd8>]
In [3]: ax1 = gca()
In [4]: ax2 = gcf().add_axes(ax1.get_position(), sharey=ax1, frameon=False)
In [5]: ax2.xaxis.tick_top()
In [6]: plot([1.3, 2.6, 3.9],[4,5,6])
Out[6]: [<matplotlib.lines.Line2D instance at 0x1b76ab8>]
In [7]: ax2.set_xlim([1.3,3.9])
Out[7]: (1.3, 3.8999999999999999)
In [8]: draw()
Cheers,
ยทยทยท
On Wed, Oct 22, 2008 at 7:27 AM, Jeffrey Fogel <matplotlib@...2127...> wrote: