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

Showing 6 results of 6

From: Gary R. <ga...@em...> - 2004年04月06日 23:44:17
Additional functionality for segplot could be; instead of providing maxdelta, be able to supply start and stop indices, or perhaps a list of start and stop indices. Another alternative would be to supply x and y ranges which specify to only join the dots when both points are within the range. It might also be worth thinking about factoring out the segment breaking code. Then you could do things like apply regression fit lines to individual segments etc.
Gary
----- Original Message -----
> Any suggestions for a name, or additional functionality?
> 
> JDH
-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
From: John H. <jdh...@ac...> - 2004年04月06日 19:57:33
>>>>> "Peter" == Peter Groszkowski <pgr...@ge...> writes:
 Peter> Hi everyone: I was wondering whether it is possible to tell
 Peter> matplotlib how/when to connect data points. Consider this
 Peter> simple script:
 Peter> from matplotlib.matlab import * figure(1) t =
 Peter> [0,1,2,3,4,5,105,106,107] s = [1,4,5,3,9,11,-5,-8,3]
 Peter> plot(t, s, antialiased=False) grid(True) show()
 Peter> There are no data points between t=5 and t=105. By default
 Peter> the points (5,11) and (105,-5) are connected, but I would
 Peter> like to tell matplotlib NOT to do so. In my case I would
 Peter> like to pass the plot function a variable telling it what
 Peter> to do. So for example would have:
 Peter> plot(t, s, max_delta=40)
 Peter> This would mean that the points are only to be connected if
 Peter> the difference between the adjacent t values is less than
 Peter> 40. In my case this is relevant because sometimes there
 Peter> are "holes" in my data, and connecting the points makes the
 Peter> plots look very messy.
 Peter> Would anyone find something like this useful? Would it be
 Peter> difficult to implement?
Certainly not difficult, and probably useful enough to put in the
standard distro. Eg, in a stock market trading example, you would
have lots of quotes, minute by minute, punctuated by long intervals
overnight where the market is closed. If you set maxdelta
appropriately, you could draw connected lines only within trading
days.
Here is a sample implementation
from matplotlib.matlab import *
def segplot(x, y, fmt, maxdelta, **kwargs):
 """
 Plot x versus y, breaking the plot at any point where x[i] -
 x[i-1] > maxdelta. kwargs are passed on to plot
 """
 x = asarray(x)
 y = asarray(y)
 d = diff(x)
 lines = []
 ind = nonzero(greater(d, maxdelta))
 ind = ind+1
 if not len(ind):
 lines.extend( plot(x,y,fmt,**kwargs) ) 
 else:
 allind = [0]
 allind.extend(ind)
 allind.append(len(x))
 for i1,i2 in zip(allind[:-1], allind[1:]):
 lines.extend( plot(x[i1:i2], y[i1:i2], fmt, **kwargs) )
 return lines
t = [0,1,2,3,4,5,105,106,107,187, 200, 212, 300, 320]
s = [1,4,5,3,9,11,-5,-8,3,12, 15, 12, -1, 3]
segplot(t, s, 'b-o', 40, antialiased=False)
grid(True)
show()
I'm inclined not to make this part of plot, since plot processes a
variable number of arguments it makes it a little difficult.
Certainly doable, but I'm hesitant to put too much on plot because it
might become unwieldy. But a new function, like segment plot, would
be easy enough to include.
Any suggestions for a name, or additional functionality?
JDH
From: John H. <jdh...@ac...> - 2004年04月06日 16:12:53
>>>>> "Dominique" == Dominique Orban <Dom...@po...> writes:
 Dominique> Many thanks for your reply and suggestions. I see what
 Dominique> is happening. Nearest neighbor interpolation has the
 Dominique> colors right, but i was trying to get "more
 Dominique> interpolation". I guess looking at the great pictures
 Dominique> that imshow() produces i was hoping for a result such
 Dominique> as that of
 Dominique> X = rand(10) pcolor( X ) shading 'interp'
As far as I recall, matlab's pcolor also loses an edge due to
interpolation. Perhaps the main difference is that in matlab, the
axes limits are set by default so that you don't see it. I remember
being surprised by this many moons ago the first time I used pcolor in
matlab.
 Dominique> in Matlab. The Matplotlib picture is just as good
 Dominique> really, except for the border. Why are the other
 Dominique> borders not white as well? Is the interpolation
 Dominique> "directional"? Why aren't pixels on the border only
 Dominique> interpolated with their neighbors inside the image, and
 Dominique> not those outside (these have less neighbors than
 Dominique> pixels in the middle)?
I'll have to think about this some more. 
There is also something funny about how the tick labeling currently
works for images, because the X[0,0] coord is upper left but is
labeled as 0,10. Perhaps ticks should be off be default, or labeled
with the y axis descending. Those who have opinions please weigh in.
BTW, the developer of agg, Maxim, is fairly responsive, so if you want
to pursue this issue after reading some of the code I point to below
on the agg mailing list
 http://lists.sourceforge.net/lists/listinfo/vector-agg-general
Maxim can probably provide some additional guidance.
 Dominique> Perhaps you can point me to the part of the code (c++ i
 Dominique> assume) which does the interpolation? Should i grab the
 Dominique> CVS repository for that? Then maybe i can play around
 Dominique> and see if i can achieve the effect i am looking for.
