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 8 results of 8

From: Isidora <is...@ju...> - 2011年10月07日 23:10:16
Hi,
I am trying to create a chart using a given file as background, drawing some curves on the map, and saving an 800x600 PNG.
Code Snipet:
map = Basemap( ................)
pilImg=Image.open('mybkgmap.gif')
rgba = pil_to_array(pilImg)
map.imshow(rgba,interpolation='nearest') # showing background map
..... # Plot some paths on top of background maps
# Add some text explaining map symbols
....
(plt.gcf()).set_size_inches(8,6)
(plt.gcf()).set_dpi(100)
plt.savefig('my.png',format='PNG',bbox_inches='tight',pad_inches=0) # Obtain an 620x480 image without a border
plt.savefig('my.png',format='PNG') # Obtain an 800x600 image with a white border I don't want
Any idea on how can I get the 800x600 without the white border? Any hint will be appreciated.
Thank you
From: Daniel H. <dh...@gm...> - 2011年10月07日 22:57:27
I'm wanting to highlight the artist under the cursor with a transparent
Rectangle patch. To do this, I have very, roughly, in a mouse motion
handler,
under = self.figure.hitlist(ev)
if under:
 artist = under[0]
 bbox = artist.get_window_extent()
 highlight =
matplotlib.patches.Rectangle(xy=bbox.min,width=bbox.width,height=bbox.height,alpha=0.2,color='yellow')
 # further code to blit the last captured graph region with highlight
drawn on top
The main problem is that all artists don't implement get_window_extent(); a
Text object does, and a legend object does, but the Axis objects do not.
So is there a general way to get the bounding box of an artist? I looked
through the API and didn't see anything there. I thought this would be easy
to get to, since almost (every?) artist implements contains(). But it looks
like in the case of XAxis, anyway, that the "hitbox" is being calculated on
the fly in XAxis.contains().
-- 
Daniel Hyams
dh...@gm...
From: Paul H. <pmh...@gm...> - 2011年10月07日 20:40:22
Hey folks,
I'm working on a patch to axes.boxplot that will allow the user to
manually specify the median and confidence intervals (notches) on a
boxplot. My need for this arises since I compute the notch locations
using the BCa-method, which depends on Scipy.
My question relates to how to best have users input their predefined
median and its confidence interval. In my use case, I'm always calling
boxplot one data set at a time and so it has made sense for me pass
the values as a dictionary to my locally-modified boxplot function.
This is probably a quite unique use case.
In the more general use case where an arbitrary number of boxplots
will be generated on a single axes object, what would be the best
method of input? My initial though is to specify a list-of-tuples in
the form: [(lower1, median1, upper1), (lower2, median2, upper2), ...,
(lowerN, medianN, upperN)]. The modified function signature would be:
 def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
 positions=None, widths=None, patch_artist=False,
 bootstrap=None, manualVals=None):
The other best option that comes to mind would be to pass each value
as an individual numpy array with dimensions that are compatible with
the data (x), i.e.,
 def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
 positions=None, widths=None, patch_artist=False,
 bootstrap=None, lowerCIs=None, medians=None, upperCIs=None):
This seems a bit cumbersome both to use and implement, though quite
flexible as the user would not be forced to supply all three arrays.
Any advice, requests, or general input would be much appreciated.
Cheers,
-Paul H.
From: Gökhan S. <gok...@gm...> - 2011年10月07日 19:42:33
Hello,
I have two questions regarding to the positioning of a mpl window (using
WXAgg backend)
1-) How to create a maximized window, instead of me clicking on window to
maximize it each time?
2-) I have two screens. Interestingly, my mpl windows tend to open on my
small screen. How can I force mpl/ipython/WX/X-windows to open mpl windows
on my 2nd and bigger monitor?
Thanks.
-- 
Gökhan
From: Pau <vim...@go...> - 2011年10月07日 18:51:12
I am trying to make a 2D density plot (from some simulation data) with
matplotlib. My x and y data are defined as the log10 of some
quantities. How can I get logarithmic axes (with log minor ticks)?
Here is an exemple of my code:
import numpy as np
import matplotlib.pyplot as plt
Data = np.genfromtxt("data") # A 2-column data file
x = np.log10(Data[:,0])
y = np.log10(Data[:,1])
xmin = x.min()
xmax = x.max()
ymin = y.min()
ymax = y.max()
fig = plt.figure()
ax = fig.add_subplot(111)
hist = ax.hexbin(x,y,bins='log', gridsize=(30,30), cmap=cm.Reds)
ax.axis([xmin, xmax, ymin, ymax])
plt.savefig('plot.pdf')
From: Sudheer J. <sjo...@gm...> - 2011年10月07日 11:42:21
Dear Users,
 I am trying to add module matplotlib-1.0.1 to
