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




Showing 7 results of 7

From: Tony S Yu <to...@MI...> - 2009年06月18日 23:24:57
I'd like to plot a collection and scale the size of the collection 
elements in relation to the data. My guess is that I need to use the 
data transformation (ax.transData) since I would like the size of the 
collection elements altered when zooming in/out.
Unfortunately, my attempt has led to weird results: the collection 
offsets are shifted from the desired coordinates when using 
ax.transData. Weirder still: the collection elements move *relative to 
the data coordinates* when panning the figure.
I suspect that setting the collection transform to ax.transData is 
somehow applying some part of the transform twice. Does anyone know 
what I'm doing wrong here and how I can fix this?
Thanks!
-Tony
Attached is a toy example of what I'm trying to do. The radii of the 
circles are plotted correctly, but notice the x, y coordinates don't 
match the circle centers in the plot. Also, try panning the plot and 
watch as the circles move relative to the tick marks.
 >>> import matplotlib.pyplot as plt
 >>> import matplotlib.transforms as transforms
 >>> import numpy as np
 >>> fig = plt.figure()
 >>> ax = fig.add_subplot(111)
 >>> x = [0.25, 0.75, 0.25, 0.75]
 >>> y = [0.25, 0.25, 0.75, 0.75]
 >>> r = 0.1 * np.ones(4)
 >>> col = plt.scatter(x, y, np.pi*r**2)
 >>> pts2pixels = transforms.Affine2D().scale(72.0/fig.dpi)
 >>> col.set_transform(pts2pixels + ax.transData)
 >>> plt.axis('equal')
 >>> plt.show()
From: Dave C. <dac...@go...> - 2009年06月18日 18:18:42
Hi All
Just wondering if anybody could give me some pointers on the problem I have
described below ?
For those that getting redirected to the freehostia main page for what ever
reason, please try this link.
http://waka.freehostia.com/python/
Thanks
 Hi
>
> I am developing on a Desktop install Ubuntu 9.04 machine with matplotlib
> 0.98.5.2,
> and running the scripts on a Server install Ubuntu 8.10 machine with
> matplotlib 0.98.3.
>
> I have found that the X axis layout for the same script varies between the
> two machines.
> Both have standard matplotlib installs using apt-get. I haven't made any
> tweaks.
>
> Rather than go into great detail about the problem, please see the script
> below and links to the resulting png files.
> I hope the png files tell the story.
>
> http://waka.freehostia.com/python/date_axis_scaling_test.py
> http://waka.freehostia.com/python/date_axis_scaling_test_0_98_3.png
> http://waka.freehostia.com/python/date_axis_scaling_test_0_98_5_2.png
>
> The plot produced by matplotlib 0.98.3 isn't what I want.
> Id like the plot to go edge to edge on the x axis grid, as the matplotlib
> 0.98.5.2 version does.
>
> Help and advise would be appreciated.
> PS : I'm new to python & matplotlib
>
>
> ######################################################################################
> #!/usr/bin/env python
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
> from datetime import datetime, timedelta
>
> version = matplotlib.__version__
> HOURSBACK = 365 * 24
> now = datetime.now()
> valueList = []
> dateList = []
>
> for i in range(HOURSBACK):
> hoursBack = timedelta( hours = (HOURSBACK - i) )
> then = now - hoursBack
> valueList.append( i )
> dateList.append( then )
>
> fig = plt.figure( figsize=(12, 9), dpi=100 )
> ax = fig.add_subplot(111)
> ax.plot(dateList, valueList)
> plt.title('Date axis scaling test for matplotlib version : %s' % ( version
> ) )
> plt.grid(True)
> plt.ylabel('Widgets')
> plt.xlabel('Date')
> fig.autofmt_xdate()
>
> plt.savefig( "date_axis_scaling_test_%s.png" % version.replace('.','_'),
> format='png' )
>
> quit()
>
> ######################################################################################
>
>
>
Hi All,
Too many people in the Python community *still* think the only way to 
work with Excel files in Python is using COM on Windows.
To try and correct this, I'm giving a tutorial at this year's EuroPython 
conference in Birmingham, UK on Monday, 29th June that will cover 
working with Excel files in Python using the pure-python libraries xlrd, 
xlwt and xlutils.
I'll be looking to cover:
- Reading Excel Files
 Including extracting all the data types, formatting and working with
 large files.
- Writing Excel Files
 Including formatting, many of the useful frilly extras and writing
 large excel files.
- Modifying and Filtering Excel Files
 A run through of taking existing Excel files and modifying them in
 various ways.
- Workshop for your problems
 I'm hoping anyone who attends will get a lot out of this! If you're
 planning on attending and have a particular problem you'd like to work
 on in this part of the tutorial, please drop me an email and I'll try
 and make sure I come prepared!
