set_position does not work with axes_grid toolkits.
Try something like
ax.LABELPAD = 0
However, note that this (and set_rotation) may not work with
mpl_toolkits in future release of matplotlib as there has been some
ps. please use "reply to all", so that messages stay inside the list.
On Mon, Feb 1, 2010 at 7:52 PM, Kim Cheung <ecs1749@...287...> wrote:
Thanks for the reply.
The position call works with the first example but not the second:
# Example 1
pylab.plot(data1, label='Score 2005')
pylab.plot(data2, label='Num 2006')
pylab.plot(data1, label='Score 06')
pylab.plot(data2, label='Num 06')
xlabels = pylab.gca().get_xticklabels()
ylabels = pylab.gca().get_yticklabels()
pylab.setp(xlabels, 'rotation', 90)
pylab.setp(xlab, position=(0.2,0.1)) # <=== This line works
But doesn't work in this example:
# Example 2
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
figprops = dict(figsize=(8., 8. / 1.618), dpi=128)
# Figure properties
adjustprops = dict(left=0.08, bottom=0.12, right=0.79, top=0.96,
wspace=0.2, hspace=0.2) # Subplot properties
fig = plt.figure(**figprops)
# Tunes the subplot layout
host = SubplotHost(fig, 111)
p0, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
plt.setp(ax.label, visible=True, text="Density", size=12,
plt.setp(ax.label, position=(0.2,0.1)) # This line has no effect.
Jae-Joon Lee wrote:
Are you using the axes_grid toolkit?
Standard matplotlib axis instance does not have "major_ticklabels"
attribute, while axes_grid axis does.
Please post a simple, but complete example that can be run and tested.
On Sun, Jan 31, 2010 at 11:06 AM, <kc106_2005-matplotlib@...9...> >> wrote:
BTW: I tried to use set_position to change the position of the axes label
as suggested by previous posting. No effect.
----- Original Message ----
I am creating a plot with multiple y-axis (up to 6) and twinx
works pretty well. The problem is that there are too much wasted spaces
by the axes. Since I have multiple axes, it cuts into the amount of
available for the plot area. I need to know how I can squeeze some
spaces out of
the standard axes. First thing I discovered was that I can rotate the
labels to vertical by:
where ax is my y-axis. But then:
(1) How to reduce the space between the tick and the axes label?
First I tried to place the label on top but couldn't get that to work.
tried to change the position property of the axis label object and that
effect. So, can somebody please tell me how I can do these 2 things?
(2) How to avoid overlapping tick labels?
With the way the standard x and y axis are drawn, after I do a vertical
of the y tick labels, the first y tick label overlaps with the last x
since they are both center aligned. Is there any way to change the
only the first and last tick labels of an axes (while keeping the rest
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call
Matplotlib-users mailing list