From: Jae-Joon L. <lee...@gm...> - 2009-12-03 21:36:54
|
On Thu, Dec 3, 2009 at 3:40 PM, Ryan Neve <rya...@gm...> wrote: > > I tried all sorts of things, but finally, by setting aspect=False I got it > to work. In the documentation, the table says this defaults to True and the > explanation of aspect below says it defaults to False. Although I don't > entirely understand what is going on, I think this threw me off. > So then I had this: > Can you be more specific about which documentation says the default aspect is False? This may need to be fixed. Note that AxesGrid is designed for displaying images with aspect=True. Otherwise, you may better stick to the subplot.. > [image: 84Kna.png] > ... which looks much better, except that there are two sets of x and y axis > labels? This seems to have something to do with the colorbar. I've got: > > To me, there is another axes underneath the AxesGrid. It is hard to tell without a complete code. > label_mode = "L", > cbar_location="right", > cbar_mode="each", > cbar_size="2%", > cbar_pad="0.5%" > > Now I'm trying to get scales and labels on my colorbars. > I tried: > for i,parameter in enumerate(z_dim): > ax = my_grid[i].pcolor(x_grid,y_grid,z_dim[parameter]) # This is the > pcolor plot > my_grid[i].set_ylabel('Depth') # Correctly puts a y label on every > plot. > cb = my_grid.cbar_axes[i].colorbar(ax) # Puts in a colorbar for this > axes?s > cb.set_ylabel(parameter) #It would be nice if this was on the far right > next to the colorbar. I don't see it anywhere. Perhaps underneath something? The label of the colorbar is set to invisible by default (this is a bug). So, try something like my_grid.cbar_axes[i].set_ylabel(parameter) my_grid.cbar_axes[i].axis["right"].toggle(ticklabels=True, label=True) > > [image: DPkWz.png] > It looks like perhaps the colorbar axes is inside the ax axes rather than > besides it? > In the demo_grid_with_each_cbar<http://matplotlib.sourceforge.net/examples/axes_grid/demo_axes_grid.html>example, how would you put a scale and label on the colorbar like in this > plot:? > [image: 58dFK.png] > I can put a y_label on each contour plot, but since they all have depth, > I'd like to label this only once. > Is there a way to label the entire AxesGrid (or is that subplot?)? > > Does label_mode="1" do what you want? You may manually make some of the labels invisible. Please post a "complete", but simple, script that reproduces your problem. Otherwise, it is hard to track down what is wrong. Also, please report what version of matplotlib you're using. The axes_grid toolkit is relatively new and some of the feature may not work in older versions. Regards, -JJ > Thank you very much for your help, > > -Ryan > > > > On Wed, Dec 2, 2009 at 10:21 PM, Jae-Joon Lee <lee...@gm...>wrote: > >> This happens because, when the AxesGrid is created, gca() is set to the >> last axes, which is the last colobar axes. >> >> If you use axes_grid toolkit, you'd better not use pyplot command that >> works on axes. Instead, use axes method directly. >> >> For example, instead of "pyplot.pcolor(..)" , use "ax.pcolor(..)". >> >> Regards, >> >> -JJ >> >> >> >> >> On Wed, Dec 2, 2009 at 2:18 PM, Ryan Neve <rya...@gm...> wrote: >> >>> Hello, >>> >>> I'm trying to use AxesGrid but I'm running into a problem: >>> I can plot a single pcolor plot: >>> [image: 58dFK.png] >>> But when I try to use AxesGrid, my pcolor plot is ending up where I >>> expect my colorbar to be. >>> [image: mEbTA.png] >>> >>> I want to have up to 6 of these plots stacked vertically, sharing a >>> common time axis and y (depth) scale. >>> >>> I'll try to simplify my code to show what I'm doing: >>> >>> # I have arrays x_grid and y_grid for time and water depth. >>> # z_dim is a dictionary of arrays (one for each plot) >>> # In the plot above it has two arrays. >>> from matplotlib import pyplot >>> nrows = len(z_dim) # Number of rows is the number of arrays >>> My_figure = pyplot.figure(1,(8,8)) >>> my_grid = AxesGrid(My_figure, 111, #Is this always 111? >>> nrows_ncols = (nrows,1), # Always one column >>> axes_pad = 0.1, >>> add_all=True, >>> share_all=True, # They all share the same time and depth >>> scales >>> label_mode = "L", >>> cbar_location="right", >>> cbar_mode="each", >>> cbar_size="7%", >>> cbar_pad="2%", >>> ) >>> for row_no,parameter in enumerate(z_dim): >>> ax = my_grid[row_no] >>> ax = pyplot.pcolor(x_grid,y_grid,z_dim[parameter]) >>> pyplot.draw() >>> pyplot.show() >>> >>> I eventually want to end up with something like this matlab output (which >>> I didn't generate): >>> [image: jiIaK.png] >>> but without the duplication of x scales. >>> >>> I'm new to pyplot and even after reading the documentation much of this >>> is baffling. >>> >>> -Ryan >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Join us December 9, 2009 for the Red Hat Virtual Experience, >>> a free event focused on virtualization and cloud computing. >>> Attend in-depth sessions from your desk. Your couch. Anywhere. >>> http://p.sf.net/sfu/redhat-sfdev2dev >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> > |