placing xlabel in the correct place when using tick_top

Hi all,

I'm trying to produce a graph in which two different sets of axes are
superimposed, with both x- and y- ticks taking on different ranges.

I've managed to get the first set of axes to place its ticks on the
bottom and left of the figure, and the second set to place its ticks
on the top and right, however, xlabel and ylabel behave in an
unexpected manner: for the bottom-left axes, xlabel and ylabel place
text in the correct location, however, for the "top-right" axes,
xlabel and ylabel misbehave, placing the axis label text at the bottom
(for xlabel) and the left (for ylabel), but positioned closer to the
axis lines.

This seems to be due to some sort of bug with the "alignment" keyword
for xlabel and ylabel: i.e. alignment = "top" or alignment = "right"
does not behave as I would have expected.

I'm sorry if this has been reported before; I wasn't able to find
anything useful in the archives or elsewhere on the web.

See below for a simple example.

Thanks for your help!
Duncan

···

----

from pylab import *

fig = figure()

ax1 = fig.add_axes([0.1,0.1,0.8,0.8],label='axes 1')
ax2 = fig.add_axes([0.1,0.1,0.8,0.8],label='axes 2')

plot1 = ax1.plot([1,2,3],[1,2,3])
plot2 = ax2.plot([4,5,6],[3,2,1])

ax1.axis([0,4,0,4])
ax1.set_xlabel('bottom')
ax1.set_ylabel('left')

ax2.axis([3,7,0,4])
ax2.xaxis.tick_top()
ax2.yaxis.tick_right()
ax2.set_xlabel('top') # I expected this to place the word "top"
at the top of the figure, corresponding to the ticks for ax2's x-axis
ax2.set_ylabel('right') # I expected this to place the word
"right" at the right of the figure, corresponding to the ticks for
ax2's y-axis

ax2.axesPatch.set_fill(False) # so that you can see through to ax1

fig.canvas.draw()

Hi all,

I'm trying to produce a graph in which two different sets of axes are
superimposed, with both x- and y- ticks taking on different ranges.

I've managed to get the first set of axes to place its ticks on the
bottom and left of the figure, and the second set to place its ticks
on the top and right, however, xlabel and ylabel behave in an
unexpected manner: for the bottom-left axes, xlabel and ylabel place
text in the correct location, however, for the "top-right" axes,
xlabel and ylabel misbehave, placing the axis label text at the bottom
(for xlabel) and the left (for ylabel), but positioned closer to the
axis lines.

This seems to be due to some sort of bug with the "alignment" keyword
for xlabel and ylabel: i.e. alignment = "top" or alignment = "right"
does not behave as I would have expected.

I'm sorry if this has been reported before; I wasn't able to find
anything useful in the archives or elsewhere on the web.
Can anyone suggest a workaround? I don't have the time at the moment
to get to grips with the source.

See below for a simple example.

Thanks for your help!
Duncan

···

----

from pylab import *

fig = figure()

ax1 = fig.add_axes([0.1,0.1,0.8,0.8],label='axes 1')
ax2 = fig.add_axes([0.1,0.1,0.8,0.8],label='axes 2')

plot1 = ax1.plot([1,2,3],[1,2,3])
plot2 = ax2.plot([4,5,6],[3,2,1])

ax1.axis([0,4,0,4])
ax1.set_xlabel('bottom')
ax1.set_ylabel('left')

ax2.axis([3,7,0,4])
ax2.xaxis.tick_top()
ax2.yaxis.tick_right()
ax2.set_xlabel('top') # I expected this to place the word "top"
at the top of the figure, corresponding to the ticks for ax2's x-axis
ax2.set_ylabel('right') # I expected this to place the word
"right" at the right of the figure, corresponding to the ticks for
ax2's y-axis

ax2.axesPatch.set_fill(False) # so that you can see through to ax1

fig.canvas.draw()

http://matplotlib.sourceforge.net/search.html?q=set_label_position&check_keywords=yes&area=default

ax2.xaxis.set_label_position("top")
ax2.yaxis.set_label_position("right")

Regards,

-JJ

···

On Thu, Aug 13, 2009 at 12:10 AM, Duncan Mortimer<dmorti@...287...> wrote:

Hi all,

I'm trying to produce a graph in which two different sets of axes are
superimposed, with both x- and y- ticks taking on different ranges.

I've managed to get the first set of axes to place its ticks on the
bottom and left of the figure, and the second set to place its ticks
on the top and right, however, xlabel and ylabel behave in an
unexpected manner: for the bottom-left axes, xlabel and ylabel place
text in the correct location, however, for the "top-right" axes,
xlabel and ylabel misbehave, placing the axis label text at the bottom
(for xlabel) and the left (for ylabel), but positioned closer to the
axis lines.

This seems to be due to some sort of bug with the "alignment" keyword
for xlabel and ylabel: i.e. alignment = "top" or alignment = "right"
does not behave as I would have expected.

I'm sorry if this has been reported before; I wasn't able to find
anything useful in the archives or elsewhere on the web.
Can anyone suggest a workaround? I don't have the time at the moment
to get to grips with the source.

See below for a simple example.

Thanks for your help!
Duncan

----

from pylab import *

fig = figure()

ax1 = fig.add_axes([0.1,0.1,0.8,0.8],label='axes 1')
ax2 = fig.add_axes([0.1,0.1,0.8,0.8],label='axes 2')

plot1 = ax1.plot([1,2,3],[1,2,3])
plot2 = ax2.plot([4,5,6],[3,2,1])

ax1.axis([0,4,0,4])
ax1.set_xlabel('bottom')
ax1.set_ylabel('left')

ax2.axis([3,7,0,4])
ax2.xaxis.tick_top()
ax2.yaxis.tick_right()
ax2.set_xlabel('top') # I expected this to place the word "top"
at the top of the figure, corresponding to the ticks for ax2's x-axis
ax2.set_ylabel('right') # I expected this to place the word
"right" at the right of the figure, corresponding to the ticks for
ax2's y-axis

ax2.axesPatch.set_fill(False) # so that you can see through to ax1

fig.canvas.draw()

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users