my Python 2.7.2 on an IBM power6 with Aix 5.3 . I get the below error when I
issue the command
python setip.py build did any one faced same issue or can I get any expert
suggestion for fixing this issue.
with best regards,
Sudheer
xlc++ xlc -bI:/gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp
build/temp.aix-5.3-2.7/src/ft2font.o build/temp.aix-5.3-2.7/src/mplutils.o
build/temp.aix-5.3-2.7/CXX/cxx_extensions.o
build/temp.aix-5.3-2.7/CXX/cxxsupport.o
build/temp.aix-5.3-2.7/CXX/IndirectPythonInterface.o
build/temp.aix-5.3-2.7/CXX/cxxextensions.o -L/opt/freeware/lib
-L/usr/local/lib -lfreetype -lz -lstdc++ -lm -o
build/lib.aix-5.3-2.7/matplotlib/ft2font.so
sjo@f2n1login1>xlc++
-bI:/gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp
build/temp.aix-5.3-2.7/src/ft2font.o build/temp.aix-5.3-2.7/src/mplutils.o
build/temp.aix-5.3-2.7/CXX/cxx_extensions.o
build/temp.aix-5.3-2.7/CXX/cxxsupport.o
build/temp.aix-5.3-2.7/CXX/IndirectPythonInterface.o
build/temp.aix-5.3-2.7/CXX/cxxextensions.o -L/opt/freeware/lib
-L/usr/local/lib -lfreetype -lz -lstdc++ -lm -o
build/lib.aix-5.3-2.7/matplotlib/ft2font.so
ld: 0711-317 ERROR: Undefined symbol: .main
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
i compiled with -bnoquiet option and get below details
(ld): setopt 64
(ld): halt 4
(ld): setfflag 4
(ld): savename build/lib.aix-5.3-2.7/matplotlib/ft2font.so
(ld): filelist 15 2
(ld): i /lib/crt0_64.o
(ld): i build/temp.aix-5.3-2.7/src/ft2font.o
(ld): i build/temp.aix-5.3-2.7/src/mplutils.o
(ld): i build/temp.aix-5.3-2.7/CXX/cxx_extensions.o
(ld): i build/temp.aix-5.3-2.7/CXX/cxxsupport.o
(ld): i build/temp.aix-5.3-2.7/CXX/IndirectPythonInterface.o
(ld): i build/temp.aix-5.3-2.7/CXX/cxxextensions.o
(ld): lib /opt/freeware/lib/libfreetype.a
(ld): lib /opt/freeware/lib/libz.a
(ld): lib /opt/freeware/lib/libstdc++.a
(ld): lib /usr/lib/libm.a
(ld): lib /usr/vac/lib/libxlopt.a
(ld): lib /usr/vac/lib/libxl.a
(ld): lib /usr/vacpp/lib/libC.a
(ld): lib /usr/lib/libc.a
LIBRARY: Shared object libfreetype.a[libfreetype.so.6]: 343 symbols
imported.
LIBRARY: Shared object libz.a[libz.so.1]: 72 symbols imported.
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[shr_32.imp]: 0
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[shr2_32.imp]: 0
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[shr3_32.imp]: 0
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[ansi_32.imp]: 0
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[shr_64.imp]: 383
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[shr2_64.imp]: 24
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[shr3_64.imp]: 27
LIBRARY: Symbols imported from import file
/usr/vacpp/lib/libC.a[ansi_64.imp]: 2448
LIBRARY: Shared object libC.a[ansi_64.o]: 2658 symbols imported.
LIBRARY: Shared object libc.a[shr_64.o]: 2669 symbols imported.
LIBRARY: Shared object libc.a[posix_aio_64.o]: 20 symbols imported.
LIBRARY: Shared object libc.a[aio_64.o]: 18 symbols imported.
LIBRARY: Shared object libc.a[pse_64.o]: 5 symbols imported.
LIBRARY: Shared object libc.a[dl_64.o]: 4 symbols imported.
LIBRARY: Shared object libc.a[pty_64.o]: 1 symbols imported.
FILELIST: Number of previously inserted files processed: 15
(ld): imports /gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp
IMPORTS: Symbols imported from import file
/gpfs1/sjo/pkgs/local/lib/python2.7/config/python.exp: 1206
(ld): resolve
RESOLVE: 63 of 18106 symbols were kept.
(ld): addgl /usr/lib/glink64.o
ADDGL: Glink code added for 11 symbols.
(ld): er full
ld: 0711-318 ERROR: Undefined symbols were found.
 The following symbols are in error:
 Symbol Inpndx TY CL Source-File(Object-File) OR
