You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(2) |
2
(4) |
3
(16) |
4
(4) |
5
(15) |
6
(16) |
7
(6) |
8
(4) |
9
(9) |
10
(5) |
11
(8) |
12
(14) |
13
(19) |
14
(21) |
15
(8) |
16
(6) |
17
(10) |
18
(22) |
19
(15) |
20
(7) |
21
(21) |
22
(1) |
23
(6) |
24
(16) |
25
(12) |
26
(11) |
27
(27) |
28
(7) |
29
|
30
(4) |
31
(5) |
|
|
|
|
|
Paul, Thanks for the detailed tutorial. I'm getting errors when I attempt to use plt.subplots(1,1) and the newcm assignment. Traceback (most recent call last): File "colorbar_Mytest2.py", line 17, in <module> f, ax = plt.subplots(1,1) AttributeError: 'module' object has no attribute 'subplots' Here are just a few of the errors I'm getting when executing colorbar command with newcm. Also, what does In and Out do, as in Out[68]: 0.34999999999999998 ? plt.draw() File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 352, in draw get_current_fig_manager().canvas.draw() File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", line 215, in draw FigureCanvasAgg.draw(self) File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line 314, in draw self.figure.draw(self.renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 773, in draw for a in self.axes: a.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in draw_wrapper Here's a simplified version that works for me: from matplotlib import pyplot, mpl import sys,getopt from mpl_toolkits.basemap import Basemap, shiftgrid, cm #from netCDF3 import Dataset as NetCDFFile from mpl_toolkits.basemap import NetCDFFile from pylab import * vals = norm(np.linspace(14,40,1000)) newcm = cm.colors.ListedColormap(cm.hot_r(vals)) # Make a figure and axes with dimensions as desired. fig = pyplot.figure(figsize=(8,3)) #f, ax = plt.subplots(1,1) ax1 = fig.add_axes([0.05, 0.4, 0.9, 0.14]) #ax2 = fig.add_axes([0.05, 0.8, 0.9, 0.6]) # Set the colormap and norm to correspond to the data for which # the colorbar will be used. cmap = mpl.cm.cool norm = mpl.colors.Normalize(vmin=0, vmax=40) # here set colorbar min/max mycolormap=cm.hot maprev = cm.hot_r #f,(ax2,ax3) = plt.subplots(2,1) cb2 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r, norm=norm, orientation='horizontal') #cb2.set_label('"percent"') #cb3 = mpl.colorbar.ColorbarBase(ax1, cmap=newcm, # orientation='horizontal') #cb3.set_label("colormap interval 0.0-1.0") plt.draw()
Neal Becker, on 2011年01月05日 08:19, wrote: > I want to plot semilogy with major and minor grid. I tried: > > plt.grid(which='both') > > But 2 problems: > > 1) For semilogy, most of my viewers will expect to see 10 minor > ticks/major tick. I got 5. How do I change it? Hi Neal, odd, it works here. (See attached image) In [1]: plt.semilogy(((np.random.rand(50)*9+1))) If your problem persists, can you provide a small example where this does not work? You might check the minor locator - make sure that it is base 10 In [2]: plt.gca().yaxis.minor.locator._base Out[2]: 10.0 > 2) I'd like the major ticks to be solid lines, and minor ticks > to be dashed. I got all dashed. In [3]: plt.grid(which='major', linestyle='solid') In [4]: plt.grid(which='minor', linestyle='dashed') -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Michael Rawlins, on 2011年01月05日 08:44, wrote: > How does one define a range of colors for a custom user-defined > colormap? I'm fairly new to matplotlib and have been using > standard colormaps. Below is a sample program that makes a > color bar based on the hot colormap. I'd like to have a > colormap like hot, but that starts at, say, orange (near 14%), > and runs to black (40%). Hi Michael, first a quick aside: your reversing of the colormap is unnecessary - just change the colordict assignment line to be: colordict=cm.hot_r._segmentdata.copy() and get rid of the two nested for loops. Or better still, get rid of colordict altogether and just use maprev = cm.hot_r Ok, as far as your question - I'm not certain that this is what you're asking for - but if you want to construct a colormap that "stretches" the portion of your plot that goes from 14 to 40 "percent" (as labeled), to be the entire range of a colormap - use the following: All colormaps take as input a value from 0.0-1.0, and give you back an rgba tuple. You already have a normalization 'norm' in there which maps an arbitrary interval (0-40 in your case) to the 0.0-1.0 interval. So you like the color value at 14 - let's find out what the scalar value for 14 is, once it's mapped to the 0.0-1.0 interval. In [68]: norm(14) Out[68]: 0.34999999999999998 So that's the value we will pass to cm.hot_r to get the color at 14. Let's verify that this is actually what's going on - I'll create a new figure and plot just one big dot on there of what should hopefully be the same color. In [69]: f, ax = plt.subplots(1,1) In [70]: plt.scatter(0,0,c=cm.hot_r(norm(14)),s=1000) # c is color, s is size Out[70]: <matplotlib.collections.CircleCollection object at 0xae9002c> Ok, that looks good. We can repeat the procedure for the 40 "percent" case In [89]: norm(40) Out[89]: 1.0 In [90]: plt.scatter(0,0,c=cm.hot_r(norm(40)),s=1000) Out[90]: <matplotlib.collections.CircleCollection object at 0xae97c4c> No surprises there (it's black). Now let's create our own segmented map. You can look at the documentation and an example: http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html but a LinearSegmentedColormap just splits deals with the rgb channels seperately, and for each color, defines transition points in the 0.0-1.0 interval which are refered to as 'x' in the links above, as well as the color to use before the transition point ('y0'), and the color to use after the point ('y1'). Here's a quote from the docs about this: Each row in the table for a given color is a sequence of x, y0, y1 tuples. In each sequence, x must increase monotonically from 0 to 1. For any input value z falling between x[i] and x[i+1], the output value of a given color will be linearly interpolated between y1[i] and y0[i+1]: row i: x y0 y1 / / row i+1: x y0 y1 Hence y0 in the first row and y1 in the last row are never used. Armed with this knowledge, you can now use the color from cm.hot_r(norm(14)) to get the entries for the first rows of your new map (remember that you're doing red, green, and blue seperately) - and then remap the remaining transition points (the 'x' portion of the tuple) to stretch portion of the colormap's 0.0-1.0 interval that you're interested in (i.e. map 0.345-1.0 to 0.0-1.0). Now that's only if you want full control of the linear segments - there's a quick and dirty way to get what you want by specifying a ListedColormap using values taken from the colormap you're using. I'll just get a whole bunch of values from the desired interval of the colormap, map them through the colormap, and get my new colormap out. In [209]: vals = norm(np.linspace(14,40,1000)) In [210]: newcm = cm.colors.ListedColormap(cm.hot_r(vals)) Let's plot the original map (as in your email), and the new one we created. In [211]: f,(ax2,ax3) = plt.subplots(2,1) In [212]: cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cm.hot_r, .....: norm=norm, .....: orientation='horizontal') In [213]: cb2.set_label('"percent"') In [214]: In [215]: cb3 = mpl.colorbar.ColorbarBase(ax3, cmap=newcm, .....: orientation='horizontal') In [216]: cb3.set_label("colormap interval 0.0-1.0") In [217]: plt.draw() And to further clarify that we did the right thing, let's adjust the xlim on that original plot. In [221]: ax2.set_xlim(norm(14),norm(40)) Out[221]: (0.34999999999999998, 1.0) In [222]: plt.draw() Hope this clears things up, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
I'm trying to figure out how to capture arrow and function key events in matplotlib running with PyQt4. I can get ASCII characters, but not things like F1 or left arrow. This is a repeat request, but I'm not sure my earlier posting (which got no response) made it to the list, as I was not a subscriber at the time. In any case, I wanted to make sure that nobody knows how to do this before filing a feature request. - Bob Lewis
On Wed, Jan 5, 2011 at 9:50 AM, Juan David M.C. <jvm...@uc...> wrote: > Hello, anyone know the best way to draw networks with matplotlib, such > as gas networks. > > How plotted lines link?, straight lines or otherwise to minimize the > junction of lines. > > thanks and regards, > > Juan, There aren't a lot of easy ways to do it, although it is possible! However, NetworkX has been suggested in the past: http://networkx.lanl.gov/index.html I hope this is helpful! Ben Root
How does one define a range of colors for a custom user-defined colormap? I'm fairly new to matplotlib and have been using standard colormaps. Below is a sample program that makes a color bar based on the hot colormap. I'd like to have a colormap like hot, but that starts at, say, orange (near 14%), and runs to black (40%). ''' Make a colorbar as a separate figure. ''' from matplotlib import pyplot, mpl import sys,getopt from mpl_toolkits.basemap import Basemap, shiftgrid, cm #from netCDF3 import Dataset as NetCDFFile from mpl_toolkits.basemap import NetCDFFile from pylab import * usemaprev=True # Make a figure and axes with dimensions as desired. fig = pyplot.figure(figsize=(8,3)) ax1 = fig.add_axes([0.05, 0.4, 0.9, 0.14]) # Set the colormap and norm to correspond to the data for which # the colorbar will be used. cmap = mpl.cm.cool norm = mpl.colors.Normalize(vmin=0, vmax=40) # here set colorbar min/max # alter a matplotlib color table, # cm.jet is very useful scheme, but reversed colors are better for drought colordict=cm.jet._segmentdata.copy() # dictionary ('blue', 'green', 'red') of nested tuples # autumn scheme is yellow to red colordict=cm.hot._segmentdata.copy() #mycolormap=cm.jet mycolormap=cm.hot for k in colordict.keys(): colordict[k]=[list(q) for q in colordict[k]] #convert nested tuples to nested list for a in colordict[k]: a[0]=1.-a[0] #in inner list, change normalized value to 1 - value. colordict[k].reverse() #reverse order of outer list maprev = cm.colors.LinearSegmentedColormap("maprev", colordict) #map = cm.colors.LinearSegmentedColormap("map", colordict) if usemaprev: mycolormap=maprev print "using reverse of defined colormap" #ax1 = fig.add_axes([0.05, 0.65, 0.9, 0.15]) #cax = axes([0.85, 0.1, 0.05, 0.7]) # setup colorbar axes #colorbar(format='%d') # draw colorbar # ColorbarBase derives from ScalarMappable and puts a colorbar # in a specified axes, so it has everything needed for a # standalone colorbar. There are many more kwargs, but the # following gives a basic continuous colorbar with ticks # and labels. #cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=jetrev, # norm=norm, # orientation='horizontal') cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=mycolormap, norm=norm, orientation='horizontal') cb1.set_label('percent') #pyplot.show() plt.savefig('colormap.png')
On Wed, Jan 5, 2011 at 9:51 AM, Benjamin Root <ben...@ou...> wrote: > > > On Tue, Jan 4, 2011 at 5:49 AM, Marcin Dulak <mar...@gm...>wrote: > >> Hi, >> >> the formlayout part in the latest matplotlib requires python >= 2.5 >> See >> >> http://www.mail-archive.com/mat...@li.../msg19219.html >> That causes troubles on very popular in RHEL 5 based distributions - >> they use an old python 2.4 still. >> > I already fixed this in my tree, haven't committed yet. Thanks, JDH
On Tue, Jan 4, 2011 at 5:49 AM, Marcin Dulak <mar...@gm...> wrote: > Hi, > > the formlayout part in the latest matplotlib requires python >= 2.5 > See > > http://www.mail-archive.com/mat...@li.../msg19219.html > That causes troubles on very popular in RHEL 5 based distributions - > they use an old python 2.4 still. > Can this be fixed for the next release? > > Best regards, > > Marcin > > Absolutely... this is definitely a bug and should be fixed for the 1.0.1rc release. I will patch it up right now. Ben Root
Hello, anyone know the best way to draw networks with matplotlib, such as gas networks. How plotted lines link?, straight lines or otherwise to minimize the junction of lines. thanks and regards,
Hello, anyone know the best way to draw networks with matplotlib, such as gas networks. How plotted lines link?, straight lines or otherwise to minimize the junction of lines. thanks and regards,
I want to plot semilogy with major and minor grid. I tried: plt.grid(which='both') But 2 problems: 1) For semilogy, most of my viewers will expect to see 10 minor ticks/major tick. I got 5. How do I change it? 2) I'd like the major ticks to be solid lines, and minor ticks to be dashed. I got all dashed.
Hi, I'm plotting two subplots using bar charts, the first one contains one dataset (one bar for each abscissa value), the second 3 dataset (3 bars for each abscissa value, each one with its own color). The legend of the multibars chart is not correct, it shows the color of the first dataset for all the bars legend. Note that it works correctly with matplotlib.pyplot.plot instead of matplotlib.pyplot.bar. Any idea to fix it? Thanks, A.Frances CODE OF MULTIBARS #------------------------------------------------------------------------------- # Name: multibars # Purpose: # # Author: alf # # Created: 05-01-2011 # Copyright: (c) alf 2010 # Licence: <your licence> #------------------------------------------------------------------------------- #!/usr/bin/env python import matplotlib.pyplot as plt from numpy import array import random strTitle = 'Bars plot - multi data and legend' x = array(range(10)) y1 = [] y2 = [[],[],[]] for i in range(len(x)): y1.append(1.0 + random.random()) for j in range(len(y2)): y2[j].append(0.5 + random.random()) lbl_y1 = [] lbl_y1.append('bar 1') lbl_y2 = 'bar 2' lbl_type = ['red', 'green', 'blue'] colors_y2 = ([1,0,0],[0,1,0],[0,0,1]) lbls_y2 = [] for i in range(len(lbl_type)): lbls_y2.append(lbl_y2 + " " + lbl_type[i]) fig = plt.figure() ax1=fig.add_subplot(2,1,1) ax1.set_title("Single data") plt.bar(x, y1, color='purple', linewidth = 0, align='edge', width = 0.8) plt.legend(lbl_y1, loc= 0) plt.xticks(x) ax2=fig.add_subplot(2,1,2, sharex=ax1) ax2.set_title("Multi data") for i in range(len(y2)): plt.bar(x+(0.8*float(i)/len(y2)),y2[i],color = colors_y2[i], linewidth=0, align='edge', width = (0.8/len(y2))) plt.legend(lbls_y2, loc=0) plt.xticks(x) plt.subplots_adjust(left=0.05, bottom=0.1, right=0.95, top=0.95, wspace=0.1, hspace=0.15) plt.show() ############################## CODE OF MULTILINES #------------------------------------------------------------------------------- # Name: multilines # Purpose: # # Author: alf # # Created: 05-01-2011 # Copyright: (c) alf 2010 # Licence: <your licence> #------------------------------------------------------------------------------- #!/usr/bin/env python import matplotlib.pyplot as plt from numpy import array import random strTitle = 'Lines plot - multi data and legend' x = array(range(10)) y1 = [] y2 = [[],[],[]] for i in range(len(x)): y1.append(1.0 + random.random()) for j in range(len(y2)): y2[j].append(0.5 + random.random()) lbl_y1 = [] lbl_y1.append('line 1') lbl_y2 = 'line 2' lbl_type = ['red', 'green', 'blue'] colors_y2 = ([1,0,0],[0,1,0],[0,0,1]) lbls_y2 = [] for i in range(len(lbl_type)): lbls_y2.append(lbl_y2 + " " + lbl_type[i]) fig = plt.figure() ax1=fig.add_subplot(2,1,1) ax1.set_title("Single data") plt.plot(x, y1, color='purple') plt.legend(lbl_y1, loc= 0) plt.xticks(x) ax2=fig.add_subplot(2,1,2, sharex=ax1) ax2.set_title("Multi data") for i in range(len(y2)): plt.plot(x,y2[i],color = colors_y2[i]) plt.legend(lbls_y2, loc=0) plt.xticks(x) plt.subplots_adjust(left=0.05, bottom=0.1, right=0.95, top=0.95, wspace=0.1, hspace=0.15) plt.show() ##############################
LS, How can it be done to create a 3D axis on an QtTabwidget with the mplwidget. I can make a 2d plot but not 3d. How can this be done ? Thanks, Arthur
On Tue, Jan 4, 2011 at 6:17 PM, Paul Ivanov <piv...@gm...> wrote: > Gf B, on 2011年01月04日 12:31, wrote: > > On Mon, Jan 3, 2011 at 3:53 PM, Paul Ivanov <piv...@gm...> > wrote: > > Gf B, on 2011年01月03日 15:23, wrote: > > > > Can such a "grid of grids" be done with matplotlib? If so, could > someone > > > > show me how? > > > > > > You'll be able to group the inner grids visually by adjusting the > > > spacing. As far as getting the spines to only outline the outer > > > grid, and not the inner grid - I think you'll have to do it > > > manually by hiding the appropriate spines for the inner subplots. > > > > > > > This sort of ad-hoc manual tweaking is what I was hoping to avoid. > > > > What would it take to implement a "true" grid-of-grids function in > > matplotlib? What I mean by this is a function that can arrange in a grid > > not only plots but also other grids. (Is this a question for the devel > > group?) > > I think the true grid-of-grids functunality is already > implemented. Here's a replication of your Mathematica plots: > > ------------ > import numpy as np > import matplotlib.pyplot as plt > import matplotlib.gridspec as gridspec > from itertools import product > > def squiggle_xy(a, b, c, d, i=np.linspace(0.0, 2*np.pi, 200)): > return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d) > > f = plt.figure(figsize=(8, 8)) > > # gridspec inside gridspec > outer_grid = gridspec.GridSpec(4, 4, wspace=0.0, hspace=0.0) > for i in xrange(16): > inner_grid = gridspec.GridSpecFromSubplotSpec(3, 3, > subplot_spec=outer_grid[i], wspace=0.0, hspace=0.0) > a, b = int(i/4)+1,i%4+1 > for j, (c, d) in enumerate(product(range(1, 4), repeat=2)): > ax = plt.Subplot(f, inner_grid[j]) > ax.plot(*squiggle_xy(a, b, c, d)) > ax.set_xticks([]) > ax.set_yticks([]) > f.add_subplot(ax) > > all_axes = f.get_axes() > > #show only the outside spines > for ax in all_axes: > for sp in ax.spines.values(): > sp.set_visible(False) > if ax.is_first_row(): > ax.spines['top'].set_visible(True) > if ax.is_last_row(): > ax.spines['bottom'].set_visible(True) > if ax.is_first_col(): > ax.spines['left'].set_visible(True) > if ax.is_last_col(): > ax.spines['right'].set_visible(True) > > plt.show() > ------------ > > It's a matter of taste, but I think you can get away hiding all > spines, and just setting the hspace and wspace for the outer_grid > to some small value (this is what I meant by 'adjusting the > spacing'). > > I'll send a patch to the devel list shortly adding this example > with the following documentation > > A Complex Nested GridSpec using SubplotSpec > =========================================== > Here's a more sophisticated example of nested gridspect where we put > a box around outer 4x4 grid, by hiding appropriate spines in each of the > inner 3x3 grids. > > it'll be placed on the gridspec page, after this section: > > http://matplotlib.sourceforge.net/users/gridspec.html#gridspec-using-subplotspec > > best, > -- > Paul Ivanov > 314 address only used for lists, off-list direct email at: > http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 > > Just to add, because it is related, another tool that gives you advanced control over your axes is the AxesGrid toolkit: http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html#toolkit-axesgrid-index However, gridspec should be exactly what you need for this particular problem. Ben Root
Gf B, on 2011年01月04日 12:31, wrote: > On Mon, Jan 3, 2011 at 3:53 PM, Paul Ivanov <piv...@gm...> wrote: > Gf B, on 2011年01月03日 15:23, wrote: > > > Can such a "grid of grids" be done with matplotlib? If so, could someone > > > show me how? > > > > You'll be able to group the inner grids visually by adjusting the > > spacing. As far as getting the spines to only outline the outer > > grid, and not the inner grid - I think you'll have to do it > > manually by hiding the appropriate spines for the inner subplots. > > > > This sort of ad-hoc manual tweaking is what I was hoping to avoid. > > What would it take to implement a "true" grid-of-grids function in > matplotlib? What I mean by this is a function that can arrange in a grid > not only plots but also other grids. (Is this a question for the devel > group?) I think the true grid-of-grids functunality is already implemented. Here's a replication of your Mathematica plots: ------------ import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec from itertools import product def squiggle_xy(a, b, c, d, i=np.linspace(0.0, 2*np.pi, 200)): return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d) f = plt.figure(figsize=(8, 8)) # gridspec inside gridspec outer_grid = gridspec.GridSpec(4, 4, wspace=0.0, hspace=0.0) for i in xrange(16): inner_grid = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=outer_grid[i], wspace=0.0, hspace=0.0) a, b = int(i/4)+1,i%4+1 for j, (c, d) in enumerate(product(range(1, 4), repeat=2)): ax = plt.Subplot(f, inner_grid[j]) ax.plot(*squiggle_xy(a, b, c, d)) ax.set_xticks([]) ax.set_yticks([]) f.add_subplot(ax) all_axes = f.get_axes() #show only the outside spines for ax in all_axes: for sp in ax.spines.values(): sp.set_visible(False) if ax.is_first_row(): ax.spines['top'].set_visible(True) if ax.is_last_row(): ax.spines['bottom'].set_visible(True) if ax.is_first_col(): ax.spines['left'].set_visible(True) if ax.is_last_col(): ax.spines['right'].set_visible(True) plt.show() ------------ It's a matter of taste, but I think you can get away hiding all spines, and just setting the hspace and wspace for the outer_grid to some small value (this is what I meant by 'adjusting the spacing'). I'll send a patch to the devel list shortly adding this example with the following documentation A Complex Nested GridSpec using SubplotSpec =========================================== Here's a more sophisticated example of nested gridspect where we put a box around outer 4x4 grid, by hiding appropriate spines in each of the inner 3x3 grids. it'll be placed on the gridspec page, after this section: http://matplotlib.sourceforge.net/users/gridspec.html#gridspec-using-subplotspec best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Hi all, I've created a custom projection for drawing Lambert plots on two adjacent hemispheres, copied closely from the custom_projection_example [1], and attached here. The basics are working I think, but the axes objects have too much whitespace around them, and I can't immediately work out what approach to take to reduce it to something reasonable. Can anyone point me in the right direction? Ultimately I'm hoping to be able to put several of these plots together in a figure, which is currently not practical. (Also, pcolor doesn't work as I expect, but I need to play around with that a bit more before I know what question I need to ask of the list.) Thanks, Angus. [1] http://matplotlib.sourceforge.net/examples/api/custom_projection_example.html -- AJC McMorland Post-doctoral research fellow Neurobiology, University of Pittsburgh
2011年1月1日 OKB (not okblacke) <bre...@br...>: > I noticed that the boxplot function incorrectly calculates the > location of the median line in each box. As a simple example, plotting > the dataset [1, 2, 3, 4] incorrectly plots the median line at 3. It seems to work fine in matplotlib 1.0.0: user@host:~$ python Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib as mpl >>> mpl.__version__ '1.0.0' >>> import matplotlib.pyplot as plt >>> import matplotlib.mlab as mlab >>> plt.ion() >>> plt.boxplot([1, 2, 3, 4]) {'medians': [<matplotlib.lines.Line2D object at 0x3ad6250>], 'fliers': [<matplotlib.lines.Line2D object at 0x3ad6610>, <matplotlib.lines.Line2D object at 0x3ad69d0>], 'whiskers': [<matplotlib.lines.Line2D object at 0x3acff50>, <matplotlib.lines.Line2D object at 0x3ad4310>], 'boxes': [<matplotlib.lines.Line2D object at 0x3ad4e50>], 'caps': [<matplotlib.lines.Line2D object at 0x3ad46d0>, <matplotlib.lines.Line2D object at 0x3ad4a90>]} >>> plt.grid() >>> plt.boxplot([1, 2, 3, 4]) {'medians': [<matplotlib.lines.Line2D object at 0x3dfbad0>], 'fliers': [<matplotlib.lines.Line2D object at 0x3dfbe90>, <matplotlib.lines.Line2D object at 0x3dff290>], 'whiskers': [<matplotlib.lines.Line2D object at 0x3df8810>, <matplotlib.lines.Line2D object at 0x3df8b90>], 'boxes': [<matplotlib.lines.Line2D object at 0x3dfb710>], 'caps': [<matplotlib.lines.Line2D object at 0x3df8f50>, <matplotlib.lines.Line2D object at 0x3dfb350>]} >>> plt.grid() >>> # See attached image. ... >>> mlab.prctile([1, 2, 3, 4]) array([ 1. , 1.75, 2.5 , 3.25, 4. ]) Goyo > > It also seems that the quartile calculations for the box are a > little peculiar. I have seen some discussion in old mailing list > postings about mlab.prctile and its ways of calculating percentiles, > which are different than those of some other software. > > I'm aware that there is legitimate disagreement about the "best" > way to calculate the quartiles. However, it seems to me that mlab's way > is still not any of these possibly-correct ways, because it uses int() > or nparray.astype(int) to coerce the percentile result to an integer > index. This TRUNCATES the floating-point result. No accepted quantile- > calculating method that I'm aware of does this; they all ROUND instead > of truncating (if they want to coerce to an integer index at all, in > order to produce a quantile value that is an element of the data set), > or in some cases they round uniformly up for the lower quartile and > down for the upper. You can see a summary of different methods at > http://www.amstat.org/publications/jse/v14n3/langford.html ; the method > used by mlab does not appear to agree with any of these. > > I would suggest that mlab.prctile be fixed to conform to some one > or other of these methods, rather than adding to the proliferation of > approaches to quantile-calculation. Is there any motivation for always > truncating to integer (other that "it's quicker to type" :-)? > > Also, regardless of these quartile issues, there is, as far as I'm > aware, no one who denies that the median of a (sorted) data set with an > even number of values is the mean of the middle two values. Since numpy > is already a dependency for matplotlib, boxplot shouldn't use > mlab.prctile at all to decide where to plot the median line -- just use > numpy.median. > > Thanks, > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. Go, instead, where there is > no path, and leave a trail." > --author unknown
On Mon, Jan 3, 2011 at 3:53 PM, Paul Ivanov <piv...@gm...> wrote: Hi, Paul. Thanks for the links! Gf B, on 2011年01月03日 15:23, wrote: > > Can such a "grid of grids" be done with matplotlib? If so, could someone > > show me how? > > You'll be able to group the inner grids visually by adjusting the > spacing. As far as getting the spines to only outline the outer > grid, and not the inner grid - I think you'll have to do it > manually by hiding the appropriate spines for the inner subplots. > This sort of ad-hoc manual tweaking is what I was hoping to avoid. What would it take to implement a "true" grid-of-grids function in matplotlib? What I mean by this is a function that can arrange in a grid not only plots but also other grids. (Is this a question for the devel group?) G.
Hi, the formlayout part in the latest matplotlib requires python >= 2.5 See http://www.mail-archive.com/mat...@li.../msg19219.html That causes troubles on very popular in RHEL 5 based distributions - they use an old python 2.4 still. Can this be fixed for the next release? Best regards, Marcin
On Mon, Jan 3, 2011 at 11:36 AM, Drew Stokes <dre...@gm...> wrote: > > Hi, > I'm very new to Matplotlib and python but I ma getting excellent results in > what I am trying to achieve. That said I have come up against an issue I > can't seem to find a resolution to and was wondering if someone here may be > able to help out. > > I have a script that generates a number of plots. The first plot comes out > fine but there seems to be a little hang over in regards to format or data > into the following plots. I have alternated the script by putting each plot > first and the same applies the first plot is fine the rest are ok but there > are odd points plotted. I wonder if there is a method of flushing or > clearing formats etc that I could use. Sorry if I'm getting terminology > wrong this is all still rather new to me. > > Drew > Drew, Do you have a very simple script that reproduces the issue you are experiencing? From the script, we might be able to spot what is wrong. Ben Root
Gf B, on 2011年01月03日 15:23, wrote: > > Can such a "grid of grids" be done with matplotlib? If so, could someone > show me how? Take a look at GridSpec - in particular: http://matplotlib.sourceforge.net/users/gridspec.html#gridspec-using-subplotspec You'll be able to group the inner grids visually by adjusting the spacing. As far as getting the spines to only outline the outer grid, and not the inner grid - I think you'll have to do it manually by hiding the appropriate spines for the inner subplots. Have a look here for how to do that: http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html best -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
I'm trying to do something in matplotlib that I do routinely in Mathematica, a "grid of grids" of plots. I made a hi-res JPEG of what this looks like in Mathematica: http://is.gd/k2cXb (you may need to zoom in, but it's definitely legible; don't focus too much on the Mathematica code; what matters are the figures). This is just an example for illustration. In reality, I'm interested in plotting experimental data. In that example, I have a function called squiggle that takes 4 positive integers as arguments and produces a squiggly plot. Then I create a "grid of grids" of such plots, parametrized by row and column numbers. For example, the lower-left cell of the outer grid corresponds to a=4 and b=1. The inner grid within that cell consists of all the plots squiggle[4, 1, c, d], where c and d each range over {1, 2, 3}. Notice in particular that the outer grid is constructed with different specs from those used in the inner grid (in this example, the outer grid has gridlines separating the cells, whereas the inner grids don't). This is what differentiates this problem from the one of simply building one giant grid with all the figures. In particular, it is of paramount importance that the inner grids be grouped visually. When I try to replicate this with matplotlib I get stuck at the inner level. IOW, I can make the inner grids, but I don't know how to aggregate them into the outer grid. For example, this code produces the inner grid corresponding to a=4, b=1: # ----------------------------------------------------------------------------- import matplotlib.pyplot as plt from numpy import arange, sin, cos, pi from itertools import product def squiggle_xy(a, b, c, d, i=arange(0.0, 2*pi, 0.005)): return sin(i*a)*cos(i*b), sin(i*c)*cos(i*d) plt.figure(figsize=(8, 8)) a, b = 4, 1 for i, (c, d) in enumerate(product(range(1, 4), repeat=2)): ax = plt.subplot(3, 3, i + 1) plt.plot(*squiggle_xy(a, b, c, d)) ax.set_xticks([]) ax.set_yticks([]) plt.show() # ----------------------------------------------------------------------------- Can such a "grid of grids" be done with matplotlib? If so, could someone show me how? Thanks! G.
On 01/03/2011 05:29 PM, Ryan May wrote: > On Mon, Jan 3, 2011 at 9:28 AM, Darren Dale<dsd...@gm...> wrote: >> On Mon, Jan 3, 2011 at 9:45 AM, Ryan May<rm...@gm...> wrote: >>> On Sun, Jan 2, 2011 at 12:24 PM, Xavier Gnata<xav...@gm...> wrote: >>>> "/usr/local/lib/python3.1/dist-packages/matplotlib/backends/qt4_editor/formlayout.py", >>>> line 59, in<module> >>>> from PyQt4.QtCore import (Qt, SIGNAL, SLOT, QSize, QString, >>>> ImportError: cannot import name QString >>>> >>>> Looks like this backend hasn't been ported yet. >>> I remember seeing this on Gentoo and, unfortunately, never tracked it >>> down. However, it seems to me this is a problem with your PyQt4 >>> install and Python 3, as QString should be found. >> It's not a problem with the PyQt4 installation. PyQt on python-3 uses >> PyQt's new API, which uses python strings and does not provide >> QString, QChar, and friends. >> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/pyqt4ref.html#selecting-incompatible-apis > I stand corrected. I don't know what's worse, being so blatently > wrong, or having wasted a bunch of time in the past trying to "fix" a > "broken" install. > > Time to don ye olde paper bag... > > Ryan > ok. It means that the qt4 backend need to be ported to python3. Should I try the tk backend ? What's the plan? First port matplotlib core? Focus on one backend? What do you want us to test? How should we report python3 related bugs? Xavier
Hi, I'm very new to Matplotlib and python but I ma getting excellent results in what I am trying to achieve. That said I have come up against an issue I can't seem to find a resolution to and was wondering if someone here may be able to help out. I have a script that generates a number of plots. The first plot comes out fine but there seems to be a little hang over in regards to format or data into the following plots. I have alternated the script by putting each plot first and the same applies the first plot is fine the rest are ok but there are odd points plotted. I wonder if there is a method of flushing or clearing formats etc that I could use. Sorry if I'm getting terminology wrong this is all still rather new to me. Drew -- View this message in context: http://old.nabble.com/clearing-previous-format-changes-tp30579911p30579911.html Sent from the matplotlib - users mailing list archive at Nabble.com.
On 01/02/2011 05:40 PM, Tom K. wrote: > [...] > FOURIER DEMO - PROBLEM AND FIX IN "lines.py" > Next I tried my wx-based gui http://wiki.wxpython.org/MatplotlibFourierDemo. > It raised assertions in lines.py, particularly the part where it tries to > access > path, affine = > self._transformed_path.get_transformed_path_and_affine() > (line 286) > since self._transformed_path is None. > When I fixed that by inserting > if self._transformed_path is None: > self._transform_path() > then it ran into problems with > ind += self.ind_offset > since ind_offset didn't exist. > I fixed that by adding > if hasattr(self, 'ind_offset'): > > Is modifying lines.py the only way to fix this, or should I do something > else in the fourier demo? I suspect this is a problem in 1.0 but not in svn or the new 1.0.1rc. I can't reproduce it using very recent svn. Eric > > Best regards, Happy New Year to all, etc, > - Tom K. >