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

Showing 7 results of 7

From: Josh H. <jh...@vn...> - 2009年07月31日 22:42:21
Fernando Perez wrote:
> 
> Please! That example with the top labels looks great, and it's a very
> useful way of displaying the numerical key parts of the dataset.
> 
> Cheers,
> 
> f
> 
OK, here is a bloxplot example based on the one previously shown. I just
replaced my environmental data with some random data to make things easier
to run, and accordingly I had to make up some story around the data (testing
bootstrap resampling). Fee free to rework the code as you see fit, but
hopefully this is a helpful example.
http://www.nabble.com/file/p24764036/boxplotExampleForums.png 
--------------------------
boxplotdemo.py
--------------------------
import numpy as np
import matplotlib.pyplot as plt 
from matplotlib.patches import Polygon
#Generate some data from five different probability distributions, each with
#different characteristics. We want to play with how an IID bootstrap
resample
#of the data preserves the distributional properties of the original sample,
and
#a boxplot is one visual tool to make this assessment 
numDists = 5
randomDists = ['Normal(1,1)',' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)', 
 'Triangular(2,9,11)']
N = 500
norm = np.random.normal(1,1, N)
logn = np.random.lognormal(1,1, N)
expo = np.random.exponential(1, N)
gumb = np.random.gumbel(6, 4, N)
tria = np.random.triangular(2, 9, 11, N)
#Generate some random indices that we'll use to resample the original data 
#arrays. For code brevity, just use the same random indices for each array
bootstrapIndices = np.random.random_integers(0, N-1, N)
normBoot = norm[bootstrapIndices]
expoBoot = expo[bootstrapIndices]
gumbBoot = gumb[bootstrapIndices]
lognBoot = logn[bootstrapIndices]
triaBoot = tria[bootstrapIndices]
data = [norm, normBoot, logn, lognBoot, expo, expoBoot, gumb, gumbBoot,
 tria, triaBoot]
fig = plt.figure(figsize=(10,6))
fig.canvas.set_window_title('A Boxplot Example') 
ax1 = fig.add_subplot(111)
plt.subplots_adjust(left=0.075, right=0.95, top=0.9, bottom=0.25) 
bp = plt.boxplot(data, notch=0, sym='+', vert=1, whis=1.5)
plt.setp(bp['boxes'], color='black')
plt.setp(bp['whiskers'], color='black')
plt.setp(bp['fliers'], color='red', marker='+')
#Add a horizontal grid to the plot, but make it very light in color so we
can 
#use it for reading data values but not be distracting
ax1.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', 
 alpha=0.5)