Import-File{Shared-object}
 RLD: Address Section Rld-type Referencing
Symbol
 ----------------------------------------------------------------------------------------------
 .main [10] ER PR crt0_64.s(/lib/crt0_64.o)
 00000098 .text R_RBR [34]
 .__start
ER: The return code is 8.
ld: 0711-317 ERROR: Undefined symbol: .main
-- 
with best regards
Sudheer
**********************************************************************************
Sudheer Joseph
Scientist
INDIAN NATIONAL CENTRE FOR OCEAN INFORMATION SERVICES (INCOIS)
MINISTRY OF EARTH SCIENCES, GOVERNMENT OF INDIA
"OCEAN VALLEY" PRAGATHI NAGAR (BO)
OPP.JNTU, NIZAMPET SO
Andhra Pradesh, India. PIN- 500 090.
TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile)
Tel:+91-40-23886047(O),Fax:+91-40-23892910(O)
E-mail: <E-mail%3A...@re...> sud...@ya...;
sj...@in....
Web- http://oppamthadathil.tripod.com
 --------------* ---------------
"The ultimate measure of a man is
not where he stands in moments of
comfort and convenience, but where
he stands at times of challenge and
controversy."
 Martin Luther King, Jr.
"What we have done for ourselves alone dies with us.
What we have done for others and the world remains and is immortal."
- Albert Pines
Hi,
I am attempting to build a set of Figure objects (based on
matplotlib.figure) which are essentially the same chart with different
x-axis limits. I would like to do this in a function that returns the
figures in a list so that i can choose to write some or all of the
figures to a multipage PDF at a later date.
I attempted to do the following:
========================================================
import matplotlib.figure as fig
from matplotlib.backends.backend_pdf import PdfPages, FigureCanvasPdf
xdata = [1,2,3,4,5]
ydata = [5,4,3,2,1]
fig1 = fig.Figure(figsize=(2,2))
ax1 = fig.Figure.add_subplot(fig1,111)
ax1.plot(xdata,ydata)
figures = []
ax1.set_xlim([0,3])
figures.append(fig1)
ax1.set_xlim([3,5])
figures.append(fig1)
pdf = PdfPages('output.pdf')
for figure in figures:
 canvas = FigureCanvasPdf(figure)
 figure.savefig(pdf, format="pdf")