All you need for the tutorial is a working knowledge of Excel and
Python, with a laptop as an added benefit, and to be at EuroPython this 
year:
http://www.europython.eu/
I look forward to seeing you all there!
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Elan P. <ep...@gm...> - 2009年06月18日 15:59:10
Hi John,
I solved the bug. In my application I have several threads. One of the
threads updates the graph on a timer and another gets data from the
application in order to plot.
The thread updating the limits was based on data coming from the
application. As I stated this is a two part process where the first
part is setting the limits and the second is redrawing the graph
(followed by updating the background). The problem is when the thread
loses control between these two stages. In this case the background is
updated to the old limits although the 'real' limits remain the
updated version.
The solution is to use a lock to ensure that everything is done
atomically. This results in the desired behaviour.
IOW it was completely my fault although an interesting bug:)
Elan
---
Fortunately, the second-to-last bug has just been fixed.
 - Ray Simard
On Wed, Jun 17, 2009 at 7:20 PM, John Hunter<jd...@gm...> wrote:
> On Wed, Jun 17, 2009 at 5:27 PM, Elan Pavlov<ep...@gm...> wrote:
>> Hi,
>> I'm using an animated graph in which most of the time I don't want it
>> to autoscale (due to speed). Once in a while I want it to change the
>> limits of the y-axis. In order to do this I use set_ylim and follow by
>> a canvas.draw(). However it does not actually redraw the canvas and
>> the old tick labels remain (although the scales are reset). When I
>> manually resize the canvas in updates the tick labels. Any ideas what
>> I'm doing wrong?
>
> This doesn't sound right -- a call to canvas.draw should redraw the
> whole canvas cleanly, with the exception of Artists where the animated
> property is set. Can you reduce your code to a free-standing example
> that we can run?
>
> JDH
>
-- 
If I knew that a man was coming to my house with the conscious design
of doing me good, I should run for my life.
- Henry David Thoreau
From: Alexandar H. <vio...@gm...> - 2009年06月18日 15:34:17
Ok, fair enough. Let's use that:
------------------
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
n = 100000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
xmin = x.min()
xmax = x.max()
ymin = y.min()
ymax = y.max()
plt.hexbin(x,y, cmap=cm.jet, gridsize=(50,50), extent=[-2,2,-10,10])
plt.axis([xmin, xmax, ymin, ymax])
plt.title("Hexagon binning")
cb = plt.colorbar()
cb.set_label('counts')
plt.show()
----------------------
I trimmed this from the example, which works fine. Without the extent
option, I get the expected plot of all the data. But, what I'd like is to
trim out some of the empty regions. If I just reset xmin, xmax, etc. the
binning of the data still occurs over the entire range of the data in x and
y, although the plot is correct, but the plot doesn't have the desired 50x50
bins. With the "extent" option I get these errors:
Traceback (most recent call last):
 File "HexBin.py", line 23, in <module>
 plt.hexbin(x,y, cmap=cm.jet, extent=[-2,2,-10,10])
 File "/usr/lib64/python2.5/site-packages/matplotlib/pyplot.py", line 1920,
in hexbin
 ret = gca().hexbin(*args, **kwargs)
 File "/usr/lib64/python2.5/site-packages/matplotlib/axes.py", line 5447,
in hexbin
 collection.update(kwargs)
 File "/usr/lib64/python2.5/site-packages/matplotlib/artist.py", line 548,
in update
 raise AttributeError('Unknown property %s'%k)
AttributeError: Unknown property extent
The same thing as before. It doesn't know what 'extent' is for some reason.
Or, perhaps more accurately, hexbin knows what it is but artist.py doesn't?
The only "solution" i've come up with is to trim the original data that I
input, but that is far from ideal.
Best,
Alex
On Wed, Jun 17, 2009 at 7:50 PM, John Hunter <jd...@gm...> wrote:
> On Wed, Jun 17, 2009 at 5:31 PM, Alexandar Hansen<vio...@gm...>
> wrote:
> > Hello,
> >
> > I've been having fun using hexbin, but I'd like to have consistent bin
> sizes
> > and plot ranges for different sets of data. What I'm finding is that the
> bin
> > sizes are primarily determined by the input data mins and maxes. For
> > instance, I'm plotting data with something like:
>
> Instead of a "something like" could you please post a complete example
> that we can run so we can replicate the error. This saves us a lot of
> time. Also, please report any version info, as described at
>
>
> http://matplotlib.sourceforge.net/faq/troubleshooting_faq.html#report-a-problem
>
> For example, the following runs for me using mpl svn:
>
> import numpy as np
> import matplotlib.cm as cm
> import matplotlib.pyplot as plt
>
> n = 100000
> x = np.random.standard_normal(n)
> y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
> xmin = x.min()
> xmax = x.max()
> ymin = y.min()
> ymax = y.max()
>
> plt.subplots_adjust(hspace=0.5)
> plt.subplot(121)
> plt.hexbin(x,y, cmap=cm.jet, extent=[xmin, xmax, ymin, ymax])
> plt.axis([xmin, xmax, ymin, ymax])
> plt.title("Hexagon binning")
> cb = plt.colorbar()
> cb.set_label('counts')
>
> plt.subplot(122)
> plt.hexbin(x,y,bins='log', cmap=cm.jet)
> plt.axis([xmin, xmax, ymin, ymax])
> plt.title("With a log color scale")
> cb = plt.colorbar()
> cb.set_label('log10(N)')
>
> plt.show()
>
From: Paul N. <pn...@il...> - 2009年06月18日 04:14:06
Pardon me, but I was hasty in sending the diff. The following diff will 
put a multiplication symbol in the tick label where large numbers are 
expected, but it also removes any possibility of getting a number 
written as 1e10, for example, so it definitely is not complete. 
Hopefully, this is a starting point for someone else to fix this properly.
Thanks,
Paul
Index: lib/matplotlib/ticker.py
===================================================================
--- lib/matplotlib/ticker.py	(revision 7225)
+++ lib/matplotlib/ticker.py	(working copy)
@@ -384,18 +384,10 @@
 offsetStr = self.format_data(self.offset)
 if self.offset > 0: offsetStr = '+' + offsetStr
 if self.orderOfMagnitude:
- if self._usetex or self._useMathText:
- sciNotStr = self.format_data(10**self.orderOfMagnitude)
- else:
- sciNotStr = '1e%d'% self.orderOfMagnitude
- if self._useMathText:
- if sciNotStr != '':
- sciNotStr = r'\times\mathdefault{%s}' % sciNotStr
+ sciNotStr = self.format_data(10**self.orderOfMagnitude)
+ if sciNotStr != '':
+ sciNotStr = r'\times\mathdefault{%s}' % sciNotStr
 s = 
''.join(('$',sciNotStr,r'\mathdefault{',offsetStr,'}$'))
- elif self._usetex:
- if sciNotStr != '':
- sciNotStr = r'\times%s' % sciNotStr
- s = ''.join(('$',sciNotStr,offsetStr,'$'))
 else:
 s = ''.join((sciNotStr,offsetStr))
@@ -476,19 +468,15 @@
 significand = tup[0].rstrip('0').rstrip('.')
 sign = tup[1][0].replace('+', '')
 exponent = tup[1][1:].lstrip('0')
- if self._useMathText or self._usetex:
- if significand == '1':
- # reformat 1x10^y as 10^y
- significand = ''
- if exponent:
- exponent = '10^{%s%s}'%(sign, exponent)
- if significand and exponent:
- return r'%s{\times}%s'%(significand, exponent)
- else:
- return r'%s%s'%(significand, exponent)
+ if significand == '1':
+ # reformat 1x10^y as 10^y
+ significand = ''
+ if exponent:
+ exponent = '10^{%s%s}'%(sign, exponent)
+ if significand and exponent:
+ return r'%s{\times}%s'%(significand, exponent)
 else:
- s = ('%se%s%s' %(significand, sign, exponent)).rstrip('e')
- return s
+ return r'%s%s'%(significand, exponent)
 except IndexError, msg:
 return s
From: Paul N. <pn...@il...> - 2009年06月18日 04:04:23
Hello,
I think there is an unused parameter in matplotlibrc, the text.markup 
which defaults to 'plain'. text.markup is not found in rcsetup.py.
Similarly, there is a keyword to ScalarFormatter, useMathText, that is 
always set to its default, False, in ticker.py; no other function 
accesses or uses that keyword. It seems that could be eliminated without 
ill-effect.
I came across this while looking for a way to have the tick formatter 
include a multiplication sign when writing very large numbers, instead 
of using engineering notation such as 1e10. I would like to be able to 
do this using the mathtext facilities native to matplotlib, and not have 
to resort to usetex.
The following diff changes the tick formatter to work as I would like 
it, but it also probably breaks something else because I have not tested 
it at all. Please consider it as a starting point.
Paul
Index: ticker.py
===================================================================
--- ticker.py	(revision 7225)
+++ ticker.py	(working copy)
@@ -384,18 +384,10 @@
 offsetStr = self.format_data(self.offset)
 if self.offset > 0: offsetStr = '+' + offsetStr
 if self.orderOfMagnitude:
- if self._usetex or self._useMathText:
- sciNotStr = self.format_data(10**self.orderOfMagnitude)
- else:
- sciNotStr = '1e%d'% self.orderOfMagnitude
- if self._useMathText:
- if sciNotStr != '':
- sciNotStr = r'\times\mathdefault{%s}' % sciNotStr
+ sciNotStr = self.format_data(10**self.orderOfMagnitude)
+ if sciNotStr != '':
+ sciNotStr = r'\times\mathdefault{%s}' % sciNotStr
 s = 
''.join(('$',sciNotStr,r'\mathdefault{',offsetStr,'}$'))
- elif self._usetex:
- if sciNotStr != '':
- sciNotStr = r'\times%s' % sciNotStr
- s = ''.join(('$',sciNotStr,offsetStr,'$'))
 else:
 s = ''.join((sciNotStr,offsetStr))

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