#Hide these grid behind plot objects
ax1.set_axisbelow(True) 
ax1.set_title('Comparison of IID Bootstrap Resampling Across Five
Distributions')
ax1.set_xlabel('Distribution') 
ax1.set_ylabel('Value')
#Now fill the boxes with desired colors
boxColors = ['darkkhaki','royalblue']
numBoxes = numDists*2
medians = range(numBoxes)
for i in range(numBoxes):
 box = bp['boxes'][i]
 boxX = []
 boxY = []
 for j in range(5):
 boxX.append(box.get_xdata()[j])
 boxY.append(box.get_ydata()[j])
 boxCoords = zip(boxX,boxY)
 #Alternate between Dark Khaki and Royal Blue
 k = i % 2
 boxPolygon = Polygon(boxCoords, facecolor=boxColors[k])
 ax1.add_patch(boxPolygon)
 #Now draw the median lines back over what we just filled in
 med = bp['medians'][i]
 medianX = []
 medianY = []
 for j in range(2):
 medianX.append(med.get_xdata()[j])
 medianY.append(med.get_ydata()[j])
 plt.plot(medianX, medianY, 'k')
 medians[i] = medianY[0]
 #Finally, overplot the sample averages, with horixzontal alignment in the 
 #center of each box
 plt.plot([np.average(med.get_xdata().data)], [np.average(data[i])], 
 color='w', marker='*', markeredgecolor='k')
#Set the axes ranges and axes labels
ax1.set_xlim(0.5, numBoxes+0.5) 
top = 40
bottom = -5
ax1.set_ylim(bottom, top) 
xtickNames = plt.setp(ax1, xticklabels=np.repeat(randomDists, 2))
plt.setp(xtickNames, rotation=45, fontsize=8)
#Due to the Y-axis scale being different across samples, it can be hard to 
#compare differences in medians across the samples. Add upper X-axis tick
labels
#with the sample medians to aid in comparison (just use two decimal places
of
#precision)
pos = np.arange(numBoxes)+1
upperLabels = [str(np.round(s, 2)) for s in medians]
weights = ['bold', 'semibold']
for tick,label in zip(range(numBoxes),ax1.get_xticklabels()):
 k = tick % 2
 ax1.text(pos[tick], top-(top*0.05), upperLabels[tick], 
 horizontalalignment='center', size='x-small', weight=weights[k],
 color=boxColors[k])
#Finally, add a basic legend 
plt.figtext(0.80, 0.08, str(N) + ' Random Numbers' , 
 backgroundcolor=boxColors[0], color='black', weight='roman', 
 size='x-small')
plt.figtext(0.80, 0.045, 'IID Bootstrap Resample',
backgroundcolor=boxColors[1],
 color='white', weight='roman', size='x-small')
plt.figtext(0.80, 0.015, '*', color='white', backgroundcolor='silver', 
 weight='roman', size='medium') 
plt.figtext(0.815, 0.013, ' Average Value', color='black', weight='roman', 
 size='x-small')
plt.show()
-----
Josh Hemann
Statistical Advisor 
http://www.vni.com/ Visual Numerics 
jh...@vn... | P 720.407.4214 | F 720.407.4199 
-- 
View this message in context: http://www.nabble.com/Radar---Spider-Chars-tp17876254p24764036.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Lukas H. <Lu...@gm...> - 2009年07月31日 20:07:19
Hello,
I have y values in the range of -100 to 100.
I want that the negative values are shown as positive (the minus gets removed 
from the output).
I tried a for loop over all self.ax.get_yticklabels() and call 
label.set_text("...") on each item but it didn't work - nothing got changed.
If I print the label in the loop they seem to be empty:
Text(0,0,'') 
Text(0,0,'') 
Text(0,0,'') 
......
Is there anything I do wrong?
Thanks,
Lukas
From: Bas v. L. <le...@gm...> - 2009年07月31日 19:45:11
Hello,
I tried to implement a solution for this issue. Basically I want to
give the x and y position in datacoords and the width + height in
pixels.
However, when using the following code:
 im = Image.open("../Icons/Program Icon.png")
 limx = self.mainAxes.get_xlim()
 limy = self.mainAxes.get_ylim()
 [x0, y0], [x1, y1] = self.mainAxes.bbox.get_points()
 datawidth = limx[1] - limx[0]
 dataheight = limy[1] - limy[0]
 pixelwidth = x1 - x0
 pixelheight = y1 - y0
 adaptedwidth = im.size[0] * (datawidth/pixelwidth)
 adaptedheight = im.size[1] * (dataheight/pixelheight)
 for peak in Blocks.peaks(self.quote.Close,
self.peakSpanSlider.value()):
 self.mainAxes.imshow(im, origin = 'lower', extent =
(date2num(peak.datetime), date2num(peak.datetime) + 100 , 400, 425)) #
left right bottom top
 self.mainAxes.set_xlim(limx)
 self.mainAxes.set_ylim(limy)
There is no visible result. When zooming in to a place where an image
should be present I encounter the following error every time I move
the mouse.
Traceback (most recent call last):
 File "C:\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py",
line 135, in mouseReleaseEvent
 FigureCanvasBase.button_release_event( self, x, y, button )
 File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py",
line 1198, in button_release_event
 self.callbacks.process(s, event)
 File "C:\Python25\lib\site-packages\matplotlib\cbook.py", line 155, in process
 func(*args, **kwargs)
 File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py",
line 2048, in release_zoom
 self.draw()
 File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py",
line 2070, in draw
 self.canvas.draw()
 File "C:\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py",
line 133, in draw
 FigureCanvasAgg.draw(self)
 File "C:\Python25\lib\site-packages\matplotlib\backends\backend_agg.py",
line 279, in draw
 self.figure.draw(self.renderer)
 File "C:\Python25\lib\site-packages\matplotlib\figure.py", line 772, in draw
 for a in self.axes: a.draw(renderer)
 File "C:\Python25\lib\site-packages\matplotlib\axes.py", line 1545, in draw
 im.draw(renderer)
 File "C:\Python25\lib\site-packages\matplotlib\image.py", line 233, in draw
 im = self.make_image(renderer.get_image_magnification())
 File "C:\Python25\lib\site-packages\matplotlib\image.py", line 220,
in make_image
 rx = widthDisplay / numcols
ZeroDivisionError: float division
Any idea what might cause this issue? Did I do something wrong? I know
it's not pretty, but it should work right?
Cheers!
Bas
2009年7月30日 Bas van Leeuwen <le...@gm...>:
> Hi JJ,
>
> Thank you for your kind and speedy reply, I completely glanced over
> the extent parameter.
> Datacoords are actually what I need so this is perfect for me.
>
> To clarify what I want, I want to mark certain parts of a graph with
> an icon representing the reason it's interesting. Icons are for peaks,
> trends, correlation, etc.
>
> Thank you very much!
>
> Bas
>
>
> 2009年7月30日 Jae-Joon Lee <lee...@gm...>:
>> The location of the image can be set by specifying the "extent"
>> keyword, however, this is set in data coordinate.
>> figimage may be close to what you want.
>>
>> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.figimage
>>
>> As far as I know, there is no direct support in matplotlib to place an
>> image with arbitrary transformation. But it may not be difficult to
>> implement. However, "annotate a plot with icons" is not enough to
>> figure out what you really want.
>> Maybe some screenshots from other plotting tool will be helpful. Or,
>> please elaborate how you want to position your image.
>>
>> -JJ
>>
>>
>> On Thu, Jul 30, 2009 at 12:11 PM, Bas van Leeuwen<le...@gm...> wrote:
>>> Hi all,
>>>
>>> Is there any way to annotate a plot with icons?
>>> The only way to include an image that I've found is using imshow, but
>>> imshow does not accept (x,y) coordinates.
>>>
>>> There probably is an easy solution, but I have not been able to find
>>> any. Please be patient :-)
>>>
>>> Thank you in advance for your reply,
>>> Bas van Leeuwen
>>>
>>> PS, I'm sorry if this mail arrives multiple times, I didn't see the
>>> previous one in the archive.
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>>> trial. Simplify your report design, integration and deployment - and focus on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>
From: John H. <jd...@gm...> - 2009年07月31日 17:45:00
We have a test release candidate rc1 of the impending
matplotlib-0.99.0 release, including lots of great new stuff like the
axes grid and mplot3d toolkits,
 http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/index.html
 http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html
