I don't use wx so i'm not sure if this could be helpful, but you may
check the figimage command.
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.figimage
Note that it draws the image directly into the figure, thus no axes is needed.
-JJ
On Wed, Feb 25, 2009 at 6:09
Can't you simply use text?
text(0.5, 0.5, s, va=center, ha=center)
Unfortunately, no TextCollection yet.
-JJ
On Tue, Feb 24, 2009 at 4:49 PM, Fred Mailhot
fmail...@connect.carleton.ca wrote:
Hi,
I've looked through the documentation, and see that it's possible to
plot a variety of
Here is my modification.
Bbox = matplotlib.transforms.Bbox.from_bounds(.4, .1, .5, .3)
trans = ax.transAxes + fig.transFigure.inverted()
l, b, w, h = matplotlib.transforms.TransformedBbox(Bbox, trans).bounds
axins = fig.add_axes([l, b, w, h])
On Mon, Feb 23, 2009 at 2:49 PM,
On Mon, Feb 23, 2009 at 3:06 PM, Johann Rohwer j...@sun.ac.za wrote:
Is there any way of conveniently changing the font size of tick labels using
the object-oriented interface?
I'm aware of plt.xticks(fontsize=6), which does this globally for a figure,
but if I have a number of custom axes of
What version of maploltib are you using?
Your data displayed with correct scale with my installation of
matplotlib 0.98.5.2.
By the way, you're chaning the axes limit of the wrong axes.
matplotlib.pyplot.axes() create a new axes.
Use plt.xlim (or plt.ylim for y-limit), or use the method of the
I think the error is raised when you try to import matplotlib (not
when you try to save your figure)
matplotlib needs its config directory writable.
It first try MPLCONFIGDIR env. variable, then try $HOME/.matplotlib.
Here, the $HOME is the home directory of the user executing the script.
I think
1) WIthin this same pick handler function, have another if conditional,
but for the case when the user is picking the legend. In other words, I
want to pick the legend artist, not a Line2D artist.
I'm afraid but it is not clear what you want here (at least to me).
Can you just pick up the
This is in contrast to the effect of the following code:
try:
from math import *
import pylab as p
except:
print Couldn't import all dependent libraries
sys.exit()
dataLength = 100
data = [sin(2*pi*x/dataLength) for x in range(0,dataLength)]
p.plot(data)
Please take a look at our gallery to see what you can do with matplotlib.
http://matplotlib.sourceforge.net/gallery.html
I am working on the eye movement data of our driving experiment. It would be
interesting to look at the spatial distribution, and most frequent visited
AOIs.
You'd better
I believe that it does not actually change the y scale of the first
axes, but simply the
y tickmarks of the second axes gets visible again. It seems to me a
bug, though. Anyhow, I guess inserting following line after
ax2.set_yscale(log) should solve your problem.
ax2.yaxis.tick_right()
-JJ
On
When you say own axes, I presume you're using subplots.
You need to create your axes with different sizes (subplot creates
axes with same size), so that the height of images are equal when they
shrink to to fit in the axes box. You may create an axes with a given
size with following command
Since you call twinx then twiny, you're creating two additional axes, not one.
And I guess this is why labels are drawn twice. You may do
def twin(ax):
ax2 = ax.figure.add_axes(ax.get_position(True),
frameon=False)
ax2.yaxis.tick_right()
As far as I know, there is no user settable attribute. But something
like below will work.
ax = gca()
title(My title)
ax.titleOffsetTrans._t = (0., 10.0/72.) # x, y offset in points/72.
default is (0., 5/72.)
ax.titleOffsetTrans.invalidate()
draw()
Alternatively, you may use
Actually, I just went back and found a reply from Jae-Joon to a post of
mine in November about this. He points out that get_frame() is
deprecated, but that gca().frame.set_linewidth(2) should work. This is
not working for me either now (it was at the time), and now that I
notice, I am also
You cannot set different tick positions for bottom and top x-axis in
the same axes.
What you can do is to make another axes at the same location and use
it to draw ticks at top.
Take a look at
http://matplotlib.sourceforge.net/examples/api/two_scales.html
But it may not be an ideal solution for
I don't see any elegant way to do that.
The easiest way I can think of is to use a derived line2d class.
Something like below will work. Others may have better ideas.
import matplotlib.lines
class Line2DNoInterpolation(matplotlib.lines.Line2D):
def recache(self):
This is a bug introduced in the recent version of MPL.
While it is fixed in the maintenance branch, there is no release yet.
You may
1) try the svn version
or
2) apply the patch by yourself.
As Jouni suggested, the frameon argument needs to be applied to the
figure, not to the axes (or subplot).
Regards,
-JJ
On Mon, Jan 26, 2009 at 10:54 AM, Willi Richert w.rich...@gmx.net wrote:
Hi,
in my version 0.98.5 frameon=False (as a subplot argument) just omits the
black lines at the x
Norbert,
It did, thank you! One question, though: when I originally tried
something like this, it didn't work, because it was treating pl as a list
and giving me the error of
list object has no attribute 'set_mec()' Why does the addition of the
comma to pl allow it to see it as a line?
twinx makes a separate axes and zorders are only meaningful within a same axes.
Because ax2 is added to the figure later than the original axes,
artists in ax2 are always above others.
I don't think there is an easy way to make zorder work between several
axes, unless you somehow merge them into
I'm afraid that you may not be able to do those with the subplot.
If you want a fixed size axes, you need to manually calculate the axes
position (in normalized figure coordinates) using the figure size.
You may use my helper class which support a fixed-size axes.
va=baseline does not work?
-JJ
On Thu, Jan 15, 2009 at 3:05 AM, projet...@club-internet.fr wrote:
Dimension of a text in mpl is renderer-dependent in general.
Each renderer has get_text_width_height_descent method which returns
width, height, and descent of the given text.
If you're only
I presume that you're only interested in the math formula, and not in
any other graphical functionality of MPL. You may use mathtext module
directly in that case.
from matplotlib.mathtext import MathTextParser
p = MathTextParser(bitmap)
filename, texstr = test.png, r$\alpha$
p.to_png(filename,
If you use recent version of mpl, the size of the overall legend
should scale with the font size.
See below,
import matplotlib.font_manager
prop = matplotlib.font_manager.FontProperties(size=5)
lagend(prop=prop)
Just in case, my preference in your case is to move the legend outside
of the axes
Take a look at
http://matplotlib.sourceforge.net/users/text_props.html
But I guess MPL's functionality is somewhat limited compared to PyX,
especially in multiline support.
-JJ
On Wed, Jan 14, 2009 at 1:13 PM, projet...@club-internet.fr wrote:
Hello,
is there a similar functionnality to
-Joon Lee
A: projet...@club-internet.fr
Sujet: Re: [Matplotlib-users] Vertical alignment of a text
Copie à: matplotlib-users@lists.sourceforge.net
Take a look at
http://matplotlib.sourceforge.net/users/text_props.html
But I guess MPL's functionality is somewhat limited compared to PyX,
especially
The best I've come up with so far is to
create a figure with a set size, and then
add axes with a specified rectangle.
But this does not give a neat path to
what I want.
Alan,
I think the way you're doing is the easiest way.
Anyhow, can you provide an example of a neat path? In my view,
For my current use it would be enough if savefig had an option
bbox = 'tight'
so that only the area actually drawn in was written
to file.
The problem is that if you set the fig size and then
set the axis size proportionately, you must fiddle
with things to get a tight fit to
I guess you're missing vertical and horizontal alignment.
Also, your font properties were not set correctly. The 4th argument of
the text function is a color.
fontdict2 = {'fontweight':'light',
'color': 'r',
'fontsize':fontsize}
fp = FontProperties(fontdict2)
labels =
:
ltext = label.get_text()
lx,ly = label.get_position()
lrot=label.get_rotation()
va, ha = label.get_va(), label.get_ha()
t = plt.text(lx,ly,ltext, fontproperties=fp,
rotation=lrot,va=va, ha=ha)
plt.savefig('output.png')
Jae-Joon Lee wrote:
I guess you're missing
The exact location of the legend is known at drawing time. Thus, the
location of the text needs to be calculated at the drawing. I may help
you with this but it is quite tricky and you need some knowledge on
internals of the mpl.
Or, you may simply draw the figure twice (with same renderer),
On Sun, Dec 21, 2008 at 1:30 PM, Georg Brandl g.bra...@gmx.net wrote:
Hi,
I'm currently using Qwt to display a plot in a GUI application, but I'd like
to replace it with matplotlib and a shell window, so that the user can not
only view the plot but also modify it in-place using pyplot
It seems as a bug in the pdf backend, which can be fixed by the simple
patch below. I didn't commit this fix as I think it would be better if
original author (Jouni?) make sure this is a correct way. Neil, your
code will work okay if you don't use hatch. Or, you may apply the
patch by yourself.
On Sat, Dec 20, 2008 at 6:02 PM, Lebostein lebost...@gmx.de wrote:
A little thing: the shadow of the legend box is not scaling with the dpi.
For example with 300 dpi I can't discover the shadow...
This also should be fixed in the maintenance branch and the trunk.
Thanks for reporting.
-JJ
On Sat, Dec 20, 2008 at 8:52 AM, jouni k seppänen j...@iki.fi wrote:
Also the patch demo or some unit test
should cover that branch of the code,
ie the case when more than one patch
has the same hatch pattern.
I just check in the patch with a slight change in the hatch_demo.py
Regards,
-JJ
The legend class has been reimplemented recently and the name of some
keyword arguments (and their meaning) has been changed. Those
parameters you're using are deprecated ones. It is supposed to show
you some warnings if deprecated parameters are used, so what you see
is a bug. I'll take a look. I
did my own test
and it worked well for me, and I hope it does not cause any problem.
Regards,
-JJ
On Fri, Dec 19, 2008 at 9:44 AM, John Hunter jdh2...@gmail.com wrote:
On Fri, Dec 19, 2008 at 8:36 AM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
The legend class has been reimplemented recently
On Wed, Dec 17, 2008 at 1:19 PM, Ken Schutte kts.li...@gmail.com wrote:
It might be nice if eventually there were extra styles, e.g. -|, |-|
for single lines with solid arrowheads
This is now added in the trunk.
-JJ
I just found my previous message was only sent to Lebostein.
Anyhow, here is my original meesage.
On Tue, Dec 16, 2008 at 10:38 AM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
Yes, I can see the differences.
Anyway, it seems to me the differences are primarily caused by
different dpi
On Tue, Dec 16, 2008 at 12:17 PM, jkitchin jkitc...@andrew.cmu.edu wrote:
I also observed this with eps output. The png looked fine, but the eps legend
was very large in my case.
j
Hmm, it is not clear to me if this is a same issue. I think eps output
is not very sensitive to dpi thing in
On Tue, Dec 16, 2008 at 4:02 PM, Jouni K. Seppänen j...@iki.fi wrote:
Jae-Joon Lee lee.j.j...@gmail.com writes:
So, Lebostein and j, if you know how to check out using svn, can you
give a try either the svn trunk or the maintenance branch? I'm
attaching the patch just in case.
On the svn
. John, are you releasing a new maintenance version? I'm afraid that
my previous patch broke one of the example. Sorry, I thought the fix
was obvious and didn't pay much attention.
On Tue, Dec 16, 2008 at 5:18 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
On Tue, Dec 16, 2008 at 4:02 PM, Jouni K
Ken,
On Wed, Dec 17, 2008 at 1:14 AM, Ken Schutte kts.li...@gmail.com wrote:
This new FancyArrow stuff looks great, but I'm having trouble getting it to
work. All of the gallery examples I see seem to only use it thru an
'annotate' call. I just want to draw these arrows directly.
I tried
John,
I remember that - is also rendedered as a dot in the HTML output.
Using \- instead of - seems to work. But, I'm afraid that the help
(or similar) command, which I frequently use in interactive sessions,
may show \- instead of -.
So, quoting seems to be a best option to me.
Regards,
-JJ
On Mon, Dec 1, 2008 at 12:56 AM, Jesper Larsen [EMAIL PROTECTED] wrote:
Hi Matplotlib users,
I have a web application in which I would like to scale the plots down
if the users horizontal screen size is less than 800. Currently only
the plot is scaled while the fonts are fixed in size (see
What if I wanted one legend with both entries in it, rather than two
separate legends with a different entry in each? Is that possible? That's
more desirable than two separate legends.
Check
http://www.nabble.com/displaying-a-legend-from-a-different-subplot-td18447966.html#a18447966
The
get_frame() is deprecated (it is supposed to show you a DeprecationWarning).
Axes class now has a frame property, so gca().frame.set_linewidth(2)
should work.
Currently get_frame() returns Axes.patch which is used to draw a axes
background.
-JJ
On Tue, Nov 18, 2008 at 12:24 PM, Christopher
On Tue, Nov 18, 2008 at 9:20 AM, John Hunter [EMAIL PROTECTED] wrote:
There are two related problems here: one easier, one harder. We can
start with the easier one. The easy one is to have a detachable
axis. Right now we have one on the right and one on the left for the
x-axis. We may as
I think the savefig() command calls draw() internally, doesn't it?
So, I guess the restore_region() command comes before the draw() call,
i.e., it has no effect for the saved figure.
One way I can think of is to save the agg buffer without redrawing it.
It seems work.
---
I think the problem is caused by the image compositing logic in the
Axes.draw() method.
It currently makes a composite image first and then flip the resulting
image if necessary.
But I think what should happen is to flip the original images first
and then do the compositing.
So, test the attached
Hey Jae Joon -- thanks for looking into this. I don't have time to
test this patch, but I wanted to mention that there is an analogous
problem for figure image compositing -- see figimage_demo.py. agg
shows the correct behavior: the two images should be in the lower
left, and the blue
know if
there are cases this patch does not work.
-JJ
On Sat, Nov 8, 2008 at 7:28 PM, John Hunter [EMAIL PROTECTED] wrote:
On Sat, Nov 8, 2008 at 6:10 PM, Jae-Joon Lee [EMAIL PROTECTED] wrote:
My original patch does not work for this case, because the figimage is
drawn by Figure.draw
I spent some time working on it and came to the following conclusion:
if the mpl figure is fully transparent, you see whatever is in the gui
rendering buffer, which may be unintiialized memory. In some sense,
mpl is doing what is asked of it, making a fully transparent figure.
Clearing the
I can reproduce Thomas' problem with Agg backend. It does not happen
if frame_on is True.
And I guess Thomas' guess in the first email might be right.
I had a quick look at the mpl source and I don't think draw(), clf()
or savefig() try to clear the canvas.
The problem is not visible if frame_on
The current legend class does not support multiple columns.
Eric Wertman once mentioned in this list that he would work on this
feature, but I don't know the current status.
A (partial) rewrite of the legend class which I plan to support
multicolumns is in my TODO list but I haven't started it
Done, except that it just raises a warning, and still works with the old
kwarg. The new kwarg is borderpad; it is used if pad==0, which is the new
rc default. I set the default borderpad=0.5.
There is still too much other positioning in legend that is based on axes
units. I briefly tried
functions like raw_input blok the mianloop of some gui backends (e.g.,
gtk) but work fine with some other backend (although Tk is the only
backend I know of). So my guess is that you used a different backend
with 0.98.1.
I guess you have a few options.
* try different backend (Tk) with 0.98.3
*
I guess you need to put draw() after plot()
self.canvas.figure.clf()
self.canvas.axes.plot([1.,2.,4.])
self.canvas.draw()
Let us know if it does not help.
-JJ
On Sat, Oct 4, 2008 at 7:17 PM, rocha [EMAIL PROTECTED] wrote:
Hi Guys,
I need to clear the Figure after the user has clicked the
Hello,
I just had a quick look at this problem. And I'm posting a quick
solution in case Christoper haven't dig it yet.
Index: lib/matplotlib/legend.py
===
--- lib/matplotlib/legend.py(revision 6138)
+++
Hi,
As far as I know, the destination coordinate of trans* is a display
(canvas) coordinate, not the normalized figure coordinate. It has a
dimension of f.get_figwidth()*f.get_dpi(),
f.get_figheight()*f.get_dpi().
For example, transFigure transforms the normalized figure coordinate
to the
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
xy = 0.3, 0.3,
width, height = 0.2, 0.5
p = mpatches.Rectangle(xy, width, height, facecolor=orange, edgecolor=red)
plt.gca().add_patch(p)
plt.draw()
A Rectangle is a patch class and (although I'm not sure) I don't think
Adjusting a physical size of the axes is a bit tricky in matplotlib,
as the axes has an fixed position in normalized figure coordinate.
But, I guess setting the axes aspect ratio in physical size is doable
relatively easily, at least if your x,y axis are in linear scales. For
example, if you want
To change the window title, you may use
fig.canvas.set_window_title(My Title)
But I couldn't find any public method to obtain the current window title.
If you just want to have a title associated with a figure, I guess you
can simply define your title attribute. For example,
Hi,
It seems that there is no guarantee that the get_major_ticks() methods
returns only ticks within the view interval, i.e., it can return ticks
outside the data limit. As far as I see, this is related with the
general behavior of locator objects.
For example,
In [71]:
2. I have a skymap I would like to plot using a particular projection
- what I've been doing so far is specifying x and y coordinates using
mgrid and calling contourf(x,y,data,100) to approximate this. But
what I'd rather do is something like
imshow(data,extent=[-pi,pi,-pi/2,pi/2]) ... when
You can suppress the tick marks on the top and right axis as Mathieu
suggested. Setting frame_on as False will suppresse both the bounding
lines and the white background patch of the axes. You can suppress
only the bounding lines by
ax = gca()
ax.frame.set_visble(False)
Note that this will
at 14:38, Jae-Joon Lee [EMAIL PROTECTED] wrote:
You can suppress the tick marks on the top and right axis as Mathieu
suggested. Setting frame_on as False will suppresse both the bounding
lines and the white background patch of the axes. You can suppress
only the bounding lines by
ax = gca
Sure. you may include it if you want.
-JJ
On Sat, Aug 23, 2008 at 12:10 AM, Jason Grout
[EMAIL PROTECTED] wrote:
Jae-Joon Lee wrote:
Hi Jason,
I did made a similar class sometime ago and I'm attaching it just in
case. I guess it is very similar to yours but I rely
Hi Jason,
I did made a similar class sometime ago and I'm attaching it just in
case. I guess it is very similar to yours but I rely on
matplolib.patches.FancyArrow class to draw the arrow head.
The circle drawn by scatter() command should be a circle with size s
(the third argument of the
While I don't know much about how callbacks work in matplotlib,
looking at the source code of figure.draw() method, it seems that
call_back functions connected with the draw_event are called after a
figure is drawn. Therefore, you need a second draw. My guess is that
this second draw is somehow
Hi,
The legend of an axes instance is stored in axes.legend_ attribute.
And your second legend call will simply rebind this attribute to the
new legend object, and the first one is never drawn. You may make a
custom Axes class which can hold multiple legends. But if you want
something quick,
Hi,
As far as I know, xticklabels in matplotlib are top-aligned, so you
may see misaligned baseline sometimes. Still, the problem you reported
seems to be a bug in the pdf-backend. I posted a simple bug fix of the
pdf backend
http://article.gmane.org/gmane.comp.python.matplotlib.general/14041
Hi Mathieu,
It seems to me that you're confused with the meaning of the transAxes.
It is a transform from the Axes coordinate to the Canvas(?) coordinate.
As far as I can see, what you seemed to want is a transform between
Data coordinate and Axes coordinate, and that would be transScale +
A minor comment.
John's code may give incorrect results when exponents are negative.
int() truncates a floating point argument towards zero, e.g.,
int(-1.5) == -1 not -2. I guess calling floor() before int() will
work.
fx = int(np.floor(np.log(abs(val))/np.log(self._base) +0.5))
-JJ
On
If you're like me and what you want is just an arrow mark with its
head at (x,y), you may use scatter() with custom verts.
arrowup_verts = [[0.,0.], [-1., -1], [0.,0.], [0.,-2.],[0.,0.], [1, -1]]
arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.], [0.,2.],[0.,0.], [1, 1]]
Hi,
Try
mylines = plot1.get_lines()
plot2.legend(mylines, [p.get_label() for p in mylines])
When you call the legend method with two arguments, first argument is
a list of lines and second argument is a list of labels. It does not
seem to matter whether lines are from same axes.
Hope this
Hi,
I often do this with ds9 and funtools.
ds9 is an astronomy-oriented image viewer (http://hea-www.harvard.edu/RD/ds9/)
but you can also use it with numpy array.
Within ds9, you can define regions (ellipse, polynomial, etc) easily
with a mouse.
After you define a region (and save it as a file),
701 - 777 of 777 matches
Mail list logo