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



Showing 9 results of 9

From: Eric F. <ef...@ha...> - 2011年11月29日 23:46:28
On 11/29/2011 01:29 PM, Nat Echols wrote:
> I'm plotting values that cover a very small range with a relatively
> large base, e.g.
>
> 375.0001
> 375.00025
> 375.0002
> ...
>
> In practice, the data series hovers at a single value for several
> hundred elements in a row, then fluctuates slightly. Initially
> matplotlib does what I expect, and the Y-axis ticks are labeled 373,
> 374, 376, 376, etc. Once the small fluctuations are plotted, however,
> it switches to showing relative values, with the absolute reference
> point above the plot, as in the attached image. This is needlessly
> confusing - is there a way to prevent such behavior?
>
> thanks,
> Nat
If you are using mpl 1.0 or later, try
pyplot.ticklabel_format(useOffset=False)
It is also available as an Axes method.
Eric
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Nat E. <nat...@gm...> - 2011年11月29日 23:29:19
Attachments: plot.png
I'm plotting values that cover a very small range with a relatively
large base, e.g.
375.0001
375.00025
375.0002
...
In practice, the data series hovers at a single value for several
hundred elements in a row, then fluctuates slightly. Initially
matplotlib does what I expect, and the Y-axis ticks are labeled 373,
374, 376, 376, etc. Once the small fluctuations are plotted, however,
it switches to showing relative values, with the absolute reference
point above the plot, as in the attached image. This is needlessly
confusing - is there a way to prevent such behavior?
thanks,
Nat
I would like to suggest the following fixes for the
mpl_toolkits.basemap module to improve its treatment of celestial
(rather than geographic) coordinates.
The first one, posted at
https://github.com/mollyswanson/basemap/commit/23db4bbebf4d7fe6ca202b5dad50b6a2054dd685
changes the call function in basemap's init.py to correctly transform
lat/lon values into xy map coordinates in the case of a cyclic or
polycyclic projection with lon_0 not equal to 0.
The second, posted at
https://github.com/mollyswanson/basemap/commit/35470b51523e9429d26cefc911dca843264581b9
changes one line in the drawparallels. This line is to avoid drawing
lines between points on the parallel that span the whole map. However,
the old version uses a fixed value for the distance between the points
rather than scaling it to the radius of the sphere used in the
projection, so if you use a non-default radius (such as 180/pi, so
your x-y values are in degrees on the sky instead of meters on the
earth) it won't work. This fix scales the cutoff value to the radius
of the projection sphere.
The following example illustrates the issues that are addressed here:
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
figure(1)
#make a basemap centered on longitude of 90
m=Basemap(celestial=False,lon_0=90,projection='hammer')
#draw map boundary and grid
m.drawmapboundary()
m.drawparallels(np.arange(-90.,91.,30.),labels=[1,0,0,0])
m.drawmeridians(np.arange(-90.,271.,30.),labels=[0,0,0,0])
#define a test polygon - a triangle with corners at
[lon,lat]=[90,30],[120,60],[120,30]
polygon=array([[90,30],[120,60],[120,30],[90,30]])
#convert to map coordinates
polyxy=m(polygon[:,0],polygon[:,1])
plt.plot(polyxy[0],polyxy[1])
plt.savefig('basemap1.png')
figure(2)
#make a celestial basemap centered on longitude of 90
m=Basemap(celestial=True,lon_0=90,projection='hammer',rsphere=180./pi)
#draw map boundary and grid
m.drawmapboundary()
m.drawparallels(np.arange(-90.,91.,30.),labels=[1,0,0,0])
m.drawmeridians(np.arange(-90.,271.,30.),labels=[0,0,0,0])
#define a test polygon - a triangle with corners at
[lon,lat]=[90,30],[120,60],[120,30]
polygon=array([[90,30],[120,60],[120,30],[90,30]])
#convert to map coordinates
polyxy=m(polygon[:,0],polygon[:,1])
plt.plot(polyxy[0],polyxy[1])
plt.savefig('celestial_basemap1.png')
Thank you!
Molly Swanson
From: Ed M. <ed....@gm...> - 2011年11月29日 21:20:33
I have a short script to plot 20 years of river flow data. I can use
the plot_date command to create a plot, using this snippet:
f = figure()
ax1 = f.add_subplot(111)
ax1.plot_date(dates0,y1,'g', label='observed', xdate=True,visible=True)
ax1.plot_date(dates1,y2,'r', label='simulated', xdate=True,visible=True)
years = YearLocator(1, month=6, day=30) # every year
months = MonthLocator(1) # every month
ax1.set_xlim(date2num(datetime.date(1990,1,1)),date2num(datetime.date(1999,12,31)))
ax1.xaxis.set_major_locator(years)
ax1.xaxis.set_minor_locator(months)
labels = ax1.get_xticklabels()
setp(labels, fontsize=8,visible=True)
The problem is with the x-axis (time axis) labels when I add a second
subplot, to add the next time segment. I change the above to ax1 =
f.add_subplot(211), and then:
ax2 = f.add_subplot(212)
ax2.plot_date(dates0,y1,'g') #plots the time series
ax2.plot_date(dates1,y2,'r') #need to call twice, unlike plot,
plot_date takes one set
ax2.set_xlim(date2num(datetime.date(2000,1,1)),date2num(datetime.date(2009,12,31)))
ax2.xaxis.set_major_locator(years)
ax2.xaxis.set_minor_locator(months)
setp(labels, fontsize=8,visible=True)
The x-axis labels only appear for the last subplot. I'm guessing that
plot_date assumes that more than one subplot must share a time axis.
There must be a simple way to stop plot_date from doing this, if this
is indeed the problem. Any guidance would be appreciated.
Thanks,
Ed
From: Neil B. <nb...@at...> - 2011年11月29日 21:17:02
Attachments: histogram.eps
Hello all,
I am struggling to improve the layout of these subplots. You can see that the x tick labels on the left subplot are crunched. I simply want to stretch the x axis a bit in order to spread out the x ticks. Do you have any suggestions?
Thanks!
Neil
-----
Here is my code:
P.figure()
P.subplots_adjust(wspace=0.4)
P.subplot(121)
P.hist([el_mean_diff,ln_mean_diff],bins=[-.7,-.6,-.5,-.4,-.3,-.2,-.1,0,.1,.2,.3,.4,.5,.6,.7],color=['red','blue'],align='mid')
P.title('a) mean')
P.xlabel('Average difference at each grid point (m/s) ')
P.ylabel('Number of grid points')
P.tick_params(axis='both',direction='out',top='off',right='off',length=2,labelsize='10')
P.grid(True)
P.subplot(122)
P.hist([el_stdv_diff,ln_stdv_diff],bins=[-.5,-.4,-.3,-.2,-.1,0,.1,.2,.3,.4,.5],color=['red','blue'],align='mid')
P.title('b) standard deviation')
P.xlabel('Average difference at each grid point (m/s) ')
P.ylabel('Number of grid points')
P.tick_params(axis='both',direction='out',top='off',right='off',length=2,labelsize='10')
P.grid(True)
P.show()
----
From: Ryan M. <rm...@gm...> - 2011年11月29日 15:06:14
On Tue, Nov 29, 2011 at 4:16 AM, Fabien Lafont <laf...@gm...> wrote:
> Hello everyone,
>
> I don't understand how works TimerBase.
>
>
>
> >From matplotlib import backend_bases
>
> def write(x):
>   print x
>
> backend_bases.TimerBase._timer_start
> backend_bases.TimerBase(1000,write(2))
TimerBase is a do-nothing skeleton class that provides the common
infrastructure for other backends to implement a timer that works with
them (just like the rest of backend_bases). For example, the gtk
backend uses this as a starting point for its own timer class. You
really shouldn't be instantiating TimerBase yourself as it won't do
anything.
> It returns only "2" one time. Why it doesn't return 2 every second?
The only reason you actually see anything at all is because you call
write yourself when you do:
write(2)
The timer never actually does anything. The proper call is to separate
the function and its arguments, since as the docs say, it takes a
"list of (func, args) tuples that will be
called upon timer events":
TimerBase(1000, [(write, 2)])
However, the proper way to create a timer, which will intergrate
properly with the figure event loop, is shown in the example:
http://matplotlib.sourceforge.net/examples/event_handling/timers.html
In your case:
timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(write, 2)
timer.start()
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Fabien L. <laf...@gm...> - 2011年11月29日 10:16:44
Hello everyone,
I don't understand how works TimerBase.
>From matplotlib import backend_bases
def write(x):
 print x
