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





Showing 13 results of 13

From: jopeto <g_n...@ho...> - 2011年10月14日 22:46:27
Hello,
I have a question regarding setting a custom axis range. Here's a basic
example:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([1,2,3])
ax.axis([xmin,xmax,ymin,ymax])
plt.show()
Now the question that I'm having is the following. The way I understand it
now, I either have to live with the default axis ranges which matplotlib
gives me, or I need to change all four values xmin, xmax, ymin, ymax using
the ax.axis command. Say that I'm happy with xmin, ymin and ymax, and I only
want to set xmax to a value slightly larger than the default. Is there a way
to specify just that and to be able to keep the other three? The command
which I'm looking for would be something like:
ax.axis([keep default, xmax, keep default, keep default])
If someone has a suggestion, I would be very grateful.
Thanks in advance!
-- 
View this message in context: http://old.nabble.com/custom-axis-range-tp32655869p32655869.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin R. <ben...@ou...> - 2011年10月14日 17:28:57
On Fri, Oct 14, 2011 at 12:24 PM, Chao YUE <cha...@gm...> wrote:
> Dear all,
>
> I am trying to plot data on a 1:1 ratio plot to compare the data.
> I can set the x and y aixs to have the same limits. but how can I set them
> to have the same distance between ticks in the graph?
> Thanks a lot,
>
> chao
>
>
Set the aspect ratio to be equal:
ax.plot(x, y)
ax.set_aspect('equal')
I hope that helps!
Ben Root
From: Chao Y. <cha...@gm...> - 2011年10月14日 17:24:44
Dear all,
I am trying to plot data on a 1:1 ratio plot to compare the data.
I can set the x and y aixs to have the same limits. but how can I set them
to have the same distance between ticks in the graph?
Thanks a lot,
chao
-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
From: John H. <jd...@gm...> - 2011年10月14日 14:05:02
On Fri, Oct 14, 2011 at 8:52 AM, John Hunter <jd...@gm...> wrote:
> On Fri, Oct 14, 2011 at 8:46 AM, Jorge Scandaliaris
> <jor...@ya...> wrote:
>> You're right, John, it works here too with the gtkagg backend. I have just
>> noticed that I had different backend options set in matplotlib.conf and
>> matplotlibrc. My initial report refers then to the Qt4Agg backend.
>
> OK, I can confirm this too on Qt4Agg version 4.8.3.
I opened an issue here
 https://github.com/matplotlib/matplotlib/issues/525
I am no qt expert so perhaps someone else can suggest a solution. In
the gtk backend, I believe we added:
 self.canvas.grab_focus()
to support events w/o clicking on the canvas.
From: John H. <jd...@gm...> - 2011年10月14日 13:53:02
On Fri, Oct 14, 2011 at 8:46 AM, Jorge Scandaliaris
<jor...@ya...> wrote:
> You're right, John, it works here too with the gtkagg backend. I have just
> noticed that I had different backend options set in matplotlib.conf and
> matplotlibrc. My initial report refers then to the Qt4Agg backend.
OK, I can confirm this too on Qt4Agg version 4.8.3.
From: Jorge S. <jor...@ya...> - 2011年10月14日 13:47:00
John Hunter <jdh2358@...> writes:
> 
> I am not seeing this on Linux x86_64 with backend GTKAgg version
> 2.22.0 on python 2.7. Eg, if I run:
> 
> > python simple_plot.py -dgtkagg
> 
> and then hover over the axes window (w/o clicking on it but the window
> has the focus on hover) and press 'g') the grids is toggled.
> 
> JDH
You're right, John, it works here too with the gtkagg backend. I have just
noticed that I had different backend options set in matplotlib.conf and
matplotlibrc. My initial report refers then to the Qt4Agg backend.
BTW, which of matplotlib.conf or matplotlibrc is preferred?
jorges
From: John H. <jd...@gm...> - 2011年10月14日 12:36:12
On Fri, Oct 14, 2011 at 7:18 AM, Jorge Scandaliaris
<jor...@ya...> wrote:
> I run Arch Linux x86_64 and I am using the GTKAgg backend. I tried both with
> IPython and python directly (2.7.2).
I am not seeing this on Linux x86_64 with backend GTKAgg version
2.22.0 on python 2.7. Eg, if I run:
 > python simple_plot.py -dgtkagg
