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
|
|
From: James B. <bo...@ll...> - 2004-09-15 18:18:33
|
John,
Thanks for your help. I'm still having a bit of trouble.
Enclosed is the code and plot. I cannot figure out why the major ticks
are at hour 16.
What I want is for the major ticks to be at 2mar 00, 3 mar 00 etc.
i.e. start at the xaxis origin.
Thanks for any help.
Jim
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import matlab
ML = matlab
from matplotlib.ticker import YearLocator, MonthLocator, DateFormatter,
DayLocator,HourLocator, DayMultiLocator
import datetime
from matplotlib.dates import PyDatetimeConverter
pydates = PyDatetimeConverter()
date1 = datetime.datetime( 2000, 3, 2, 0)
date2 = datetime.datetime( 2000, 3, 5, 0)
delta = datetime.timedelta(hours=6)
dates = []
d = date1
while d <= date2:
dates.append(d)
d = d + delta
eDates = [ pydates(d) for d in dates ]
y = ML.arrayrange( len(dates)*1.0)
ysq = y*y
majorTick = DayLocator(0)
minorTick = HourLocator(6)
ax = ML.subplot(111)
ax.plot_date(dates, ysq, pydates)
ax.set_xlim( (pydates(dates[0]), pydates(dates[-1])) )
ax.xaxis.set_major_locator(majorTick)
ax.xaxis.set_minor_locator(minorTick)
labels = ax.get_xticklabels()
ML.set(labels,'rotation', 90)
|
|
From: John H. <jdh...@ac...> - 2004-09-15 14:39:24
|
>>>>> "Christian" == Christian Kristukat <ge...@ho...> writes:
Christian> Hi, when doing simple plots and reducing the figuresize
Christian> to e.g. (4,3) it happens that the axis labels are
Christian> clipped especially if the y-axis tick labels have many
Christian> digits, but it happens as well for the x-axis. How can
Christian> that be solved? Christian
The fact that tick labels aren't very smart - they can overlap
adjacent subplots for example - is a typical source of annoyance. The
only thing you can do in the current implementation is to make them
smaller or control their placement. You can make them smaller by
default by setting the
axes.labelsize : 12 # fontsize of the x any y labels
tick.labelsize : 10 # fontsize of the tick labels
properties in your rc file or by using the rc command. You can also
set the properties of individual labels
ticks = ax.get_xticklabels()
set(ticks, fontsize=8)
Alternatively, you can just set the xticks so that they are not so
close to the edge, eg
set(ax, xticks=(0.0, 0.5, 1.0))
JDH
|
|
From: Christian K. <ge...@ho...> - 2004-09-15 14:21:28
|
John Hunter wrote: > Christian> In fact the PNGs are looking too nice. I want to create > Christian> a GIF animation to be included in a p0werpoint > Christian> presentation. As p0werpoint automatically does > Christian> antialiasing for every bitmap graphic it produces ugly > Christian> results if the bitmap is already antialised. Anyway, > Christian> it's not that important... > > An alternative approach is to save a series of PNGs and use one of > many programs on the web to turn a series of images into a mpeg or > AVI. Perhaps then powerpoint won't try and be so helpful :-) Yes, that could be an idea. > What does it mean to look "too nice"? I guess that's a feature, not a > bug <wink> Yes, definitely. Christian |
|
From: Christian K. <ge...@ho...> - 2004-09-15 14:19:04
|
Hi, when doing simple plots and reducing the figuresize to e.g. (4,3) it happens that the axis labels are clipped especially if the y-axis tick labels have many digits, but it happens as well for the x-axis. How can that be solved? Christian |
|
From: John H. <jdh...@ac...> - 2004-09-15 14:18:46
|
>>>>> "Christian" == Christian Kristukat <ge...@ho...> writes:
Christian> In fact the PNGs are looking too nice. I want to create
Christian> a GIF animation to be included in a p0werpoint
Christian> presentation. As p0werpoint automatically does
Christian> antialiasing for every bitmap graphic it produces ugly
Christian> results if the bitmap is already antialised. Anyway,
Christian> it's not that important...
An alternative approach is to save a series of PNGs and use one of
many programs on the web to turn a series of images into a mpeg or
AVI. Perhaps then powerpoint won't try and be so helpful :-)
What does it mean to look "too nice"? I guess that's a feature, not a
bug <wink>
JDH
|
|
From: Christian K. <ge...@ho...> - 2004-09-15 14:15:49
|
John Hunter wrote: > What do you want this feature - is it because it doesn't look nice in > printouts of agg PNGs (this has come up before)? If so, and you have > a postscript printer, that may be your best bet. You could also try > the SVG output, for which there are plugins or programs that would > probably know how to send an svg doc to your printer. In fact the PNGs are looking too nice. I want to create a GIF animation to be included in a p0werpoint presentation. As p0werpoint automatically does antialiasing for every bitmap graphic it produces ugly results if the bitmap is already antialised. Anyway, it's not that important... Christian |
|
From: John H. <jdh...@ac...> - 2004-09-15 13:54:07
|
>>>>> "Christian" == Christian Kristukat <ge...@ho...> writes:
Christian> Hi, is it possible to turn off antialiasing for the
Christian> axes and labels of a plot, or does it affect the data
Christian> only?
Yes and no.
You can turn off antialiasing by default for all lines and patches
(which includes the axes frame since the frame is a Rectangle which
derives from Patch in matplotlib.patches) by setting
lines.antialiased : False
patch.antialiased : False
in your matplotlibrc file http://matplotlib.sf.net/.matplotlibrc. You
can also do this for an individual script using the rc command -
http://matplotlib.sf.net/matplotlib.matlab.html#-rc.
If you only want to selectively turn off antialiasing for the axes
lines and rectangle, you can set the antialised property to False for
all the relevant objects
from matplotlib.matlab import *
ax = subplot(111)
plot([1,2,3])
grid(True)
objects = (ax.get_xticklines() + ax.get_yticklines() +
ax.get_xgridlines() + ax.get_ygridlines() +
[ax.get_frame()]
)
set(objects, antialiased=False)
show()
As for text, assuming you are using one of the *Agg backends, you
cannot get aliased text. agg uses the freetype module ft2font for
text rendering. Off the top of my head, I don't know if freetype has
an aliased option (Anyone?), and I know the matplotlib wrapper doesn't
currently support it if it does.
You always have the option of using a backend that doesn't support
antialiasing (eg wx, ps), but most of them do in some regard; eg gtk
uses antialiased text but not lines, I believe.
What do you want this feature - is it because it doesn't look nice in
printouts of agg PNGs (this has come up before)? If so, and you have
a postscript printer, that may be your best bet. You could also try
the SVG output, for which there are plugins or programs that would
probably know how to send an svg doc to your printer.
JDH
|
|
From: John H. <jdh...@ac...> - 2004-09-15 12:16:32
|
>>>>> "James" == James Boyle <bo...@ll...> writes:
James> I have been trying to use the plot_date of matplotlib
James> (0.6.2.4) with limited success. Apparently, I must have
James> some basic misconception as to what is going on. What I am
James> try to do is plot data that has values every 6 hours with
James> major ticks at each day and minor every 12 hours. Attached
James> is my latest attempt. The basic problem is that the major
James> and minor ticks do not line up.
James> Thanks for any help. code and plot are below
Hi Jim,
You are using the constructor of DayLocator incorrectly. There are
two day tickers. It's a bit confusing because the constructor of
DayLocator takes an hour on which to place the tick, and
DayMultiLocator takes an integer base and ticks days which are
multiples of that base
* DayLocator - locate a given hour each day
* DayMultiLocator - Make ticks on day which are multiples of base
When you say DayLocator(1), you are placing a tick every day *at 1am*.
If you say DayLocator(5), the tick is at 5am. You want the default
constructor DayLocator(), which places the tick at hour=0, midnight.
Nice file name, by the way :-)
JDH
|
|
From: Christian K. <ge...@ho...> - 2004-09-15 10:20:54
|
Hi, is it possible to turn off antialiasing for the axes and labels of a plot, or does it affect the data only? Christian |
|
From: James B. <bo...@ll...> - 2004-09-14 22:16:17
|
I have been trying to use the plot_date of matplotlib (0.6.2.4) with
limited success.
Apparently, I must have some basic misconception as to what is going on.
What I am try to do is plot data that has values every 6 hours with
major ticks at each day and minor every 12 hours.
Attached is my latest attempt. The basic problem is that the major and
minor ticks do not line up.
Thanks for any help. code and plot are below
Jim
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import matlab
ML = matlab
from matplotlib.ticker import YearLocator, MonthLocator, DateFormatter,
DayLocator,HourLocator
import datetime
from matplotlib.dates import PyDatetimeConverter
majorTick = DayLocator(1)
minorTick = HourLocator(12)
pydates = PyDatetimeConverter()
date1 = datetime.datetime( 2000, 3, 2, 00)
date2 = datetime.datetime( 2000, 3, 5, 00)
delta = datetime.timedelta(hours=6)
dates = []
d = date1
while d <= date2:
dates.append(d)
d = d + delta
y = ML.arrayrange( len(dates)*1.0)
ysq = y*y
ax = ML.subplot(111)
ML.plot_date(dates, ysq, pydates)
ax.xaxis.set_major_locator(majorTick)
ML.set(ax,xlim = (pydates(dates[0]), pydates(dates[-1])))
ax.xaxis.set_minor_locator(minorTick)
ax.autoscale_view()
labels = ax.get_xticklabels()
ML.set(labels, 'rotation', 90)
|
|
From: John H. <jdh...@ac...> - 2004-09-14 20:02:53
|
>>>>> "Rodrigo" == Rodrigo Caballero <rc...@ge...> writes:
Rodrigo> Ok, here's the problem, illlustrated by a simple variant
Rodrigo> of the dynamic_image_gtkagg.py example (see below). I've
Rodrigo> put in a colorbar and I'm letting the amplitude of the
Rodrigo> pattern grow linearly in time. The result is that the
Rodrigo> colormap limits remained fixed at their initial values
Rodrigo> (-2,2), rather than change in time. If I don't put in the
Rodrigo> colorbar, the colormap limits *do* change. I'm a bit
Rodrigo> confused about all this. I tried changing the
Rodrigo> normalization of the colormap doing im.autoscale(z) each
Rodrigo> time z is updated, but that doesn't work ...
OK, I understand the problem now. The reason setting the colorbar
caused the behavior you find unusual (the colormap limits remain
fixed) stems from the call to
if norm.vmin is None or norm.vmax is None:
mappable.autoscale()
in matplotlib.matlab.colorbar. When the normalization limits are
None, the normalization class automatically uses the full range. This
call to autoscale sets the normalization limits, and after that they
are fixed.
I'll have to make some changes to the code to do this right, perhaps
creating a colorbar class instance on which you can call various
methods to get the desired behavior. The question is: what is the
right default behavior, and what are the other kinds of behaviors that
should be possible? I imagine that in some cases when you set the
array data for the main window, you want to colorbar and color limits
to update and autoscale it's range, and in other cases you want the
colorbar and limits to autoscale.
JDH
|
|
From: John H. <jdh...@ac...> - 2004-09-14 14:41:41
|
>>>>> "Jean-Michel" == Jean-Michel Philippe <jea...@ir...> writes:
Jean-Michel> With matplotlib 0.62.4 I wasn't able to detect any
Jean-Michel> effect of the 'edgecolor' property. I tried both
Jean-Michel> string color values ('w', 'k' and 'r') and floating
Jean-Michel> point color values (1.0, 0.95 and 0.5). What is it
Jean-Michel> supposed to change exactly, the window border, the
Jean-Michel> subplot border? Are my values wrong?
The window border.
The figure background frame is a rectangle. Like all rectangles in
matplotlib, it has a facecolor and an edgecolor. Eg, the default axes
facecolor is white and edgecolor is black. The figure facecolor in a
GUI backend is gray, which is modeled after matlab and in my opinion
is more pleasing to the eye than a field of white. The default
edgecolor is white, but it's easier to see if you use 'r'. I just
tested and it is visible in GTKAgg and WXAgg but appears to be clipped
in tkagg. Not sure why.
The other gotcha is that the default is different for savefig. That
is because when you want to save hardcopy, you typically do not want
that gray background so the face and edgecolor for savefig default to
white. Thus you would need to do
savefig('test.png', edgecolor='r')
to see it in hardcopy. Both the figure and savefig defaults are
exposed in the .matplotlibrc file.
I personally have never used the edgecolor property of figures. I
just added the attribute for completeness to expose the rectangle
properties.
JDH
|
|
From: John H. <jdh...@ac...> - 2004-09-14 14:25:29
|
>>>>> "Alan" == Alan G Isaac <ai...@am...> writes:
Alan> Crudely: I'm looking for something just as simple in
Alan> matplotlib.matlab. My last post outlined what I think the
Alan> current procedure is to achieve the same effect, and it is
Alan> much more cumbersome. While this matters little when one is
Alan> leisurely writing a script, it matters a lot when one is
Alan> doing interactive plotting in a classroom setting.
Alan> Now you point out that this request has an ambiguity: what
Alan> "physical" medium am I talking about? Specifically, a true
Alan> compression ratio on screen requires tricky stuff if dpiy !=
Alan> dpix. OK, I assume ignoring this will yield a "close
Alan> enough" result in a classroom setting, so the only time I
Alan> need it to be exact is when I produce figures for paper
Alan> display.
w/o having to worry about dpi differences in the x and y direction, it
is much easier, and your hardcopy will be correct in any case.
Do you really need arbitrary compression ratios, or just ratios equal
to 1. I added the option 'equal' to the axis command, which simply
sets the xlim and ylim to be equal and includes the range of both.
I'll include the modified axis method from matlab.py at the end of
this email. Thus you can do
from matplotlib.matlab import *
figure(figsize=(6,6))
ax = axes([0.1, 0.1, 0.8, 0.8])
plot(rand(100), rand(100), 'o')
axis('equal')
show()
Admittedly this is more typing than you want to do in an interactive
session. I experimented with a function 'square' which isn't the
right name but you get the idea. It handles setting the figure size,
axes ratio and lim ratio for you. Some suitably named function could
be included in the standard interface
from matplotlib.matlab import *
def square():
fig = gcf()
ax = gca()
figw, figh = fig.get_size_inches()
l,b,axw,axh = ax.get_position()
side = min([figw, figh])
frac = min([axw, axh])
fig.set_figsize_inches(side, side)
ax.set_position([l,b,frac,frac])
axis('equal')
draw()
plot(rand(100), rand(100), 'o')
square()
show()
It's the right idea, but it doesn't work currently if you are using a
GUI backend. The reason it fails is has to do with the pipeline order
in which figure managers, figures etc are created by default, and the
fact that configure events and resize events change the figure width
and height (so you can for example, resize your figure window). It
*does* work if you specify the figure size
figure(figsize=(8,8))
plot(rand(100), rand(100), 'o')
square()
show()
because then matplotlib has the information it needs at figure
creation time. Of course, you can set the figure size to have a unity
aspect ratio in your rc file and then you could do without the figsize
command altogether. I'll think about how to best fix the GUI resizing
problem. I'll probably need to add an observer to the figure limits
so that the GUI backend can update its size from script calls to
figure size. As an aside, traits are starting to look very useful,
with their build in observer framework.
For now, any feedback on whether this approach looks like the right
one, whether any ratios other than 1 are actually needed, what the
function square should be called and anything else is welcome.
JDH
def axis(*v):
"""
axis() returns the current axis as a length a length 4 vector
axis(v) where v= [xmin xmax ymin ymax] sets the min and max of the
x and y axis limits
axis('off') turns off the axis lines and labels
axis('equal') sets the xlim and ylim to be identical
"""
if len(v)==1 and is_string_like(v[0]):
s = v[0]
if s.lower()=='on': gca().set_axis_on()
elif s.lower()=='off': gca().set_axis_off()
elif s.lower()=='equal':
ax = gca()
xmin, xmax = ax.get_xlim()
ymin, ymax = ax.get_ylim()
vmin = min([xmin, ymin])
vmax = max([xmax, ymax])
ax.set_xlim((vmin, vmax))
ax.set_ylim((vmin, vmax))
draw_if_interactive()
else:
error_msg('Unrecognized string %s to axis; try on or off' % s)
return
try: v[0]
except IndexError:
xlim = gca().get_xlim()
ylim = gca().get_ylim()
return [xlim[0], xlim[1], ylim[0], ylim[1]]
v = v[0]
if len(v) != 4:
error_msg('v must contain [xmin xmax ymin ymax]')
return
gca().set_xlim([v[0], v[1]])
gca().set_ylim([v[2], v[3]])
draw_if_interactive()
|
|
From: Jean-Michel P. <jea...@ir...> - 2004-09-14 06:41:47
|
jdh...@ac... wrote:
> Docstring:
> figure(num = 1, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
>
With matplotlib 0.62.4 I wasn't able to detect any effect of the
'edgecolor' property. I tried both string color values ('w', 'k' and
'r') and floating point color values (1.0, 0.95 and 0.5). What is it
supposed to change exactly, the window border, the subplot border? Are
my values wrong?
Regards.
JM.
|
|
From: Alan G I. <ai...@am...> - 2004-09-14 05:28:12
|
On Mon, 13 Sep 2004, Chris Barker apparently wrote:
> I'm not sure what he means either, but it sounds like what he wants is
> to be able to specify the ratio of the x-scale and y-scale of the
> figure. Most commonly, you'd want to specify they are the same, like
> MATLAB's
> axis('equal')
This seems the same in the 2D case.
I haven't thought about what it means in the 3D case.
Cheers,
Alan Isaac
|
|
From: Alan G I. <ai...@am...> - 2004-09-14 05:28:11
|
Alan G Isaac <ai...@am...> writes: >> So this is almost a feature request. The only problem is >> that gnuplot's size command does not seem obviously suited >> to the matplotlib.matlab model, and I'm not sure what a good >> version would be. I think it would be something like "get >> the current axis, keep the "long" axis (as implied by the >> ratio) full length, and "shrink" the shorter axis as >> necessary to achieve the right ratio. This would respect >> the existing margins to everywhere except by the shrinking >> axis. However it would probably be better to adjust the >> figure size as well, to keep the margins unchanged. On Mon, 13 Sep 2004, John Hunter apparently wrote: > I'm not fully understanding you, in part because I find the > terminology ambiguous. Could you give an example of what you want to > achieve (eg a scatterplot with a square viewing window). For > concreteness, we have > ylim / xlim : the data view limits > axh / axw : the axes height / width, relative coords 0-1 > figh / figw : the figure width and height in inches > dpiy / dpix : the display devices resolution in pixels in the > vertical and horizontal directions > In order to get true physical sizes and ratios, we need to know dpiy > and dpix. matplotlib currently only supports a single dpi, though it > is still possible to hack true sizes by adjusting for example, figh > and figw to compensate for variation in dpiy and dpix. In gnuplot if I want to set a compression ratio of unity for a figure that has an xrange of [xmin,xmax] and a yrange of [ymin,ymax], I just say set size ratio (ymax-ymin)/(xmax-xmin) So e.g. if I do this when I am plotting a function f:R->R then the unit size will be physically identical along each axis. So for example if I plot a circle it looks like a circle and not an oval. In a very clever move, gnuplot also allows set size ratio -1 to achieve the same effect. Crudely: I'm looking for something just as simple in matplotlib.matlab. My last post outlined what I think the current procedure is to achieve the same effect, and it is much more cumbersome. While this matters little when one is leisurely writing a script, it matters a lot when one is doing interactive plotting in a classroom setting. Now you point out that this request has an ambiguity: what "physical" medium am I talking about? Specifically, a true compression ratio on screen requires tricky stuff if dpiy != dpix. OK, I assume ignoring this will yield a "close enough" result in a classroom setting, so the only time I need it to be exact is when I produce figures for paper display. Hope that is clearer. Thank you, Alan Isaac |
|
From: John H. <jdh...@ac...> - 2004-09-13 22:37:31
|
Chris> Hi, I have looked had a look around but I have been unable
Chris> to find out how to change the size (and orientation) of
Chris> graphs when I save them as eps or png files - using savefig
Chris> - any help or directions to help would be greatly
Chris> appreciated.
The flags you are looking for a re the figsize argument to the figure
command, and the orientation flag to the savefig command. Complete
docstrings below.
I didn't write the landscape support for PS/EPS (there is none
currently for png), but I think the following incantation is what you
are looking for
from matplotlib.matlab import *
figure(figsize=(11, 8.5))
plot([1,2,3])
savefig('temp.ps', orientation='landscape')
show()
Docstring:
figure(num = 1, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
Create a new figure and return a handle to it
If figure(num) already exists, make it active and return the
handle to it.
figure(1)
figsize - width in height x inches; defaults to rc figure.figsize
dpi - resolution; defaults to rc figure.dpi
facecolor - the background color; defaults to rc figure.facecolor
edgecolor - the border color; defaults to rc figure.edgecolor
rcParams gives the default values from the .matplotlibrc file
3 >>> savefig?
Type: function
Base Class: <type 'function'>
String Form: <function savefig at 0x414504fc>
Namespace: Interactive
File: /usr/local/lib/python2.3/site-packages/matplotlib/matlab.py
Definition: savefig(*args, **kwargs)
Docstring:
def savefig(fname, dpi=150, facecolor='w', edgecolor='w',
orientation='portrait'):
Save the current figure to filename fname. dpi is the resolution
in dots per inch.
Output file types currently supported are jpeg and png and will be
deduced by the extension to fname
facecolor and edgecolor are the colors os the figure rectangle
orientation is either 'landscape' or 'portrait' - not supported on
all backends; currently only on postscript output.
Hope this helps,
JDH
|
|
From: Rodrigo C. <rc...@ge...> - 2004-09-13 22:37:03
|
Ok, here's the problem, illlustrated by a simple variant of the
dynamic_image_gtkagg.py example (see below).
I've put in a colorbar and I'm letting the amplitude of the pattern
grow linearly in time. The result is that the colormap limits remained
fixed at their initial values (-2,2), rather than change in time. If I
don't put in the colorbar, the colormap limits *do* change. I'm a bit
confused about all this.
I tried changing the normalization of the colormap doing
im.autoscale(z) each time z is updated, but that doesn't work ...
Rodrigo
-----------
#!/usr/bin/env python
"""
An animated image
"""
import sys, time, os, gc
from matplotlib import rcParams
from matplotlib.matlab import *
import gtk
x = arange(120.0)*2*pi/120.0
x = resize(x, (100,120))
y = arange(100.0)*2*pi/100.0
y = resize(y, (120,100))
y = transpose(y)
z = sin(x) + cos(y)
im = imshow( z, cmap=cm.jet)#, interpolation='nearest')
colorbar()
manager = get_current_fig_manager()
cnt = 0
tstart = time.time()
def updatefig(*args):
global x, y, cnt, start
x += pi/15
y += pi/20
z = ( sin(x) + cos(y) ) * cnt/5.
im.set_array(z)
manager.canvas.draw()
cnt += 1
if cnt==50:
print 'FPS', cnt/(time.time() - tstart)
return gtk.FALSE
return True
cnt = 0
gtk.idle_add(updatefig)
show()
-----------------------------
On Monday, September 13, 2004, at 03:47 PM, John Hunter wrote:
>>>>>> "Rodrigo" == Rodrigo Caballero <rc...@ge...> writes:
>
> Rodrigo> One of my favorite aspects of matplotlib is how easy it
> Rodrigo> is to make dynamic plots. When doing this with 2D
> Rodrigo> renderings using pcolor or imshow, is there an easy way
> Rodrigo> to also dynamically update the colorbar?
>
> It should *just work*. images (matplotlib.image.AxesImage) and
> pcolors (matplotlib.collections.PolygonCollection) both derive from
> matplotlib.cm.ScalarMappable. This class implements an observer
> pattern, and the colorbar registers itself with the ScalarMappable
> instance. If you change the normalization, or colormap, or
> colorlimits, the ScalarMappable instance notifies it's observers, who
> update automagically.
>
> Let me know if you run into any troubles.
>
> JDH
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
> Project Admins to receive an Apple iPod Mini FREE for your judgement on
> who ports your project to Linux PPC the best. Sponsored by IBM.
> Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Chris <rea...@po...> - 2004-09-13 22:04:07
|
Hi, I have looked had a look around but I have been unable to find out how to change the size (and orientation) of graphs when I save them as eps or png files - using savefig - any help or directions to help would be greatly appreciated. What I want to do is save a graph that is a full page size in landscape orientation. Chris |
|
From: John H. <jdh...@ac...> - 2004-09-13 21:37:10
|
>>>>> "Rodrigo" == Rodrigo Caballero <rc...@ge...> writes:
Rodrigo> One of my favorite aspects of matplotlib is how easy it
Rodrigo> is to make dynamic plots. When doing this with 2D
Rodrigo> renderings using pcolor or imshow, is there an easy way
Rodrigo> to also dynamically update the colorbar?
It should *just work*. images (matplotlib.image.AxesImage) and
pcolors (matplotlib.collections.PolygonCollection) both derive from
matplotlib.cm.ScalarMappable. This class implements an observer
pattern, and the colorbar registers itself with the ScalarMappable
instance. If you change the normalization, or colormap, or
colorlimits, the ScalarMappable instance notifies it's observers, who
update automagically.
Let me know if you run into any troubles.
JDH
|
|
From: Rodrigo C. <rc...@ge...> - 2004-09-13 20:44:14
|
One of my favorite aspects of matplotlib is how easy it is to make dynamic plots. When doing this with 2D renderings using pcolor or imshow, is there an easy way to also dynamically update the colorbar? Thanks, Rodrigo |
|
From: Todd M. <jm...@st...> - 2004-09-13 17:53:25
|
On Mon, 2004-09-13 at 12:08, John Hunter wrote:
> >>>>> "Matt" == Matt Newville <new...@ca...> writes:
>
> Matt> I agree that it would not be that easy with TkAgg. I think
> Matt> you have to use Tkinter.Canvas.postscript() to get a
> Matt> representation of the whole canvas. Then you'd have to
> Matt> convert postscript to a bitmap that can be copied to the
> Matt> clipboard (using clipboard_copy() / clipboard_append()). I
> Matt> think that's not very easy, as PIL is not that good with
> Matt> postscript.
>
> Matt> It might be easier to switch to the Agg backend and create a
> Matt> bitmap that can then be copied to the clipboard. This looks
> Matt> possible, and might make a more uniform way to copy to
> Matt> clipboard.
>
> Matt> By the way, for the WXAgg backend, copy to the clipboard is
> Matt> fairly simple, as it already provides the bitmap: For a
> Matt> canvas = FigureCanvasWxAgg(...)
>
> Matt> This works: bmp = wx.BitmapDataObject()
> Matt> bmp.SetBitmap(canvas.bitmap) wx.TheClipboard.Open()
> Matt> wx.TheClipboard.SetData(bmp) wx.TheClipboard.Close()
>
> I don't know about how one accesses the operating system clipboard in
> tk or the other GUI toolkits (I assume this is platform dependent),
> but it is easy to get the bitmap from tkagg. FigureCanvasTkAgg
> derives from FigureCanvasAgg, which provides a method tostring_rgb.
> You should be able to use this to create a bitmap for copying to the
> clipboard.
That sounds pretty easy. I have two questions:
1. What is meant by "bitmap"? How standard is the format?
2. Is a "bitmap" the right format? What about EPS?
I guess that was 4.
Cheers,
Todd
>
> This is how wxagg's FigureCanvasWxAgg gets the bitmap in the first
> place
>
> def draw(self):
> """
> Render the figure using agg
> """
> DEBUG_MSG("draw()", 1, self)
>
> FigureCanvasAgg.draw(self)
> s = self.tostring_rgb()
> w = int(self.renderer.width)
> h = int(self.renderer.height)
> image = wxEmptyImage(w,h)
> image.SetData(s)
> self.bitmap = image.ConvertToBitmap()
>
> Hope this helps...
>
> Thanks for the wx example.
>
> JDH
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
> Project Admins to receive an Apple iPod Mini FREE for your judgement on
> who ports your project to Linux PPC the best. Sponsored by IBM.
> Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
|
|
From: John H. <jdh...@ac...> - 2004-09-13 16:57:50
|
>>>>> "Matt" == Matt Newville <new...@ca...> writes:
Matt> I agree that it would not be that easy with TkAgg. I think
Matt> you have to use Tkinter.Canvas.postscript() to get a
Matt> representation of the whole canvas. Then you'd have to
Matt> convert postscript to a bitmap that can be copied to the
Matt> clipboard (using clipboard_copy() / clipboard_append()). I
Matt> think that's not very easy, as PIL is not that good with
Matt> postscript.
Matt> It might be easier to switch to the Agg backend and create a
Matt> bitmap that can then be copied to the clipboard. This looks
Matt> possible, and might make a more uniform way to copy to
Matt> clipboard.
Matt> By the way, for the WXAgg backend, copy to the clipboard is
Matt> fairly simple, as it already provides the bitmap: For a
Matt> canvas = FigureCanvasWxAgg(...)
Matt> This works: bmp = wx.BitmapDataObject()
Matt> bmp.SetBitmap(canvas.bitmap) wx.TheClipboard.Open()
Matt> wx.TheClipboard.SetData(bmp) wx.TheClipboard.Close()
I don't know about how one accesses the operating system clipboard in
tk or the other GUI toolkits (I assume this is platform dependent),
but it is easy to get the bitmap from tkagg. FigureCanvasTkAgg
derives from FigureCanvasAgg, which provides a method tostring_rgb.
You should be able to use this to create a bitmap for copying to the
clipboard.
This is how wxagg's FigureCanvasWxAgg gets the bitmap in the first
place
def draw(self):
"""
Render the figure using agg
"""
DEBUG_MSG("draw()", 1, self)
FigureCanvasAgg.draw(self)
s = self.tostring_rgb()
w = int(self.renderer.width)
h = int(self.renderer.height)
image = wxEmptyImage(w,h)
image.SetData(s)
self.bitmap = image.ConvertToBitmap()
Hope this helps...
Thanks for the wx example.
JDH
|
|
From: Chris B. <Chr...@no...> - 2004-09-13 16:55:26
|
John Hunter wrote:
> I'm not fully understanding you, in part because I find the
> terminology ambiguous.
I'm not sure what he means either, but it sounds like what he wants is
to be able to specify the ratio of the x-scale and y-scale of the
figure. Most commonly, you'd want to specify they are the same, like
MATLAB's
axis('equal')
Even if the OP wasn't looking for that, I am. Can matplotlib do that?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
|
|
From: Matt N. <new...@ca...> - 2004-09-13 16:39:12
|
Hi, > It sounds more complicated than I thought. Indeed I was > searching for existing solutions that would copy the window > contents into clipboard. I know it is quite easy to do with > Tcl/Tk and the BLT extension or something similar. You just call > a function with the window path as arg and your clipboard is > filled. This is why I focused on TkAgg. I agree that it would not be that easy with TkAgg. I think you have to use Tkinter.Canvas.postscript() to get a representation of the whole canvas. Then you'd have to convert postscript to a bitmap that can be copied to the clipboard (using clipboard_copy() / clipboard_append()). I think that's not very easy, as PIL is not that good with postscript. It might be easier to switch to the Agg backend and create a bitmap that can then be copied to the clipboard. This looks possible, and might make a more uniform way to copy to clipboard. By the way, for the WXAgg backend, copy to the clipboard is fairly simple, as it already provides the bitmap: For a canvas = FigureCanvasWxAgg(...) This works: bmp = wx.BitmapDataObject() bmp.SetBitmap(canvas.bitmap) wx.TheClipboard.Open() wx.TheClipboard.SetData(bmp) wx.TheClipboard.Close() Hope that helps, --Matt |