(sorry if this is a duplicate post)
Jae,
Thank you for your help. I found the problem. It was caused
by using pyplot.title(). It is working better now.
I next have to
figure out how to do the following within AxesGrid:
-
How to convert the x axis labels from an integer
value representing epoch seconds to a nicely formatted date. I think
this has something to do with matplotlib.dates.DateFormatter. I hope that this will remove the 1.25325e9 from the plot. -
How to minimize or eliminate the white bands on the right and
bottom of each axes caused by the axis scale exceeding the data values. -
How
to eliminate (or hide) the first major tic label on the y axis (always 0) so it
doesn’t overlap with the last tick from the previous y axis.
It seems like there may be a different way to approach this than with subplot()
Regards,
-Ryan
Here’s a complete example:
from matplotlib import pyplot
from mpl_toolkits.axes_grid import AxesGrid
from numpy import arange, linspace, meshgrid, random, transpose
Generate some data
x_dim = linspace(1253250000,1253250000 + 606024,47) # This is epoch seconds
y_dim = arange(0,-2.7,-0.1)
z_dim = {}
z_dim[‘chl’] = random.rand(len(x_dim),len(y_dim)) + linspace(5,26,len(y_dim))
z_dim[‘do’] = random.rand(len(x_dim),len(y_dim)) + linspace(5,10,len(y_dim))
z_dim[‘turb’] = random.rand(len(x_dim),len(y_dim)) + linspace(4.5,12.5,len(y_dim))
x_grid,y_grid = meshgrid(x_dim,y_dim)
x_grid = transpose(x_grid)
y_grid = transpose(y_grid)
Start the plotting routines
DAP_figure = pyplot.figure(1,(8,8))
#pyplot.title(‘Title goes here’) # THIS IS THE LINE THAT CAUSES THE EARLIER PROBLEM
pyplot.figtext(0.05,.5,“Depth (m)”,rotation=‘vertical’,verticalalignment=‘center’)
Create a grid of axes with the AxesGrid helper class
my_grid = AxesGrid(DAP_figure, 111, # Only one grid in DAP_figure
nrows_ncols = (3,1),
axes_pad = 0.0, #pad between axes in inches
aspect=False, #By default (False), widths and heigths of axes in the
grid are scaled independently. If True, they are scaled according to
their data limits
add_all=True, # Add axes to figures if True (default True)
share_all=False, # xaxis & yaxis of all axes are shared if True (default False)
label_mode = “L”, # location of tick labels thaw will be displayed. “1”
(only the lower left axes), “L” (left most and bottom most axes), or
“all”
cbar_location="right", # "right" or "top"
cbar_mode="each", # "None","single", or "each"
cbar_size="2%",
cbar_pad="1%",
)
for i,parameter in enumerate(z_dim):
ax = my_grid[i].pcolor(x_grid,y_grid,z_dim[parameter])
my_grid[i].set_ylabel(parameter) # Puts a y label on every graph. Eventually we want this labeled only once.
my_grid.cbar_axes[i].colorbar(ax)
my_grid.cbar_axes[i].axis["right"].toggle(ticklabels=True,label=True)
my_grid.cbar_axes[i].set_ylabel("units")
my_grid[i].axis["bottom"].major_ticklabels.set_rotation(45) #
pyplot.show()
···
On Tue, Dec 8, 2009 at 7:39 PM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
Did you test the code in my previous post?
If you want to get some help, you need to take your time to create a simple and complete example (which reproduces the problem) that others can easily test.
Since I believe the problem is due to the existence of an extra axes, your example don’t need to show any images. Please post a simple script that draws a blank AxesGrid and shows extra ticklabels as your current code does.
Regards,
-JJ