and then hover over the axes window (w/o clicking on it but the window
has the focus on hover) and press 'g') the grids is toggled.
JDH
From: Jorge S. <jor...@ya...> - 2011年10月14日 12:19:02
Benjamin Root <ben.root@...> writes:
> 
> Which backend and platform are you using?Ben Root
> 
I run Arch Linux x86_64 and I am using the GTKAgg backend. I tried both with
IPython and python directly (2.7.2).
jorges
From: Jeff W. <js...@fa...> - 2011年10月14日 12:07:53
On 10/12/11 8:20 PM, questions anon wrote:
> Hi All,
> I keep receiving a memory error when processing many netcdf files. I 
> assumed it had something to do with how I loop things and maybe needed 
> to close things off properly but I recently received an error that 
> made me think it might be because of matplotlib.
>
> In the code below I am looping through a bunch of netcdf files (each 
> file is hourly data for one month) and within each netcdf file I am 
> outputting a *png file every three hours. This works for one netcdf 
> file (therefore one month) but when it begins to process the next 
> netcdf file I receive a memory error (see below). Since I have tidied 
> some of my code up it seems to process partly into the second file but 
> then I still receive the memory error.
> I have tried a few suggestions such as:
> -Combining the dataset using MFDataset (using NETCDF4) is not an 
> option because the files do not have unlimited dimension.
> - gc.collect() but that just results in a /GEOS_ERROR: bad allocation 
> error/.
> -only open LAT and LON once (which worked)
>
> System Details:
> Python 2.7.2 |EPD 7.1-2 (32-bit)| (default, Jul 3 2011, 15:13:59) 
> [MSC v.1500 32 bit (Intel)] on win32
>
> Any feedback will be greatly appreciated as I seem to keep ending up 
> with memory errors when working with netcdf files this even happens if 
> I am using a much better computer.
>
> *Most recent error: *
> Traceback (most recent call last):
> File "C:\plot_netcdf_merc_multiplot_across_multifolders_TSFC.py", 
> line 78, in <module>
> plt.savefig((os.path.join(outputfolder, 
> 'TSFC'+date_string+'UTC.png')))
> File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 363, 
> in savefig
> return fig.savefig(*args, **kwargs)
> File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 
> 1084, in savefig
> self.canvas.print_figure(*args, **kwargs)
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_wxagg.py", 
> line 100, in print_figure
> FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
> File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", 
> line 1923, in print_figure
> **kwargs)
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 438, in print_png
> FigureCanvasAgg.draw(self)
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 393, in draw
> self.renderer = self.get_renderer()
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 404, in get_renderer
> self.renderer = RendererAgg(w, h, self.figure.dpi)
> File 
> "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 59, in __init__
> self._renderer = _RendererAgg(int(width), int(height), dpi, 
> debug=False)
> RuntimeError: Could not allocate memory for image
>
> *Error when I added gc.collect()*
> GEOS_ERROR: bad allocation
>
> *Old error (before adding gc.collect() )*
> /Traceback (most recent call last):
> File 
> "d:/plot_netcdf_merc_multiplot_across_multifolders__memoryerror.py", 
> line 44, in <module>
> TSFC=ncfile.variables['T_SFC'][1::3]
> File "netCDF4.pyx", line 2473, in netCDF4.Variable.__getitem__ 
> (netCDF4.c:23094)
> MemoryError/
>
>
>
> from netCDF4 import Dataset
> import numpy as N
> import matplotlib.pyplot as plt
> from mpl_toolkits.basemap import Basemap
> from netcdftime import utime
> from datetime import datetime
> import os
> import gc
>
>
> shapefile1="E:/
>
> griddeddatasamples/GIS/DSE_REGIONS"
> MainFolder=r"E:/griddeddatasamples/GriddedData/InputsforValidation/T_SFC/"
> OutputFolder=r"E:/griddeddatasamples/GriddedData/OutputsforValidation"
> fileforlatlon=Dataset("E:/griddeddatasamples/GriddedData/InputsforValidation/T_SFC/TSFC_1974_01/IDZ00026_VIC_ADFD_T_SFC.nc",
> 'r+', 'NETCDF4')
> LAT=fileforlatlon.variables['latitude'][:]
> LON=fileforlatlon.variables['longitude'][:]
>
> for (path, dirs, files) in os.walk(MainFolder):
> for dir in dirs:
> print dir
> path=path+'/'
> for ncfile in files:
> if ncfile[-3:]=='.nc':
> print "dealing with ncfiles:", ncfile
> ncfile=os.path.join(path,ncfile)
> ncfile=Dataset(ncfile, 'r+', 'NETCDF4')
> TSFC=ncfile.variables['T_SFC'][1::3]
> TIME=ncfile.variables['time'][1::3]
> ncfile.close()
> gc.collect()
>
> for TSFC, TIME in zip((TSFC[:]),(TIME[:])):
> cdftime=utime('seconds since 1970年01月01日 00:00:00')
> ncfiletime=cdftime.num2date(TIME)
> print ncfiletime
> timestr=str(ncfiletime)
> d = datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S')
> date_string = d.strftime('%Y%m%d_%H%M')
>
> map =
> Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
> 
> llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
> x,y=map(*N.meshgrid(LON,LAT))
> map.drawcoastlines(linewidth=0.5)
> map.readshapefile(shapefile1, 'DSE_REGIONS')
> map.drawstates()
>
> plt.title('Surface temperature at %s UTC'%ncfiletime)
> ticks=[-5,0,5,10,15,20,25,30,35,40,45,50]
> CS = map.contourf(x,y,TSFC, ticks, cmap=plt.cm.jet)
> l,b,w,h =0.1,0.1,0.8,0.8
> cax = plt.axes([l+w+0.025, b, 0.025, h], )
> cbar=plt.colorbar(CS, cax=cax, drawedges=True)
>
> plt.savefig((os.path.join(OutputFolder,
> 'TSFC'+date_string+'UTC.png')))
> plt.close()
> gc.collect()
>
Try moving these lines
 map = 
Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
 
llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
 x,y=map(*N.meshgrid(LON,LAT))
 map.drawcoastlines(linewidth=0.5)
 map.readshapefile(shapefile1, 'DSE_REGIONS')
 map.drawstates()
out of the loop.
-Jeff
From: Yoshi R. <yo...@ro...> - 2011年10月14日 09:36:51
+------------------------------------------------ Keith Hughitt ---------+
> Hi all,
> 
> Does anyone know of a good way to create a new LinearSegmentedColormap
> based off an existing one?
> 
> I have a function which attempts to generate N "optimal" color map
> indices for a given data array. In cases where the number of values
> specified in _segmentdata is the same as N, then I can simply
> copy _segmentdata and modify the indices and create a new color map. In
> many cases, however, the segment data has far fewer interpolation
> points, e.g.:
> 
> In [52]: cm.gray._segmentdata
> Out[52]:
> {'blue': ((0.0, 0, 0), (1.0, 1, 1)),
> 'green': ((0.0, 0, 0), (1.0, 1, 1)),
> 'red': ((0.0, 0, 0), (1.0, 1, 1))}
> 
> 
> Other colormaps may have an arbitrary number of interpolation points.
> Ideally, what I would like is a way to expand this into N points (e.g.
> 256) so that I use that as input for my new map.
> 
i cannot really help you with your approach, but i also think it's not
so elegant to expand cmaps.
did you try to understand the way cmaps can be defined by gradient
borders? -> http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps
i.e. a friend gave me a colormap defined by points and i converted it to
something like that (by just looking at the colors):
ie_data = {
'red': ((0.00, 0.357, 0.357),
 (0.50, 1.000, 1.000),
 (0.75, 1.000, 1.000),
 (1.00, 1.000, 1.000)),
'green':((0.00, 0.467, 0.467),
 (0.50, 1.000, 1.000),
 (0.75, 0.750, 0.750),
 (1.00, 0.371, 0.371)),
'blue':((0.00, 0.800, 0.800),
 (0.50, 1.000, 1.000),
 (0.75, 0.157, 0.157),
 (1.00, 0.157, 0.157))
}
ie = matplotlib.colors.LinearSegmentedColormap('ieMap', ie_data, 256)
use it with cmap=ie
regards
From: Nils W. <nw...@ia...> - 2011年10月14日 08:43:31
Hi all,
what is the native "data" coordinate system for Arrows in 
a polar plot ?
How do I add arrows to a polar plot ?
An example would be appreciated.
fig = figure(figsize=(12,12))
ax = fig.add_subplot(111, polar=True)
Nils
From: Benjamin R. <ben...@ou...> - 2011年10月14日 03:42:46
On Thu, Oct 13, 2011 at 9:52 PM, Jorge Scandaliaris
<jor...@ya...>wrote:
> Hi,
>
> I am experiencing something a bit strange with 'key_press_event': The event
> is
> not detected unless I click with the mouse on the canvas (The grey area
> around
> the axis). I verified this with my own code as well as with some unmodified
> example (
>
> http://matplotlib.sourceforge.net/examples/event_handling/keypress_demo.html?highlight=key_press_event
> ).
> I built mpl from a recent revision (a few days old).
>
> Does anyone else experience this? Is this the expected behavior? I believe
> it
> was enough to have the figure window focused to get key events before, but
> I
> haven't used this feature for some time.
>
> Thanks,
>
> Jorges
>
>
Which backend and platform are you using?
Ben Root
From: Jorge S. <jor...@ya...> - 2011年10月14日 02:52:26
Hi,
I am experiencing something a bit strange with 'key_press_event': The event is
not detected unless I click with the mouse on the canvas (The grey area around
the axis). I verified this with my own code as well as with some unmodified
example (
http://matplotlib.sourceforge.net/examples/event_handling/keypress_demo.html?highlight=key_press_event
).
I built mpl from a recent revision (a few days old).
Does anyone else experience this? Is this the expected behavior? I believe it
was enough to have the figure window focused to get key events before, but I
haven't used this feature for some time.
Thanks,
Jorges

Showing 13 results of 13

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