pdf.close()
========================================================
In the actual code the list of figures is returned from a function to
another part of the code, but this is roughly equivalent. I realise in
this example i can just write directly to the pdf file after appending
fig1, but in the actual code i do not wish to write the data to a file
until later on.
The output i get from this code is two identical pages of PDF where
the x limits are set to 3,5. I understand this is because I am simply
making two identical references to the figure object in the list and
by modifying fig1 i also affect the fig1 that is 'stored' in the first
position of the array. My question is how do I avoid this? I have
tried to use copy.copy() and copy.deepcopy(). The former does not work
correctly (for fairly obvious reasons) and the latter does not work
with the figure object giving me an error: "NotImplementedError:
TransformNode instances can not be copied. Consider using frozen()
instead."
So, how can i go about making a list of 'charts' and then output them
selectively to a PDF at a later time?
Many thanks and apologies for any information I have left out.
Stephen
P.S. as an aside, can anyone confirm whether it is possible to write a
multipage PDF using the cairo backend?
From: Michael C. <fat...@ya...> - 2011年10月07日 00:20:45
Hi Ryan
More very interesting information! I will give these methods a try!
Thanks once again,
Mike
rcnelson wrote:
> 
> Mike,
> 
> You may want to look into the matplotlib.cm and matplotlib.colors modules.
> I've had good success with matplotlib.colors.LinearSegmentedColormap and
> its
> 'from_list' method. The documentation is the best location for information
> on this topic. If you have a large number of locations, then the color
> differences will be pretty small, unless you use a colormap with lots of
> different colors. Below is your example using the 'from_list' method and
> the
> built-in colormap 'hsv' (you'll just have to flip around the comments).
> For
> the matplotlib.cm colormaps, be sure to passed in normalized values (which
> is why the call to the colormap is slightly complex).
> 
> Maybe this is a bit more help.
> 
> Ryan
> 
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.colors as plc
> import matplotlib.cm as mcm
> 
> IDs = np.array([47, 33, 47, 12, 50, 50, 27, 27, 16, 27])
> locations = np.array(['201', '207', '207', '205', '204', '201', '209',
> '209', \
> '207','207'])
> dates = np.array([ 733315.83240741, 733315.83521991, 733315.83681713,
> 733315.83788194, 733336.54554398, 733336.54731481,
> 733337.99842593, 733337.99943287, 733338.00070602,
> 733338.00252315])
> 
> fig = plt.figure()
> ax = fig.add_subplot(111)
> locs_un = np.unique(locations)
> # The variable assignment below can be removed if you use the mcm module.
> cs = plc.LinearSegmentedColormap.from_list('Colormap name', ['r', 'g',
> 'b'],
> N=len(locs_un) )
> for n, i in enumerate(locs_un):
> # Reverse the comments here to use the mcm module 'hsv' colormap.
> ax.plot(dates[locations==i],IDs[locations==i],'d', c=cs(n), label=i)
> #ax.plot(dates[locations==i],IDs[locations==i],'d',
> # c=mcm.hsv( float(n)/(len(locs_un)-1) ), label=i)
> ax.xaxis_date()
> fig.autofmt_xdate()
> plt.legend(numpoints=1)
> plt.grid(True)
> plt.show()
> 
> 
> On Tue, Oct 4, 2011 at 5:25 PM, Michael Castleton
> <fat...@ya...>wrote:
> 
>>
>> Ryan,
>> I should clarify my color issue. Your code is smart enough to generate
>> however many colors are needed but I want to make sure the colors are all
>> unique.
>> Thanks again!
>>
>> Mike
>>
>>
>>
>> Mike, sorry to send this twice... I should have sent it to the list as
>> well...
>> _______________________________
>> Mike,
>>
>> If your locations were integers or floats rather than strings, you could
>> just change the scatter call to the following:
>> ax.scatter(dates,IDs,c=
>> locations,marker='d')
>> I don't know about a legend... I don't know if that is possible with a
>> scatter plot (?). Because scatter plots get their colors based off of a
>> color map, you could generate a color bar for your data. You may need to
>> capture the collection object returned from the scatter plot function
>> call,
>> though. Here's your code with these modifications:
>>
>> # Of course, you need to change your locations list to integers rather
>> than
>> strings.
>>
>> fig = plt.figure()
>> ax = fig.add_subplot(111)
>> sc = ax.scatter(dates,IDs,c=locations,marker='d')
>> ax.xaxis_date()
>> fig.autofmt_xdate()
>> plt.colorbar(sc)
>> plt.grid(True)
>> plt.show()
>>
>> If you really need a legend, then you could do a loop of plot commands
>> for
>> each set of unique locations. Using some fancy Numpy masking makes the
>> process easier...
>>
>> import numpy as np
>> import matplotlib.pyplot as plt
>>
>> IDs = np.array([47, 33, 47, 12, 50, 50, 27, 27, 16, 27])
>> locations = np.array(['201', '207', '207', '205', '204', '201', '209',
>> '209', \
>> '207','207'])
>> dates = np.array([ 733315.83240741, 733315.83521991, 733315.83681713,
>>
>> 733315.83788194, 733336.54554398, 733336.54731481,
>> 733337.99842593, 733337.99943287, 733338.00070602,
>> 733338.00252315])
>>
>>
>> fig = plt.figure()
>> ax = fig.add_subplot(111)
>> cs = ['r', 'b', 'g', 'k', 'c']
>> for n, i in enumerate(np.unique(locations)):
>> ax.plot(dates[locations==i],IDs[locations==i],'d', c=cs[n%len(cs)],
>> label=i)
>> ax.xaxis_date()
>> fig.autofmt_xdate()
>> plt.legend(numpoints=1)
>> plt.grid(True)
>> plt.show()
>>
>> Not sure if this is exactly what you wanted, but I hope it helps a
>> little.
>>
>> Ryan
>>
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/color-problems-in-scatter-plot-tp32584727p32592799.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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. Business sense. IT sense. Common sense.
>> http://p.sf.net/sfu/splunk-d2dcopy1
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> 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. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/color-problems-in-scatter-plot-tp32584727p32603057.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Showing 8 results of 8

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