We have uploaded tarballs, eggs and binary installers for win32 and
OSX, and would love to have some testers. You can grab the release
candidates from:
 http://drop.io/xortel1#
If you have any bugfixes or patches, feel free to post them here, but
please also post to the tracker
 https://sourceforge.net/tracker/?group_id=80706&atid=560720
Thanks to Michael Droettboom with help setting up the release branch,
Christoph Gohlke for the python2.6 win32 binaries, and William Stein
for providing a remote OSX box for building and testing OSX binaries.
Those of you with svn access can grab the release branch from::
 svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint
mpl99
and post patches against svn for any bugs you discover and fix::
 http://matplotlib.sourceforge.net/faq/howto_faq.html#submit-a-patch
Thanks to all the developers who contributed in this cycle -- more
details to follow on the official release announcement next week.
JDH
From: Tony S Yu <to...@MI...> - 2009年07月31日 14:56:24
On Jul 30, 2009, at 5:16 PM, Gewton Jhames wrote:
> Anyone?
>
> On Tue, Jul 28, 2009 at 3:23 PM, Gewton Jhames <gj...@gm...> 
> wrote:
> Guys, there is the code.
> On Tue, Jul 28, 2009 at 3:13 PM, Gewton Jhames <gj...@gm...> 
> wrote:
> Jae-Joon Lee, savefig("file.png", bbox_inches="tight") doesn't work 
> too.
>
>
> On Mon, Jul 27, 2009 at 7:00 PM, Jae-Joon Lee <lee...@gm...> 
> wrote:
[Snip]
> On Mon, Jul 27, 2009 at 4:06 PM, Gewton Jhames<gj...@gm...> 
> wrote:
> On the other hand, there is some crude support for trimming, i.e.,
> reducing the figure size while the axes area fixed.
>
> savefig("file.png", bbox_inches="tight")
>
> Note that the figure size of the saved output is only affected. This
> does not change the figure displayed on the screen.
>
> Regards,
>
> -JJ
>
Jae-Joon's suggestion worked for me (using your code). Since this 
feature is pretty new, it may depend on the version you're using (I'm 
using the latest from svn).
I couldn't get `autoscale_view` to work either. However, 
`subplots_adjust` should work with a little tweaking. Instead of the 
dimensions John gave, try plt.subplots_adjust(left=0.07, right=0.99). 
These dimensions may show up differently on your system, so try 
tweaking these values.
Best,
-T
From: Michael D. <md...@st...> - 2009年07月31日 14:10:00
That is by design -- it's a performance vs. accuracy tradeoff. Markers 
are drawn only once and then stamped to the nearest pixel boundaries. 
What you're seeing is the result of this rounding. And since each 
marker is rounded in isolation, you don't see smooth stepping as a 
classical line drawing algorithm (such as Breshenham's) would give. We 
could make this behavior optional, but it would require a significantly 
different code path in the Agg backend. The Agg backend is generally 
optimized for interactive performance, not accuracy. For accuracy, one 
can use any of the vector output formats.
Cheers,
Mike
João Luís Silva wrote:
> The positioning of markers seems a bit off, especially when a line is 
> moved around with the pan and zoom tool. They don't follow the line they 
> are in, and seem to follow a much lower resolution line. Try the 
> following example, and use the pan and zoom tool to move the lines around.
>
> mpl svn rev 7310 / Ubuntu 9.04 / GTKAgg
>
> Regards,
> João Silva
>
> ---------------------------------------------------------------------
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> delta = 0.2
> x = np.arange(-5,5,0.05)
> plt.plot(x,x,marker="o")
> plt.plot(x,x+delta,"g",lw=1.5)
> plt.plot(x,x-delta,"g",lw=1.5)
> ax = plt.gca()
> ax.set_xlim((-4.25,4.7))
> ax.set_ylim((-5.5,5.1))
> plt.show()
>
> ---------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: João L. S. <js...@fc...> - 2009年07月31日 01:05:22
The positioning of markers seems a bit off, especially when a line is 
moved around with the pan and zoom tool. They don't follow the line they 
are in, and seem to follow a much lower resolution line. Try the 
following example, and use the pan and zoom tool to move the lines around.
mpl svn rev 7310 / Ubuntu 9.04 / GTKAgg
Regards,
João Silva
---------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
delta = 0.2
x = np.arange(-5,5,0.05)
plt.plot(x,x,marker="o")
plt.plot(x,x+delta,"g",lw=1.5)
plt.plot(x,x-delta,"g",lw=1.5)
ax = plt.gca()
ax.set_xlim((-4.25,4.7))
ax.set_ylim((-5.5,5.1))
plt.show()
---------------------------------------------------------------------

Showing 7 results of 7

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