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





Showing 19 results of 19

From: Daniel M. <dan...@go...> - 2011年01月13日 23:40:40
Attachments: 3D_colorbar.py
Hi,
I am trying to plot a set of simulation results of FEM simulations.
With a lot of help from Ben I can plot the deformed shape quite nicely
but I have trouble in applying a colorbar to the plot.
In the attached file there are three results with different results.
How can I apply a "global" colorbar so that all collections are nicely
represented?
Thanks a lot in advance,
Daniel
From: Chris F. <sta...@me...> - 2011年01月13日 20:07:30
Sorry for the lack of clarity in my last shot at this problem. What I want to be able to do is change a plot's axis to the log scale, then have some reasonable (i.e. evenly-spaced) tick labels generated automatically. I have tried to do this manually, but end up with the following:
http://cl.ly/3h1T2i0a0T3X0K2b3W11
After Paul's answer to the original message, I have tried messing with the major_locator:
ml = MultipleLocator(0.2)
ax.xaxis.set_major_locator(ml)
with different values for the MultipleLocator. Though the ticks do change, I only am able to see labels such as 10^0, 10^1, etc. -- I need better labels than that, such as [0, 0.3, 0.5, 1, 2, 4, 7] -- these are good values, because they are unlikely to overlap on the log scale. It will be a pain, however, to do this manually for every plot, so I am looking for a way to automate this somehow. I was hoping (and still hope) that Matplotlib is able to choose reasonable ticks on the log scale that do not overlap, but are more informative than just powers of 10.
Hope that is clearer,
cf
From: Daniel M. <dan...@go...> - 2011年01月13日 19:40:10
Attachments: mpl3D_col.py
Dear Ben,
again, thanks for all your support! Still, I am unable to get the plot
done. In your example, each set of elements gets a color where as I
need each element to have its own color.
I'll attach a file to demonstrate. Maybe you know how to get this
done, and sorry that I am a bit slow on this :(
Best regards,
Daniel
From: Chris F. <sta...@me...> - 2011年01月13日 19:18:57
On Jan 12, 2011, at 10:33 PM, Paul Ivanov wrote:
> In [50]: plt.loglog(1,1)
> Out[50]: [<matplotlib.lines.Line2D object at 0x108dde4c>]
> 
> In [51]: ax = plt.gca()
> 
> In [52]: loc = ax.xaxis.get_major_locator()
> 
> In [53]: loc.numticks
> Out[53]: 15
> 
> In [54]: loc.numticks = 10
Also, this approach does not seem to work in general for me. As an example:
In [49]: loglog([1.341, 0.1034, 0.6076, 1.4278, 0.0374], 
 ....: [0.37, 0.12, 0.22, 0.4, 0.08], 'o')
In [50]: loc = ax.xaxis.get_minor_locator()
In [51]: loc.numticks=10
In [52]: loc.numticks=5
This does nothing to change the number of minor ticks, and I tried the same thing for get_major_locator(), with the same result. The plot does not change at all.
Thanks,
cf
From: Michael D. <md...@st...> - 2011年01月13日 16:57:01
On 01/13/2011 11:38 AM, Alex S wrote:
> Hi there,
> I've made a program that makes plots using New Century Schoolbook Lt Std
> font. I did this by inserting this into the matplotlibrc file:
>
> font.family : New Century Schoolbook LT Std # serif #sans-serif
>
> There's also a "fontlist.cache" file that I think points to it when it says:
>
> .
> .
> .
> (dp283
> g12
> g45
> sg14
> S'New Century Schoolbook LT Std'
> p284
> sg16
> I400
> sg17
> g13
> sg18
> .
> .
> .
>
> This all works fine on my computer. But I'm trying to make it run on other
> people's computers (off a network drive) but when I do the plots all go back
> into Ariel font and all the spacing and stuff gets screwed up. Running the
> exact same exe from the same place, my computer continues to make them with
> the correct font. I have copied the matplotlibrc file and the
> fontlist.cache file from my hard drive (C:...Matplotlib) to the mpl-data
> folder in the dist folder (from py2exe) but that didn't work.
>
> Does anyone have any ideas for fixing this stuff? I think it might just be
> a matter of including the right files in the Py2Exe setup file but I don't
> know which ones. Or maybe changing how I select the font, which was a
> roundabout way of doing it from the start.
The fontList.cache file maps from the properties (names, weights, 
slants) etc. of the fonts available on a particular system to their file 
path. You should definitely not ship this file with the exe, but rather 
allow it to be regenerated from scratch on each system, since the 
selection and locations of fonts is very likely to be different.
I think "New Century Schoolbook" is one of the fonts that ships with 
Windows, so you can probably count on it being there. If not, you need 
to ship the font as part of the exe by adding it to mpl-data/fonts/ttf 
and then following the instructions to include the fonts given here:
http://www.py2exe.org/index.cgi/MatPlotLib
> When I run the plots
> (successfully on my computer) it says this at one point:
>
> c:\Python26\lib\site-packages\matplotlib\backends\backend_pdf.py:982:
> UserWarning: 'newcenturyschlbkltstd-roman.otf' can not be subsetted into a
> Type 3 font. The entire font will be embedded in the output.
>
> Maybe that has somethign to do with what's going on?
> 
I don't think that's related. All this means is that when it embeds the 
font into the PDF file, it has to embed the entire thing rather than 
only the characters that are being used. (Resulting in a larger PDF 
file, but otherwise fine.) To avoid this message, you can set the 
rcParam "pdf.fonttype" to 42.
Cheers,
Mike
>
>
> Thanks a lot,
> Alex
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Alex S <sch...@gm...> - 2011年01月13日 16:39:00
Hi there,
I've made a program that makes plots using New Century Schoolbook Lt Std
font. I did this by inserting this into the matplotlibrc file:
font.family : New Century Schoolbook LT Std # serif #sans-serif
There's also a "fontlist.cache" file that I think points to it when it says:
.
.
.
(dp283
g12
g45
sg14
S'New Century Schoolbook LT Std'
p284
sg16
I400
sg17
g13
sg18
.
.
.
This all works fine on my computer. But I'm trying to make it run on other
people's computers (off a network drive) but when I do the plots all go back
into Ariel font and all the spacing and stuff gets screwed up. Running the
exact same exe from the same place, my computer continues to make them with
the correct font. I have copied the matplotlibrc file and the
fontlist.cache file from my hard drive (C:...Matplotlib) to the mpl-data
folder in the dist folder (from py2exe) but that didn't work. 
Does anyone have any ideas for fixing this stuff? I think it might just be
a matter of including the right files in the Py2Exe setup file but I don't
know which ones. Or maybe changing how I select the font, which was a
roundabout way of doing it from the start. When I run the plots
(successfully on my computer) it says this at one point:
c:\Python26\lib\site-packages\matplotlib\backends\backend_pdf.py:982:
UserWarning: 'newcenturyschlbkltstd-roman.otf' can not be subsetted into a
Type 3 font. The entire font will be embedded in the output.
Maybe that has somethign to do with what's going on?
Thanks a lot,
Alex
-- 
View this message in context: http://old.nabble.com/Font-not-carrying-through-Py2Exe-tp30663871p30663871.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Benjamin R. <ben...@ou...> - 2011年01月13日 16:00:26
On Thu, Jan 13, 2011 at 7:54 AM, CASOLI Jules <jul...@ce...> wrote:
> Hello to all,
>
> This is yet another question about matplotlib not freeing memory, when
> closing a figure (using close()).
> Here is what I'm doing (tried with several backends, on MacOSX and Linux,
> with similar results):
> --------------------
> import matplotlib as mpl
> from matplotlib import pylot as plt
> import numpy as np
>
> a = np.arange(1000000)
> mpl.cbook.report_memory()
> # -> output: 54256
> plt.plot(a)
> mpl.cbook.report_memory()
> # -> output: 139968
> plt.close()
> mpl.cbook.report_memory()
> # -> output: 138748
> --------------------
>
> Shouldn't plt.close() close the figure _and_ free the memory used by it?
> What am I doing wrong ?
> I tried several other ways to free the memory, such as f = figure(); ... ;
> del f, without luck.
>
> Any help appreciated !
>
> P.S. : side question : how come the call to plot take so much memory (90MB
> for a 8MB array ?). I have read somewhere that each point is coded on three
> RGB floats, but it only means an approx. 12MB plot... (plus small overhead)
>
> Jules
>
>
>
Jules,
Which version of Matplotlib are you using and which backend? On my Linux
install of matplotlib (development branch) using GTKAgg, the memory usage
does get high during the call to show(), but returns to (near) normal
amounts after I close. An interesting observation is that if the
interactive mode is off, the memory usage returns back to just a few
kilobytes above where it was before, but if interactive mode was turned on,
the memory usage returned to being a few hundred kilobytes above where it
started.
Ben Root
P.S. - As a side note, estimating the memory size of these plots from the
given data isn't as straight-forward as multiplying by three (actually, it
would be four because of the transparency value in addition to rgb). There
are many other parts of the graph that needs to be represented (all having
rgba values) but there are also a lot of simplifications that are done to
reduce the amount of memory needed to represent these objects.
From: CASOLI J. <jul...@ce...> - 2011年01月13日 13:54:13
Hello to all,
This is yet another question about matplotlib not freeing memory, when closing a figure (using close()).
Here is what I'm doing (tried with several backends, on MacOSX and Linux, with similar results):
--------------------
import matplotlib as mpl
from matplotlib import pylot as plt
import numpy as np
a = np.arange(1000000)
mpl.cbook.report_memory()
# -> output: 54256
plt.plot(a)
mpl.cbook.report_memory()
# -> output: 139968
plt.close()
mpl.cbook.report_memory()
# -> output: 138748
--------------------
Shouldn't plt.close() close the figure _and_ free the memory used by it?
What am I doing wrong ?
I tried several other ways to free the memory, such as f = figure(); ... ; del f, without luck.
Any help appreciated !
P.S. : side question : how come the call to plot take so much memory (90MB for a 8MB array ?). I have read somewhere that each point is coded on three RGB floats, but it only means an approx. 12MB plot... (plus small overhead)
Jules
From: Michael D. <md...@st...> - 2011年01月13日 13:50:36
The change in behavior was to fix this bug:
http://sourceforge.net/tracker/?func=detail&aid=3062773&group_id=80706&atid=560720
It seems it may be impossible to produce Postscript that works across 
all fonts and all readers at the same time.
Can you provide a simple LaTeX document that illustrates the problem 
with psfrag? This is still compliant Postscript, AFAICT.
Mike
On 01/11/2011 10:43 AM, Benjamin Root wrote:
>
>
> On Tue, Jan 11, 2011 at 8:45 AM, Lebostein <Leb...@gm... 
> <mailto:Leb...@gm...>> wrote:
>
>
> I have compared the new and old output. For example the "0.0" in a
> diagram:
>
> old eps (1.0.0):
>
> 35.223 19.934 m
> 0 0.141 rmoveto
> (0.0) show
> [1 2] 0 setdash
> 0.502 setgray
>
> new eps (1.0.1):
>
> 35.222810 19.933563 translate
> 0.000000 rotate
> 0.000000 0.140625 m /zero glyphshow
> 6.362305 0.140625 m /period glyphshow
> 9.541016 0.140625 m /zero glyphshow
> grestore
> [1 2] 0 setdash
> 0.502 setgray
>
> ...
>
>
> Ah, this bit me yesterday as well. I wanted to edit some labels using 
> InkScape and it became easier to just modify my original script and 
> just re-make the image. I know there were some "fixes" recently, but 
> I don't know the specifics.
>
> Ben Root
>
>
> ------------------------------------------------------------------------------
> Gaining the trust of online customers is vital for the success of any company
> that requires sensitive data to be transmitted over the Web. Learn how to
> best implement a security strategy that keeps consumers' information secure
> and instills the confidence they need to proceed with transactions.
> http://p.sf.net/sfu/oracle-sfdevnl
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Michael D. <md...@st...> - 2011年01月13日 13:36:23
Do you have Arial installed? (I see you are on Linux, so it's unlikely 
to have been installed by default -- that font is shipped with Windows 
and copyright Microsoft). If it is installed, you may need to clear 
your matplotlib font cache in ~/.matplotlib/fontList.cache.
Mike
On 01/13/2011 05:42 AM, Bala subramanian wrote:
> Friends,
> The journal in which i am planning to send my paper says that the 
> figure and panel labels should be in 'ARIAL' bold.
>
> When i try to set the font as arial, i get a warning message. Someone 
> kindly let me know what is the appropriate setting to get the font 
> arial bold.
>
> /usr/lib/python2.5/site-packages/matplotlib/font_manager.py:1242: 
> UserWarning: findfont: Font family ['sans-serif'] not found. Falling 
> back to Bitstream Vera Sans (prop.get_family(), 
> self.defaultFamily[fontext]))
>
>
> FIG=plt.figure(figsize=(6.8,4),dpi=200)
> FIG.subplots_adjust(hspace=0.02,wspace=0.02)
> NROW=2;NCOL=2
> TXT=['A','B','C','D']
> mpl.rcParams['font.sans-serif']='Arial'
>
> # Block 1
> ax1=FIG.add_subplot(NROW,NCOL,1)
> data1=np.loadtxt(flist[0],usecols=(1,)); 
> m1=round(np.mean(data1[10001:]),2)
> data2=np.loadtxt(flist[1],usecols=(1,)); 
> m2=round(np.mean(data2[10001:]),2)
> ax1.plot(data1,color='black',label=str(m1))
> ax1.plot(data2,color='red',label=str(m2))
> plt.setp(ax1.get_xticklabels(),visible=False)
> ------------------------
>
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA
From: Bala s. <bal...@gm...> - 2011年01月13日 10:42:54
Friends,
The journal in which i am planning to send my paper says that the figure and
panel labels should be in 'ARIAL' bold.
When i try to set the font as arial, i get a warning message. Someone kindly
let me know what is the appropriate setting to get the font arial bold.
/usr/lib/python2.5/site-packages/matplotlib/font_manager.py:1242:
UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to
Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext]))
FIG=plt.figure(figsize=(6.8,4),dpi=200)
FIG.subplots_adjust(hspace=0.02,wspace=0.02)
NROW=2;NCOL=2
TXT=['A','B','C','D']
mpl.rcParams['font.sans-serif']='Arial'
# Block 1
ax1=FIG.add_subplot(NROW,NCOL,1)
data1=np.loadtxt(flist[0],usecols=(1,)); m1=round(np.mean(data1[10001:]),2)
data2=np.loadtxt(flist[1],usecols=(1,)); m2=round(np.mean(data2[10001:]),2)
ax1.plot(data1,color='black',label=str(m1))
ax1.plot(data2,color='red',label=str(m2))
plt.setp(ax1.get_xticklabels(),visible=False)
------------------------
From: Jochen D. <joc...@nt...> - 2011年01月13日 09:43:42
Hi!
 > I noticed that the boxplot function incorrectly calculates the
 > location of the median line in each box. As a simple example,
 > plotting
 > the dataset [1, 2, 3, 4] incorrectly plots the median line at 3.
