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) |
|
|
|
|
|
|
From: Michael R. <raw...@ya...> - 2011-01-05 22:42:17
|
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()
|
|
From: Paul I. <piv...@gm...> - 2011-01-05 22:17:43
|
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 |
|
From: Paul I. <piv...@gm...> - 2011-01-05 21:10:06
|
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 |
|
From: Bob L. <bo...@tr...> - 2011-01-05 18:47:11
|
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 |
|
From: Benjamin R. <ben...@ou...> - 2011-01-05 17:47:57
|
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 |
|
From: Michael R. <raw...@ya...> - 2011-01-05 16:44:23
|
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')
|
|
From: John H. <jd...@gm...> - 2011-01-05 15:59:15
|
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 |
|
From: Benjamin R. <ben...@ou...> - 2011-01-05 15:52:01
|
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 |
|
From: Juan D. M.C. <jvm...@uc...> - 2011-01-05 15:51:06
|
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, |
|
From: Juan D. M.C. <jdm...@gm...> - 2011-01-05 15:44:30
|
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, |
|
From: Neal B. <ndb...@gm...> - 2011-01-05 13:20:28
|
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. |
|
From: Alain P. F. <fra...@it...> - 2011-01-05 13:19:35
|
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()
##############################
|
|
From: Arthur D. <ar...@xs...> - 2011-01-05 09:21:23
|
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 |
|
From: Benjamin R. <ben...@ou...> - 2011-01-05 01:30:13
|
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 |
|
From: Paul I. <piv...@gm...> - 2011-01-05 00:17:57
|
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
|