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



Showing 5 results of 5

From: Eric F. <ef...@ha...> - 2007年02月09日 19:01:59
Claas Teichmann wrote:
> Hi Eric,
> 
> Great that it works!! This is what I was looking for!
> 
> There is one thing left, which is that the tick labels are not exactly
> at the boundary between the colors. (It is no problem for me, but I am
> interested where it comes from). The script below shows that the
> colorswitch is not exactly at an "even" number. The values
> -0.022000001 and -0.022 are colored with the same color, whereas
> -0.02200001 has a different color. I don't know whether this is the
> reason for the ticks not beeing exactly at the intersection..?
When I run the script below I don't see what you are describing above; 
but I may not be looking in the right place, and it would not surprise 
me if there are little anomalies like this, because we are dealing with 
floating point arithmetic.
I do see (and had noticed before) that the colorbar ticks look a tiny 
bit high. I don't know whether this is a bug or whether it is a 
consequence of the fact that colors are assigned to ranges that include 
the lower limit but not the upper limit, and/or floating point 
arithmetic, and/or the resolution of the display. Or it may be because 
of some floating point fudge factors that I put into the colorbar code. 
 Maybe these could be improved.
Eric
From: Giorgio G. <gi...@gi...> - 2007年02月09日 18:26:16
Dear matplotlib users,
I am a new enthusiastic member of the matplotlib community.
I'll start up my frequentation in the ml with two questions for which I
couldn't find an answer; the first one is relatively tricky while the second
one should be quite straigthforward. Both are, I believe, of general
interest.
1) I use matplotlib and the wxmpl library to wrap the graphs in a notebook
page of a wxpython application. My canvas is a wxmpl.PlotPanel which is a
derivation of FigureCanvasWxAgg.Everything works just great, I love it.
Thing is that while most graphs have contained size, certain graphs can be
actually composed of several subplots and therefore I would like them to be
plotted on bigger canvas.
I can create a big canvas in a scrolledwindow with big virualsize and this
works just fine.
What I cannot do is to dinamically resize the canvas after it has been
create, ie. Create a smaller canvas and then increase its size only if
needed.
One more thing is that if I put the canvas in a sizer and then set the
scrolledwindow to fit the sizer than the canvas changes its dimension
accortding to the dimension of the frame (meaning if I maximize the whole
frame I seem to get a bigger canvas.
Here some graphic examples:
This is what I have now
Class MyNoteBookpage(wx.panel):
	def _init_ ...
		#In the notebook page self, create scrolledwindow
		self.virtualw = wx.ScrolledWindow(self)
		self.virtualw.SetVirtualSize((1000,1000))
		self.virtualw.SetScrollRate(20,20)
		
		#Create Canvas, child of the scrolledwindow
		self.canvas1 = MyCanvas(self.virtualw)
		#now arrange the sizer
		self.cs = wx.BoxSizer()
		self.cs.Add (self.canvas1, 1, wx.GROW|wx.ALL, 1)
		self.virtualw.SetSizer(self.cs) 
This code will result in this: http://zipp.it/u/Q687P 
Note that in the panel I also have a grid and a textbox and some buttons,
all arranged within a sizer.
If I resize the figure using 
	fig.set_size_inches((10,10)) I get this: http://zipp.it/u/Z466Y
2) Is it possible to include in my subplot a custom drawing?
I would like to have a half filled rectangle below the x axis, like the one
you see on panel b of the figure: http://zipp.it/u/L963V
Thanks a lot,
Giorgio
--
gi...@gi...
http://www.cafelamarck.it
From: Claas T. <cla...@gm...> - 2007年02月09日 13:11:03
Hi Eric,
Great that it works!! This is what I was looking for!
There is one thing left, which is that the tick labels are not exactly
at the boundary between the colors. (It is no problem for me, but I am
interested where it comes from). The script below shows that the
colorswitch is not exactly at an "even" number. The values
-0.022000001 and -0.022 are colored with the same color, whereas
-0.02200001 has a different color. I don't know whether this is the
reason for the ticks not beeing exactly at the intersection..?
I used the newest matplotlib version from the svn-repository.
I would use a script in the following way:
from pylab import *
from matplotlib import ticker
delta = 0.01
x = arange(-3.0, 3.0, delta)
y = arange(-3.0, 3.0, delta)
X,Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = Z2 - Z1 # difference of Gaussians
Z[20,20]=-0.022
Z[20,25]=-0.022000001
Z[20,30]=-0.02200001
Z[20,35]=-0.0220001
Z[20,40]=-0.022001
Z[20,45]=-0.02201
cmap = cm.get_cmap('jet', 10) # 10 discrete colors
#### Set vmin and vmax beforehand
im = imshow(Z, cmap=cmap, vmin=-0.15, vmax=0.17, interpolation='nearest')
colorbar(ticks=linspace(im.norm.vmin, im.norm.vmax, 11)) # 11 tick labels
Thanks!
Claas :-)
From: Krzysztof M. <ma...@pi...> - 2007年02月09日 11:29:19
Hello,
I have problem with generate charts with matplotlib under zope. I use 
the code based on 
http://www.scipy.org/Cookbook/Matplotlib/Matplotlib_and_Zope
Problem appears when the server is overloaded (even a little oveloaded) 
and generally after starting zope. The image charts sometimes don't draw 
completely, sometimes part of first chart draw on the second image.
Description:
Web client generates two http requests. The requests are served by 
external functions, functions use matplotlib. Results of functions are 
returning two image in png format. Images are sending to client who 
shows it in a web browser.
First case:
Return image sometimes isn't completely. Image have labels, axises but 
havent't chart.
Second case:
First return image isn't completely. The part which hasn't draw on the 
fisrt image is drawing on the second image.
This looks like something is not synchronized or doesn't correctly use 
resources. Why return external function image when the process isn't 
completely. Why can function draw on locally buffer allocated in another 
function?
How resolve the problem?
I searched event.log in zope and nothing had been saved.
Use:
Zope 2.9.5, python 2.4.3, matplotlib 0.87.7, numpy-1.0.1, Plone 2.5, 
Debian (i686, 2 processors).
Thanks,
Chris.
From: Nils W. <nw...@ia...> - 2007年02月09日 09:36:55
Attachments: image.png
John Hunter wrote:
> On 2/8/07, Nils Wagner <nw...@ia...> wrote:
>
>> Is there a way to add the coordinates in text form to each plus in the
>> attached figure ?
>> ERach plus in the plot is generated by
>> plot([data[-1].real],[data[-1].imag],'k+')
>>
>> For example the rightmost plus (in the upper right half plane) should
>> have a text (1.049+0.692j)
>> Can I use text for this purpose ?
>
> You can use text, but I suggest you use the brand-spanking-new
> annotate function, which is designed to annotate data points with
> text. It has support for arrows, and offsets from the annotated point
> in a variety of coordinate systems.
>
> Here is an example that shows annotations in a variety of contexts
>
> """
> Some examples of how to annotate points in figures. You specify an
> annotation point xy=(x,y) and a text point xytext=(x,y) for the
> annotated points and text location, respectively. Optionally, you can
> specify the coordinate system of xy and xytext with one of the
> following strings for xycoords and textcoords (default is 'data')
>
>
> 'figure points' : points from the lower left corner of the figure
> 'figure pixels' : pixels from the lower left corner of the figure
> 'figure fraction' : 0,0 is lower left of figure and 1,1 is upper, right
> 'axes points' : points from lower left corner of axes
> 'axes pixels' : pixels from lower left corner of axes
> 'axes fraction' : 0,1 is lower left of axes and 1,1 is upper right
> 'data' : use the axes data coordinate system
>
> Optionally, you can specify arrow properties which draws and arrow
> from the text to the annotated point by giving a dictionary of arrow
> properties
>
> Valid keys are
>
> width : the width of the arrow in points
> frac : the fraction of the arrow length occupied by the head
> headwidth : the width of the base of the arrow head in points
> shrink : move the tip and base some percent away from the
> annotated point and text
> any key for matplotlib.patches.polygon (eg facecolor)
>
> For physical coordinate systems (points or pixels) the origin is the
> (bottom, left) of the figure or axes. If the value is negative,
> however, the origin is from the (right, top) of the figure or axes,
> analogous to negative indexing of sequences.
> """
>
>
> from pylab import figure, show, nx
> from matplotlib.patches import Ellipse
>
> if 1:
> # if only one location is given, the text and xypoint being
> # annotated are assumed to be the same
> fig = figure()
> ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5),
> ylim=(-3,5))
>
> t = nx.arange(0.0, 5.0, 0.01)
> s = nx.cos(2*nx.pi*t)
> line, = ax.plot(t, s, lw=3, color='purple')
>
> ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction',
> horizontalalignment='center', verticalalignment='center')
>
> ax.annotate('pixels', xy=(20, 20), xycoords='figure pixels')
>
> ax.annotate('points', xy=(100, 300), xycoords='figure points')
>
> ax.annotate('local max', xy=(3, 1), xycoords='data',
> xytext=(0.8, 0.95), textcoords='axes fraction',
> arrowprops=dict(facecolor='black', shrink=0.05),
> horizontalalignment='right', verticalalignment='top',
> )
>
> ax.annotate('a fractional title', xy=(.025, .975),
> xycoords='figure fraction',
> horizontalalignment='left', verticalalignment='top',
> fontsize=20)
>
> # use negative points or pixels to specify from right, top -10, 10
> # is 10 points to the left of the right side of the axes and 10
> # points above the bottom
> ax.annotate('bottom right (points)', xy=(-10, 10),
> xycoords='axes points',
> horizontalalignment='right', verticalalignment='bottom',
> fontsize=20)
>
> fig.savefig('annotation_coords')
>
> if 1:
> # you can specify the xypoint and the xytext in different
> # positions and coordinate systems, and optionally turn on a
> # connecting line and mark the point with a marker. Annotations
> # work on polar axes too. In the example below, the xy point is
> # in native coordinates (xycoords defaults to 'data'). For a
> # polar axes, this is in (theta, radius) space. The text in this
> # example is placed in the fractional figure coordinate system.
> # Text keyword args like horizontal and vertical alignment are
> # respected
> fig = figure()
> ax = fig.add_subplot(111, polar=True)
> r = nx.arange(0,1,0.001)
> theta = 2*2*nx.pi*r
> line, = ax.plot(theta, r, color='#ee8d18', lw=3)
>
> ind = 800
> thisr, thistheta = r[ind], theta[ind]
> ax.plot([thistheta], [thisr], 'o')
> ax.annotate('a polar annotation',
> xy=(thistheta, thisr), # theta, radius
> xytext=(0.05, 0.05), # fraction, fraction
> textcoords='figure fraction',
> arrowprops=dict(facecolor='black', shrink=0.05),
> horizontalalignment='left',
> verticalalignment='bottom',
> )
> #fig.savefig('annotation_polar')
>
> if 1:
> # You can also use polar notation on a cartesian axes. Here the
> # native coordinate system ('data') is cartesian, so you need to
> # specify the xycoords and textcoords as 'polar' if you want to
> # use (theta, radius)
>
> el = Ellipse((0,0), 10, 20, facecolor='r', alpha=0.5)
>
> fig = figure()
> ax = fig.add_subplot(111, aspect='equal')
> ax.add_artist(el)
> el.set_clip_box(ax.bbox)
> ax.annotate('the top',
> xy=(nx.pi/2., 10.), # theta, radius
> xytext=(nx.pi/3, 20.), # theta, radius
> xycoords='polar',
> textcoords='polar',
> arrowprops=dict(facecolor='black', shrink=0.05),
> horizontalalignment='left',
> verticalalignment='bottom',
> )
>
> ax.set_xlim(-20, 20)
> ax.set_ylim(-20, 20)
> #fig.savefig('annotation_ellipse')
>
>
>
> fig.savefig('annotation_demo.png')
> show()
 
Hi John,
Thank you very much for your note !
How can I control the number of digits in the output (image.png) ?
I would like to have four digits for the real part and four digits for
the imaginary part.
And how can I suppress small numbers ?
 plot([data[-1].real],[data[-1].imag],'k+')
 
annotate(str(data[-1]),xy=(data[-1].real,data[-1].imag),xycoords='data')
Nils
1 message has been excluded from this view by a project administrator.

Showing 5 results of 5

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