I can confirm this.
 > [..]
 > I would suggest that mlab.prctile be fixed to conform to some one
 > or other of these methods, rather than adding to the proliferation of
 > approaches to quantile-calculation. Is there any motivation for
 > always truncating to integer (other that "it's quicker to type" :-)?
And I agree here. I also recently (before I noticed this thread) posted 
a bug report #3151034 [1]
There is also documented, that the mlab.prctle function does not yield 
the same results as scipy.stats.scoreatpercentile. In addition to make 
the confusion complete matlab reports yet another result ... But I think 
at least matplotlib and the scipy-stats-package should agree.
Jochen
[1] 
http://sourceforge.net/tracker/?func=detail&aid=3151034&group_id=80706&atid=560720
-- 
Jochen Deibele, PhD candidate, Dipl.-Ing.
Department of Circulation and Medical Imaging
Norwegian University of Science and Technology (NTNU)
Phone: +47 728 28028 E-Mail: joc...@nt...
From: Paul I. <piv...@gm...> - 2011年01月13日 09:31:32
Salvador Benimeli, on 2011年01月13日 10:10, wrote:
> I would like to known if it is possible to hide a plot from a graph.
> 
> For example, I have the following python code:
> 
> for i in range(0,len(self.data):
> ..........
> c = np.array(s[i])
> self.axes.plot_date(t[i],c,self.colors[i],label=self.labels[i])
> .........
> 
> currently this code "draws" to plots on the canvas. The question is if its
> possible to hide/unhide a plot while remains the other.
Hi Salvador,
yes, it is possible. Just save the list plot_date returns, and
then call set_visible(False) on every member of that list.
 lines = plot_date([2000.10,2000.20,2000.30],[1,2,3])
 [l.set_visible(False) for l in lines]
or something like this to toggle visibility on and off
 [l.set_visible(not l.get_visible()) for l in lines]
 
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Salvador B. <sa...@gm...> - 2011年01月13日 09:10:39
Hello,
I would like to known if it is possible to hide a plot from a graph.
For example, I have the following python code:
for i in range(0,len(self.data):
 ..........
 c = np.array(s[i])
 self.axes.plot_date(t[i],c,self.colors[i],label=self.labels[i])
 .........
currently this code "draws" to plots on the canvas. The question is if its
possible to hide/unhide a plot while remains the other.
Thaks a lot.
From: Paul I. <piv...@gm...> - 2011年01月13日 04:34:08
Christopher Fonnesbeck, on 2011年01月12日 20:12, wrote:
> I'm wondering if there is a way of automating tick labeling on
> log-scale axes, so that labels do not overlap. Specifically,
> when the values get large, they overlap which makes the labels
> unreadable. I would expect them to automatically get more
> sparse with the axis value, as they do when you generate such
> plots in R, for example.
Hi Christopher,
can you provide a small code example that demonstrates the
problem you're having?
The ticks get placed by a ticklocator. You can change the number
of ticks that get placed by setting the appropriate locators
numticks parameter.
In [50]: plt.loglog(1,1)
Out[50]: [<matplotlib.lines.Line2D object at 0x108dde4c>]
In [51]: ax = plt.gca()
In [52]: loc = ax.xaxis.get_major_locator()
In [53]: loc.numticks
Out[53]: 15
In [54]: loc.numticks = 10
IIRC, the variable name changes slightly from locator to locator,
but you can quickly figure it out in ipython using tab completion
in IPython once you grab a given locator object. 
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Christopher F. <sta...@me...> - 2011年01月13日 02:12:25
I'm wondering if there is a way of automating tick labeling on log-scale axes, so that labels do not overlap. Specifically, when the values get large, they overlap which makes the labels unreadable. I would expect them to automatically get more sparse with the axis value, as they do when you generate such plots in R, for example.
Thanks in advance,
cf
From: Paul I. <piv...@gm...> - 2011年01月13日 01:03:56
Christopher Brewster, on 2011年01月13日 00:27, wrote:
> I have a bar chart with three sets of figures and I would like
> some space between the three sets. I cannot seem to find
> anything in the manual or online which explains how to separate
> sets of data. I tried adding a blank (white bar) with 0 data
> and that did not work. When I made the data non zero I got
> overlapping bars. Basically I want the US/EU/Japan data
> slightly set apart. This is the default if I use a speadsheet
> package.
Hi Christopher,
Given the width for each bar that you've chosen and how you're
offsetting each year, there's just not room left between the
indexes that you're using. Just change your ind assignment line
to this:
 
 ind = np.arange(0, 2*N, 2) 
this spaces your indexes out more.
hope that helps,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Benjamin R. <ben...@ou...> - 2011年01月13日 00:45:52
On Wed, Jan 12, 2011 at 6:27 PM, Christopher Brewster
<cbr...@gm...>wrote:
> My apologies in advance if this is obvious.
>
> I have a bar chart with three sets of figures and I would like some space
> between the three sets. I cannot seem to find anything in the manual or
> online which explains how to separate sets of data.
> I tried adding a blank (white bar) with 0 data and that did not work. When
> I made the data non zero I got overlapping bars. Basically I want the
> US/EU/Japan data slightly set apart. This is the default if I use a
> speadsheet package.
>
> I must be doing something obviously wrong.
>
> Thank you in advance for your help
> Christopher
>
> ----------------
> #!/usr/bin/env python
> import numpy as np
> import matplotlib.pyplot as plt
>
> N = 3
> _1971 = (120, 130, 70)
> _2008 = (400, 370, 180)
> _2011 = (350, 350, 140)
> # _blank = (100,100,100)
>
> ind = np.arange(N) # the x locations for the groups
> width = 0.35 # the width of the bars
>
> plt.subplot(111)
> rects1 = plt.bar(ind, _1971, width, color='r')
> rects2 = plt.bar(ind+width, _2008, width, color='y')
> rects3 = plt.bar(ind+width+width, _2011, width, color='b')
> # rects4 = plt.bar(ind+width+width+width, _blank, width, color='w')
>
> plt.ylabel('Annual Expenditure ($bn)')
> plt.title('Net Imports')
> plt.xticks((ind+(width*1.5)), ('US', 'EU', 'Japan'))
> plt.axes().yaxis.grid(True, linestyle='--', which='major', color='grey',
> alpha=0.75) # add a grid to the subplot
>
> plt.show()
> # plt.savefig('oilbar.pdf')
>
> ----------------
>
Are you looking for something that is grouped in threes (3 US bars, space, 3
EU bars, space, 3 Japan bars)? Or what? It would be helpful if you include
an example of what you would like from the spreadsheet program.
Btw, if you want space in between the three groups like I described above,
you can simply make the 'width' variable smaller (like 0.15).
Ben Root
From: Christopher B. <cbr...@gm...> - 2011年01月13日 00:27:26
My apologies in advance if this is obvious.
I have a bar chart with three sets of figures and I would like some space between the three sets. I cannot seem to find anything in the manual or online which explains how to separate sets of data.
I tried adding a blank (white bar) with 0 data and that did not work. When I made the data non zero I got overlapping bars. Basically I want the US/EU/Japan data slightly set apart. This is the default if I use a speadsheet package.
I must be doing something obviously wrong.
Thank you in advance for your help
Christopher
----------------
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
N = 3
_1971 = (120, 130, 70)
_2008 = (400, 370, 180)
_2011 = (350, 350, 140)
# _blank = (100,100,100)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
plt.subplot(111)
rects1 = plt.bar(ind, _1971, width, color='r')
rects2 = plt.bar(ind+width, _2008, width, color='y')
rects3 = plt.bar(ind+width+width, _2011, width, color='b')
# rects4 = plt.bar(ind+width+width+width, _blank, width, color='w')
plt.ylabel('Annual Expenditure ($bn)')
plt.title('Net Imports')
plt.xticks((ind+(width*1.5)), ('US', 'EU', 'Japan'))
plt.axes().yaxis.grid(True, linestyle='--', which='major', color='grey',
 alpha=0.75) # add a grid to the subplot
plt.show()
# plt.savefig('oilbar.pdf')
----------------

Showing 19 results of 19

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