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






Showing 6 results of 6

From: Boris B. <ba...@en...> - 2008年08月14日 23:02:49
Eric and John,
Thanks for the information. You are right that this probably would have been a 
premature optimisation, even if it weren't rendered useless by matplotlib 
using doubles internally (which I hadn't realised). The thought just occurred 
to me as I was writing the data-scaling part of my script.
The script is intended to be somewhat interactive. Initial tests suggest that 
plotting or updating several subplots from memory does take a quite 
noticeable time (e.g. 1.2 -- 1.5 seconds for 3 subplots of 10000 points) that 
will probably become annoying in routine use. As you indicated, basically all 
that time is spent within matplotlib. I'm just using standard default calls:
for i in subplot
 subplot	
 plot
 xlabel
 ylabel
 title
Each of these calls seems to take roughly the same time (60--100ms). If 
anybody has pointers on speeding things up significantly, I'm all ears. 
(Predefining data limits? Using lower-level commands? Use of a non-default 
backend?)
Boris
From: Tony S Yu <to...@MI...> - 2008年08月14日 22:26:25
On Aug 14, 2008, at 4:51 PM, Jae-Joon Lee wrote:
> 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 +
> transLimits (from Data to Axes).
>
> So, try
>
> trans = (ax.transScale + ax.transLimits).inverted()
> # trans = ax.transLimits.inverted() will also work in this case.
>
> and you will get 2.0, 2.0 as you expected.
>
> The "transform" argument should be transAxes still.
>
> ax.text(valx, valy, actualcoords, transform=ax.transAxes)
>
> As far as your original question is concerned, I have little idea what
> you are trying to do, so I'll leave that question to others.
>
> Regards,
>
> -JJ
>
>
> On Thu, Aug 14, 2008 at 3:43 PM, Mathieu Leplatre 
> <lep...@gm...> wrote:
>> I am still investigating and I am stuck at converting transAxes 
>> values to data.
>>
>> If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 
>> 15.0.
>>
>> This would allow me to compute bar width and space, since I am able 
>> to
>> convert inches to transAxes values.
>>
>> I tried many combinations of transAxes, transData, ...,
>> inverse_xy_tup, xy_tup, inverted(), transform(), ... without success
>> :(
>>
>> Any ideas please ?
Hi Mathieu,
I just wanted to add a little bit to Jae-Joon's example. I feel like I 
have to relearn the axes transformations every time I deal with them. 
Your email reminded me to write things down, and I thought I'd share 
it, in case others find it useful. Let me know if anything is wrong/ 
unclear.
Best,
-Tony
=============================
Axes Transformations Tutorial
=============================
The new transformations infrastructure is documented in the `new 
docs`_ (still
in progress...), which talks about transformations *in general*. This 
document
talks about transforms that are pre-defined attributes of `axes`. The 
following
explanation is partially stolen from a mailing list reply by Michael 
Droettboom.
In the following,
data space
 the actual `x, y` input data coordinates
axes space
 the axes coordinates which are `([0, 0], [1, 1])` at 
`([xmin,ymin], [xmax,
 ymax])`
figure space
 the screen pixel coordinates.
.. _new docs:
 http://matplotlib.sourceforge.net/doc/html/devel/ 
transformations.html
`matplotlib.axes` transforms
============================
`transScale`
 scales data to account for nonlinearities (non-affine) in the 
axis scales,
 e.g. log-log and semi-log scales. For example, 
`transScale.transform` would
 convert `x = [1, 10, 100, 1000]` to `[1, 2, 3, 4]` (powers of 
ten) if the
 x-axis is logarithmically spaced.
`transLimits`
 scales the data to the currently "zoomed" in portion of the data.
`transScale + transLimits`
 maps data space to axes space.
`transAxes`
 maps axes space to figure space.
`transData`
 maps data space to the figure space. `transData` is a composite of
 `transScale`, `transLimits`, and `transAxes`. It's the "fast 
lane" between
 the data and the screen.
Transforms example
==================
If you want to draw a dot in the middle of the plot, you know that
 >>> x = y = 0.5
in axes space.
Since the default transform for `matplotlib.pyplot.plot` is 
`transData`, you can
either either change the transform of the plot operation
 >>> import matplotlib.pyplot as plt
 >>> ax = plt.subplot(111)
 >>> ax.plot([x], [y], 'ro', transform=ax.transAxes)
Or you can transform the midpoint to data coordinates then plot them
 >>> trans_data2axes = ax.transScale + ax.transLimits
 >>> trans_axes2data = trans_data2axes.inverted()
 >>> mid_point = trans_axes2data.transform([x, y])
 >>> x_trans, y_trans = mid_point
 >>> ax.plot([x_trans], [y_trans], 'gs')
It's important to note that these are two **very different** 
approaches. The
first point (red dot) above is always referenced to axes space and 
will remain
in the center of the plot, even if you change the axes limits (try 
panning in
interactive mode).
On the other hand, the second point (green square) is referenced to 
the data
space and will move with the data if the axes limits are changed.
From: Ben A. <bax...@co...> - 2008年08月14日 21:54:41
I am trying to implement a dynamic graph in mpl, where users can drag around the nodes, and the edges follow the nodes like rubber bands. I have this working with regular edges, but I want to give the option of putting arrows on the edges. I am running into some issues with the Arrow classes.
With my Text, Rectangle, and Line2D objects I can get and set their locations with methods such as get_position(), get_x(), and get_xdata() respectively. But there are no such methods for any of the Arrow classes. (By the way, it seems like these sorts of things would be in the base classes, and much more standard).
What is the difference between Arrow, YAArrow, and FancyArrow anyway? (Besides drastically different scales).
Some other features of the Arrow class that I would like very much are:
* double headed arrows (one line with an arrow head on each end)
 * the ability to turn the arrow head on and off easily (Boolean parameter function)
Does anyone have any ideas on how to work around these issues?
Thanks,
-Ben
From: Jae-Joon L. <lee...@gm...> - 2008年08月14日 20:51:11
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 +
transLimits (from Data to Axes).
So, try
 trans = (ax.transScale + ax.transLimits).inverted()
 # trans = ax.transLimits.inverted() will also work in this case.
and you will get 2.0, 2.0 as you expected.
The "transform" argument should be transAxes still.
 ax.text(valx, valy, actualcoords, transform=ax.transAxes)
As far as your original question is concerned, I have little idea what
you are trying to do, so I'll leave that question to others.
Regards,
-JJ
On Thu, Aug 14, 2008 at 3:43 PM, Mathieu Leplatre <lep...@gm...> wrote:
> I am still investigating and I am stuck at converting transAxes values to data.
>
> If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 15.0.
>
> This would allow me to compute bar width and space, since I am able to
> convert inches to transAxes values.
>
> I tried many combinations of transAxes, transData, ...,
> inverse_xy_tup, xy_tup, inverted(), transform(), ... without success
> :(
>
> Any ideas please ?
>
> -----
> import pylab as P
> import matplotlib.transforms as T
>
> x = P.arange(5)
> y = P.rand(5) * 4
> ax = P.subplot(1,1,1)
> P.plot(x,y)
> ax.set_ylim(0.0, 4.0)
>
> trans = ax.transAxes
> valx = valy = 0.5
> actualcoords = "%s" % trans.transform([valx, valy])
> #Gives me [328, 240] instead of [2.0, 2.0]
>
> ax.text(valx, valy, actualcoords, transform=trans)
> P.show()
>
> -----
>
>
>
> On Wed, Aug 13, 2008 at 10:34 AM, Mathieu Leplatre <lep...@gm...> wrote:
>> Hi all,
>>
>> I've searched in examples and archives and could not find anything
>> about manual control of space between bars.
>>
>> By default, the bars in the following script overlap.
>>
>> So I guess the behaviour is :
>> specify chart width (8in) + bar width (0.8) => auto bar space
>>
>> And I would like to know how to do :
>> specify chart width + bar space => auto bar width
>> specify bar space + bar width => auto chart width (fixed margins)
>>
>> But I can't figure it out, especially the latter. Can
>> matplotlib.transforms help me about the former ?
>>
>> Do you have documentation reference or some hints about that please ?
>> Thanks!
>>
>> I am plotting a chronological bar chart like this one :
>>
>> #!/usr/bin/env python
>> import matplotlib, pylab, numpy
>> import datetime
>>
>> def rangedates( hourstep ):
>> dates = []
>> for d in range(1,31):
>> for h in range(0,24,hourstep):
>> dt = datetime.datetime(2008,06,d,h)
>> dates.append(dt)
>> return pylab.date2num(dates)
>>
>> # Plot value every 12H
>> abscissa = rangedates(12)
>>
>> barstep = abscissa[1] - abscissa[0]
>> barspace = 0.5 * barstep
>> barwidth = barstep - barspace
>>
>> fig = pylab.figure()
>> ax = fig.add_subplot(111)
>> fmt = matplotlib.dates.DateFormatter('%b %d')
>> ax.xaxis.set_major_formatter( fmt )
>> fig.autofmt_xdate()
>>
>> pylab.bar( abscissa, numpy.random.randn( len(abscissa) ),
>> width = barwidth)
>> pylab.show()
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Mathieu L. <lep...@gm...> - 2008年08月14日 19:43:07
I am still investigating and I am stuck at converting transAxes values to data.
If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 15.0.
This would allow me to compute bar width and space, since I am able to
convert inches to transAxes values.
I tried many combinations of transAxes, transData, ...,
inverse_xy_tup, xy_tup, inverted(), transform(), ... without success
:(
Any ideas please ?
-----
import pylab as P
import matplotlib.transforms as T
x = P.arange(5)
y = P.rand(5) * 4
ax = P.subplot(1,1,1)
P.plot(x,y)
ax.set_ylim(0.0, 4.0)
trans = ax.transAxes
valx = valy = 0.5
actualcoords = "%s" % trans.transform([valx, valy])
#Gives me [328, 240] instead of [2.0, 2.0]
ax.text(valx, valy, actualcoords, transform=trans)
P.show()
-----
On Wed, Aug 13, 2008 at 10:34 AM, Mathieu Leplatre <lep...@gm...> wrote:
> Hi all,
>
> I've searched in examples and archives and could not find anything
> about manual control of space between bars.
>
> By default, the bars in the following script overlap.
>
> So I guess the behaviour is :
> specify chart width (8in) + bar width (0.8) => auto bar space
>
> And I would like to know how to do :
> specify chart width + bar space => auto bar width
> specify bar space + bar width => auto chart width (fixed margins)
>
> But I can't figure it out, especially the latter. Can
> matplotlib.transforms help me about the former ?
>
> Do you have documentation reference or some hints about that please ?
> Thanks!
>
> I am plotting a chronological bar chart like this one :
>
> #!/usr/bin/env python
> import matplotlib, pylab, numpy
> import datetime
>
> def rangedates( hourstep ):
> dates = []
> for d in range(1,31):
> for h in range(0,24,hourstep):
> dt = datetime.datetime(2008,06,d,h)
> dates.append(dt)
> return pylab.date2num(dates)
>
> # Plot value every 12H
> abscissa = rangedates(12)
>
> barstep = abscissa[1] - abscissa[0]
> barspace = 0.5 * barstep
> barwidth = barstep - barspace
>
> fig = pylab.figure()
> ax = fig.add_subplot(111)
> fmt = matplotlib.dates.DateFormatter('%b %d')
> ax.xaxis.set_major_formatter( fmt )
> fig.autofmt_xdate()
>
> pylab.bar( abscissa, numpy.random.randn( len(abscissa) ),
> width = barwidth)
> pylab.show()
>
From: David M. K. <Dav...@ir...> - 2008年08月14日 09:28:28
Hi,
Sorry for the long delay - I have been on vacation. I don't use the
imcrop function, but it looks fairly easy to implement using ginput. I
am heading off for vacation again for another two weeks and I want to
get in some of the changes I proposed a long while ago before working on
this, so it might be a while, but if no one can take it on first, I can
give a look next month.
Cheers,
David
On Tue, 2008年08月05日 at 19:51 -0500, John Hunter wrote:
> On Tue, Aug 5, 2008 at 6:26 PM, Elfnor <el...@gm...> wrote:
> 
> > This would be really useful for implementing a user image crop function,
> > similar to matlab's imcrop for example.
> 
> David, since you are a recent matlab user and are deeply versed in the
> blocking code: how hard would it be to simply provide a (mostly)
> matlab compatible imcrop function, and is this something you are
> interested in doing?
> 
> JDH
-- 
**********************************
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France
Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**********************************

Showing 6 results of 6

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 によって変換されたページ (->オリジナル) /