The code is available in the matplotlib src distribution. The module
is src/_image.cpp, which uses agg for image manipulation; see the
function Image_resize. All the agg code is also in the matplotlib src
distro, eg, agg2/include. agg2 doesn't have a lot of documentation -
hence I spend a lot of time reading src files, eg
 agg_conv_transform.h
 agg_span_image_filter_rgb24.h
 agg_span_image_filter_rgba32.h
 agg_span_interpolator_linear.h
The latest agg snapshot it http://www.antigrain.com/agg2.tar.gz which
has lots of examples in the examples dir. Agg can do a lot with
images, some of which would be nice to add to the matplotlib
interface....
JDH
From: Dominique O. <Dom...@po...> - 2004年04月06日 15:25:25
John Hunter wrote:
>>>>>>"Dominique" == Dominique Orban <Dom...@po...> writes:
> 
> 
> Dominique> When using imshow(), why does there always seem to be a
> Dominique> blank zone along the southern and eastern edges of the
> Dominique> figure? For instance:
> 
> Dominique> X = rand(10,10) imshow(X)
> 
> Dominique> plots a luminance image of X, which seems fine, except
> Dominique> for the lower and rightmost edges, which are blank. I
> Dominique> may be misunderstanding the purpose of imshow, but
> Dominique> skimming through the code didn't give me an answer. I
> Dominique> am using matplotlib 0.52 on WinXP with either GTKAgg or
> Dominique> TkAgg.
> 
> Hi Dominique,
> 
> Your example did point me to a small bug in the image module, but it
> is mostly unrelated to what you are observing. In the axes.py
> function imshow, replace
> 
> self.set_image_extent(0, numcols-1, 0, numrows-1) 
> with 
> self.set_image_extent(0, numcols, 0, numrows) 
> 
> 
> This only affects the tick labeling (not the actual image display)
> but it was wrong before and should be changed.
> 
> Now run this script
> 
> from matplotlib.matlab import *
> X = rand(10,10)
> 
> subplot(211)
> im = imshow(X)
> im.set_interpolation('nearest')
> 
> subplot(212)
> im = imshow(X)
> show()
> 
> The key thing is that the white border you are seeing arises from
> interpolation. The points on the bottom and right have no neighbors
> in those directions, and so they interpolate to the background color,
> which is white.
> 
> You can set the axis limits so that these regions don't appear, or use
> nearest neighbor interpolation.
> 
> Let me know if these suggestions don't work for you.
> 
> JDH
John,
Many thanks for your reply and suggestions. I see what is happening. 
Nearest neighbor interpolation has the colors right, but i was trying to 
get "more interpolation". I guess looking at the great pictures that 
imshow() produces i was hoping for a result such as that of
X = rand(10)
pcolor( X )
shading 'interp'
in Matlab. The Matplotlib picture is just as good really, except for the 
border. Why are the other borders not white as well? Is the 
interpolation "directional"? Why aren't pixels on the border only 
interpolated with their neighbors inside the image, and not those 
outside (these have less neighbors than pixels in the middle)?
Perhaps you can point me to the part of the code (c++ i assume) which 
does the interpolation? Should i grab the CVS repository for that? Then 
maybe i can play around and see if i can achieve the effect i am looking 
for.
Thanks again !
Dominique
From: John H. <jdh...@ac...> - 2004年04月06日 14:53:20
>>>>> "Dominique" == Dominique Orban <Dom...@po...> writes:
 Dominique> When using imshow(), why does there always seem to be a
 Dominique> blank zone along the southern and eastern edges of the
 Dominique> figure? For instance:
 Dominique> X = rand(10,10) imshow(X)
 Dominique> plots a luminance image of X, which seems fine, except
 Dominique> for the lower and rightmost edges, which are blank. I
 Dominique> may be misunderstanding the purpose of imshow, but
 Dominique> skimming through the code didn't give me an answer. I
 Dominique> am using matplotlib 0.52 on WinXP with either GTKAgg or
 Dominique> TkAgg.
Hi Dominique,
Your example did point me to a small bug in the image module, but it
is mostly unrelated to what you are observing. In the axes.py
function imshow, replace
 self.set_image_extent(0, numcols-1, 0, numrows-1) 
with 
 self.set_image_extent(0, numcols, 0, numrows) 
This only affects the tick labeling (not the actual image display)
but it was wrong before and should be changed.
Now run this script
 from matplotlib.matlab import *
 X = rand(10,10)
 subplot(211)
 im = imshow(X)
 im.set_interpolation('nearest')
 subplot(212)
 im = imshow(X)
 show()
The key thing is that the white border you are seeing arises from
interpolation. The points on the bottom and right have no neighbors
in those directions, and so they interpolate to the background color,
which is white.
You can set the axis limits so that these regions don't appear, or use
nearest neighbor interpolation.
Let me know if these suggestions don't work for you.
JDH
From: Flavio C. C. <fcc...@ci...> - 2004年04月06日 00:28:03
Attachments: equationbox.py
Hi john ,
I was doing a pure TeX plot (a bunch of equations inside a box) and I 
noticed that the \sqrt{}command does not work even though it listed in 
the help page for mathtext.
\frac and \dfrac would be a nice addition too...
feel free to used this little script as an example of another use of 
mathtext...
Flavio

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