backend_bases.TimerBase._timer_start
backend_bases.TimerBase(1000,write(2))
It returns only "2" one time. Why it doesn't return 2 every second?
Thx in advance,
Fabien
From: Markus B. <mar...@gm...> - 2011年11月29日 02:09:23
> This is a bug. In the current implementation, "annotate" has a
> side-effect that modifies the arrowprops dictionary.
> As a workaround, you may do,
>
> arrowprops = dict(arrowstyle='-', relpos=(0, 1))
> plt.annotate('Good relpos', (3, 3), xytext = (3, 2),
>
 annotation_clip=False, arrowprops=arrowprops.copy())
>
>
Works for me. Thanks a lot!
>
> > plt.annotate('No ha/va', (5, 5), xytext = (5, 4),
> > arrowprops=dict(arrowstyle='-'),
> > ha='left', va='top')
> >
>
> ha and va controls the location of the text relative to the xytext,
> and I believe it does work as expected. It has nothing to do with the
> starting point of the arrow, which should be controlled by the relpos
> parameter.
>
Thanks for clarifying.
Regards,
Markus
From: Austin G. <au...@as...> - 2011年11月29日 01:59:46
Hello,
Are there examples of extending imshow or further customizing any of
the UI components of matpotlib? Or anything you can point me at to
get started? I have been able to connect events to imshow. An
example of the type of thing I might want to do is to print the R,G,B
value in a status bar when I hover over an x y coordinate of an image.
-- 
Austin Godber

Showing 9 results of 9

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