SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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
(19)
2
(3)
3
(12)
4
(2)
5
6
(9)
7
(27)
8
(39)
9
(17)
10
(22)
11
(5)
12
(1)
13
(11)
14
(12)
15
(14)
16
(29)
17
(32)
18
(8)
19
(3)
20
(10)
21
(27)
22
(11)
23
(8)
24
(4)
25
(4)
26
(3)
27
(18)
28
(7)
29
(29)
30
(13)
31
(4)

Showing 3 results of 3

From: Andrew S. <str...@as...> - 2006年03月19日 19:48:44
Jouni K Seppanen wrote:
>It looks like the sys.platform check is trying to guard against this
>condition, but plain Mac Python without py2app does not have
>sys.frozen. I suppose it would be better to check whether sys.frozen
>exists and then its truth value. Would the following change work for
>everyone?
> 
>
Hi Jouni,
I applied your patch in SVN revision 2166. Thanks for the pointer.
Cheers!
Andrew
From: Jouni K S. <jk...@ik...> - 2006年03月19日 18:57:27
"Charlie Moad" <cw...@gm...> writes:
> On 2/19/06, Josh Marshall <jos...@gm...> wrote:
>> Change the line to either:
>> if (sys.platform=='win32' or sys.platform=='darwin') and sys.frozen:
>
> Done.
This is causing problems on OS X, since (on at least Python 2.4.1 on
Tiger from http://undefined.org/python/) sys.platform is 'darwin' but
sys.frozen does not exist:
>>> sys.platform
'darwin'
>>> sys.frozen
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'frozen'
It looks like the sys.platform check is trying to guard against this
condition, but plain Mac Python without py2app does not have
sys.frozen. I suppose it would be better to check whether sys.frozen
exists and then its truth value. Would the following change work for
everyone?
Index: lib/matplotlib/__init__.py
===================================================================
--- lib/matplotlib/__init__.py (revision 2151)
+++ lib/matplotlib/__init__.py (working copy)
@@ -349,7 +349,7 @@
 if os.path.isdir(path): return path
 
 # py2exe zips pure python, so still need special check
- if (sys.platform=='win32' or sys.platform=='darwin') and sys.frozen:
+ if getattr(sys, 'frozen', None):
 path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
 if os.path.isdir(path): return path
 else:
See also: http://pythonmac.org/wiki/FAQ#head-fda52eabc4c64a21d7044d62a49319a7c85faca9
The reason I ran into this was that I installed the svn version with
"setupegg.py develop"1, and there is no mpl-data directory in
lib/matplotlib. I made a symlink to an existing mpl-data directory,
but I wonder if there is some more elegant way for matplotlib to
support setuptools' develop mode?
1 http://mail.python.org/pipermail/distutils-sig/2005-July/004692.html
-- 
Jouni
From: Ted D. <ted...@jp...> - 2006年03月19日 18:46:44
John,
It might be nice if we could add a "what if" type function to all the 
backends for text sizing. That way we could write much better auto-layout 
algorithms for the axis and legend code. A very simple improvement to the 
auto-date labeller would then work like this:
- Find min, max values of the time axis
- Convert to the label format using the date formatter
- Ask the backend what the size of the min/max labels would be
- Take the max of that as a reasonable guess for the date label size
- Divide up the total interval (in pixels) by the label size + pad
- Pick nice ticks based on the total time interval and number of ticks you 
can fit
This would be really handy for us in that we do a lot of date plotting with 
widely varying time ranges and it would be nice to have an "auto-ticker" 
that insures the labels don't overlap for a plot of a given size and range.
On a scale of 1-10, how difficult do you think this type of thing would be 
to do?
Ted
At 07:52 PM 3/17/2006, John Hunter wrote:
> >>>>> "Michael" == Michael P Mossey <mo...@jp...> writes:
>
> Michael> Is there a way to find out in terms of pixels, points, or
> Michael> fraction of figure, how large a text string is? In other
> Michael> words if I generate "Some label" as the x-axis label, can
> Michael> I find out how tall and wide it is?
>
>It can be done -- it's not terribly elegant. The basic problem is
>that text size depends on the backend and configuration settings.
>Since we have arbitrary fonts, multiline text with arbitrary rotation,
>possible using TeX to render, with multiple output targets that might
>handle text differently, you can see how this seemingly simple
>question is actually tough.
>
>All text instances have a method called "get_window_extent" which
>returns a matplotlib.transforms.BBox that bounds the text instance.
>This bbox is in pixel coords.
>
> bbox = sometext.get_window_extent()
> l,b,w,h = bbox.get_bounds() # left, bottom, width, height
>
>
>Here's the rub: we can't realistically know the text size until we
>have a renderer, because the same text may be different in different
>renderers. matplotlib sets the figure renderer at draw time, and so
>by default we don't know the text size until draw size. This is
>sometimes cumbersome.
>
>One solution is to do something like
>
> plot(something)
> sometext = text(x,y,s)
> draw() # force a draw to set the renderer
> l,b,w,h = sometext.get_window_extent().get_bounds()
> ..adjust the postion of some objects based on this info
> ...draw again
>
>not terribly elegant because we must redraw. If you did not first
>force the draw command before calling get_window_extent, you would get
>an exception about needing to first set the renderer.
>
>Another approach if you want to avoid the duplicate drawing is to
>create a proxy renderer and pass that off to the text instance.
>
> l,b,w,h = fig.bbox.get_bounds()
> renderer = RendererAgg(w, h, fig.dpi)
> l,b,w,h = sometext.get_window_extent(renderer).get_bounds()
>
>This is not ideal either because you have a duplicate renderer.
>
>If you are using a *Agg backend and have a figure instance, you can do
>the following, which requires no duplicate drawing and no duplicate
>renderer (the get_renderer method below caches the return value so
>repeated calls do not create duplicate renderers)
>
>Here is a complete example
>
> from matplotlib.patches import Rectangle
> from matplotlib.transforms import identity_transform
> from pylab import figure, show
>
> fig = figure()
> ax = fig.add_subplot(111)
> ax.plot([1,2,3,4], [1,2,3,4])
> t = ax.text(2,2,'Look Ma!\nNo hands', fontsize=40, rotation=-45)
> renderer = fig.canvas.get_renderer()
> bbox = t.get_window_extent(renderer)
> l,b,w,h = bbox.get_bounds()
>
> # no transformation necessary, already in pixel coords
> r = Rectangle((l,b),w,h, transform=identity_transform())
> ax.add_patch(r)
> show()
>
>If we made the get_renderer method standard across backends, we could
>probably hide the get_renderer call from the user and make this a
>little more friendly, but the above should suffice. Note if you have
>some data in pixel coords, you can transform it into another
>coordinate system (eg data coords) using the inverse transform
>methods. The l,b,w,h bounding box of the text bbox in "data"
>coordinates (ie, the coords of the [1,2,3,4] plot) can be obtained
>with
>
> from matplotlib.transforms import inverse_transform_bbox
> databbox = inverse_transform_bbox(ax.transData, bbox)
> print databbox.get_bounds()
>
>In general, different coordinate systems in matplotlib communicate
>with one another by transforming a data point to pixel space and then
>inverse transforming that point into a different own space. There are
>two inverse methods to help with these tasks. The first is a
>transform method to handle single points:
>
> # apply the inverse transformation to tuple xy
> xi, yi = trans.inverse_xy_tup(xy)
>
>and the second is a stand-alone function defined in
>matplotlib.transforms to handle bboxes
>
> # apply the inverse transformation of a bbox
> bboxi = inverse_transform_bbox(trans, bbox)
>
>
>You might be thinking: why aren't we simply using an affine
>transformation matrix with a standard matrix inverse? All I can offer
>in response is that this architecture supports nonlinear
>transformations, ie, an affine plus a nonlinear transformation, for
>polar, log, etc.... There is probably a better way, but this is what
>we've got.
>
>JDH
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by xPML, a groundbreaking scripting language
>that extends applications into web and mobile media. Attend the live webcast
>and join the prime developer group breaking into this new coding territory!
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>_______________________________________________
>Matplotlib-users mailing list
>Mat...@li...
>https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Showing 3 results of 3

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /