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

Showing results of 57

<< < 1 2 3 > >> (Page 2 of 3)
From: John H. <jdh...@ac...> - 2004年01月22日 21:54:30
>>>>> "Engelsma," == Engelsma, Dave <D.E...@La...> writes:
 Engelsma,> Why are the x-axis limits adjusted when I try to plot a
 Engelsma,> vertical line as a Control Limit?
Everytime you add some data to the plot, matplotlib recomputes the
axis limits. The quick fix for you is to set your xlim after all the
plot commands
 # the histogram of the data
 n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)
 # add a 'best fit' line
 y = matplotlib.matlab.normpdf(bins, average[i], std_dev[i])
 l = matplotlib.matlab.plot(bins, y, 'r--')
 matplotlib.matlab.set(l, 'linewidth', 2)
 matplotlib.matlab.xlabel(DataDescription[i])
 matplotlib.matlab.ylabel('Number of Parts')
 matplotlib.matlab.plot([201,201],[0,40],'k--')
 matplotlib.matlab.title(PartNum + " -- " + PartDesc)
 matplotlib.matlab.set(matplotlib.matlab.gca(), 'xlim', [199, 205])
 matplotlib.matlab.show()
But it's not clear to me why the autoset would leave some of your data
offscreen - that shouldn't happen. I'll take a look at that code. Is
it possible for you to provide a complete example that replicates the
problem?
On an unrelated note, give that you like to use the fully qualified
names of all the functions, you might prefer the object oriented
interface
 n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)
 ax = matplotlib.matlab.subplot(111)
 y = matplotlib.mlab.normpdf(bins, average[i], std_dev[i])
 ^ normpdf is defined in mlab.py, not matlab.py
 lines = ax.plot(bins, y, 'r--')
 for line in lines:
 line.set_linewidth(2)
 ax.set_xlabel(DataDescription[i])
 ax.set_ylabel('Number of Parts')
 ax.plot([201,201],[0,40],'k--')
 ax.set_title(PartNum + " -- " + PartDesc)
 ax.set_xlim([199, 205])
 matplotlib.matlab.show()
Hope this helps,
John Hunter
From: Engelsma, D. <D.E...@La...> - 2004年01月22日 21:18:21
Hi -
I'm using the following code to generate a histogram. I also want to plot
the Upper Control Limit as a vertical line to the right of the histogram
bars and a Lower Control Limit to the left of the bars. Each Control Limit
would be represented by a vertical line. The code below does not include the
line necessary to plot a sample control limit.
# the histogram of the data
n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)
# add a 'best fit' line
y = matplotlib.matlab.normpdf(bins, average[i], std_dev[i])
l = matplotlib.matlab.plot(bins, y, 'r--')
matplotlib.matlab.set(l, 'linewidth', 2)
matplotlib.matlab.set(matplotlib.matlab.gca(), 'xlim', [199, 205])
matplotlib.matlab.xlabel(DataDescription[i])
matplotlib.matlab.ylabel('Number of Parts')
matplotlib.matlab.title(PartNum + " -- " + PartDesc)
matplotlib.matlab.show()
When I modify the code with the additional line to plot a Lower Control
Limit: 
# the histogram of the data
n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)
# add a 'best fit' line
y = matplotlib.matlab.normpdf(bins, average[i], std_dev[i])
l = matplotlib.matlab.plot(bins, y, 'r--')
matplotlib.matlab.set(l, 'linewidth', 2)
matplotlib.matlab.set(matplotlib.matlab.gca(), 'xlim', [199, 205])
matplotlib.matlab.xlabel(DataDescription[i])
matplotlib.matlab.ylabel('Number of Parts')
matplotlib.matlab.plot([201,201],[0,40],'k--')	<--- added this line to plot
a control limit
matplotlib.matlab.title(PartNum + " -- " + PartDesc)
matplotlib.matlab.show()
The x-axis limits are somehow automatically forced to something less than
that specified in the line: matplotlib.matlab.set(matplotlib.matlab.gca(),
'xlim', [199, 205]). The histogram appears as would be expected, but now I
cannot see my Control Limit (specified in the added line of code) as it
seems to be plotted off of the chart.
If I comment out the additional line (that plotted a vertical line as a
control limit), the x-axis limits return to normal, as expected (199 ->
205).
Why are the x-axis limits adjusted when I try to plot a vertical line as a
Control Limit?
Thanks in advance,
Dave Engelsma
From: John H. <jdh...@ac...> - 2004年01月22日 17:39:04
>>>>> "Jean-Baptiste" == Jean-Baptiste Cazier <jea...@de...> writes:
 Jean-Baptiste> Hi ! The more I look at matplotlib, the more nice
 Jean-Baptiste> feature I find. However there are more that I
 Jean-Baptiste> haven't found yet, eventhough they might be
 Jean-Baptiste> implemented. I would like to have a little more
 Jean-Baptiste> interactivity with the plot itself. By this I do
 Jean-Baptiste> not mean the interactivity with the python shell,
 Jean-Baptiste> but with the mouse: - Double click on the
 Jean-Baptiste> legend/axes/label allow it modification - Single
 Jean-Baptiste> Click on a drawn line give the properties of the
 Jean-Baptiste> function and/or location - In short, being able to
 Jean-Baptiste> treat elements of the figure as widgets - I reckon
 Jean-Baptiste> the whole figure is a DrawingArea and that might
 Jean-Baptiste> not be straight forward
 Jean-Baptiste> Of course just having a signal sent with the
 Jean-Baptiste> propoerties of the curves would be good enough
 Jean-Baptiste> Are more people interested in that ?
It's not something I need in my own work, but I think it would be a
good addition to matplotlib and I'd be happy to include it. To that
end, I wrote some demo code to get you started! I implemented an
object picker (currently only for tick labels and lines but this can
easily be extended to include the other elements of the figure).
I also wrote the start of a line properties dialog. It should be
straight forward to extend to incorporate the other line properties,
(markeredgecolor, etc...) and then to do the same for a text
properties dialog, etc....
I needed to add a few things to matplotlib to make this easier, so
you'll need to grab the snapshot at 
 http://nitace.bsd.uchicago.edu:8080/files/share/matplotlib-0.42a.tar.gz
and see the file examples/object_picker.py. 
Good luck!
John Hunter
From: John H. <jdh...@ac...> - 2004年01月22日 12:46:13
>>>>> "John" == John Hunter <jdh...@ac...> writes:
 John> Your paths to the GTK runtime library are not set properly.
 John> Check out
Alternatively, you should be able to use the WX backend with the
enthought edition of python with no extra installation. Just
 import matplotlib
 matplotlib.use('WX')
 from matplotlib.matlab import plot, show
 plot([1,2,3])
 show()
Good luck,
John Hunter
From: John H. <jdh...@ac...> - 2004年01月22日 08:36:31
>>>>> "David" == David Nordquest <Nor...@ga...> writes:
 David> I've just installed Matplotlib with the 2.3 version of
 David> Python packaged by Enthought & believe I followed the
 David> instructions on the Matplotlib web page. I am getting the
 David> following error message:
Hi David,
Your paths to the GTK runtime library are not set properly. Check out
 http://matplotlib.sourceforge.net/installing.html
and the following pygtk FAQ entry addresses the PATH issue at length
 http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq21.012.htp
Should cure what ails you,
John Hunter
From: Jean-Baptiste C. <jea...@de...> - 2004年01月22日 08:05:08
Hi !
The more I look at matplotlib, the more nice feature I find.
However there are more that I haven't found yet, eventhough they might
be implemented. I would like to have a little more interactivity with
the plot itself. By this I do not mean the interactivity with the python
shell, but with the mouse:
- Double click on the legend/axes/label allow it modification
- Single Click on a drawn line give the properties of the function=20
and/or location
- In short, being able to treat elements of the figure as widgets
- I reckon the whole figure is a DrawingArea and that might not be
straight forward
Of course just having a signal sent with the propoerties of the curves
would be good enough
Are more people interested in that ?
Takk
Kve=C3=B0ja
Jean-Baptiste
From: Randy H. <he...@iu...> - 2004年01月22日 03:06:19
Dave, 
Are you sure you installed pygtk as mentioned at
http://matplotlib.sourceforge.net/backends.html ?
You might print out your sys.path to verify.
--Randy
> -----Original Message-----
> From: mat...@li... [mailto:matplotlib-
> use...@li...] On Behalf Of David Nordquest
> Sent: Wednesday, January 21, 2004 9:48 PM
> To: mat...@li...
> Subject: [Matplotlib-users] Gobject missing
> 
> I've just installed Matplotlib with the 2.3 version of Python packaged
> by Enthought & believe I followed the instructions on the Matplotlib
web
> page. I am getting the following error message:
> 
> IDLE 1.0
> >>> from matplotlib.matlab import *
> 
> Traceback (most recent call last):
> File "<pyshell#0>", line 1, in -toplevel-
> from matplotlib.matlab import *
> File "D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\matlab.py",
> line 121, in -toplevel-
> from axes import Subplot, Axes
> File "D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\axes.py",
> line 119, in -toplevel-
> import backends
> File
>
"D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\backends\__init__.py"
,
> line 9, in -toplevel-
> from backend_gtk import AxisText, Figure, FigureManager, \
> File
> "D:\PROGRA~1\PYTHON23\Lib\site-
> packages\matplotlib\backends\backend_gtk.py",
> line 13, in -toplevel-
> import gobject
> ImportError: DLL load failed: One of the library files needed to run
> this application cannot be found.
> >>>
> 
> I'd be grateful for any suggestions.
> 
> Dave
> 
> 
> 
> 
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: David N. <Nor...@ga...> - 2004年01月22日 02:47:58
I've just installed Matplotlib with the 2.3 version of Python packaged 
by Enthought & believe I followed the instructions on the Matplotlib web 
page. I am getting the following error message:
IDLE 1.0
 >>> from matplotlib.matlab import *
Traceback (most recent call last):
 File "<pyshell#0>", line 1, in -toplevel-
 from matplotlib.matlab import *
 File "D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\matlab.py", 
line 121, in -toplevel-
 from axes import Subplot, Axes
 File "D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\axes.py", 
line 119, in -toplevel-
 import backends
 File 
"D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\backends\__init__.py", 
line 9, in -toplevel-
 from backend_gtk import AxisText, Figure, FigureManager, \
 File 
"D:\PROGRA~1\PYTHON23\Lib\site-packages\matplotlib\backends\backend_gtk.py", 
line 13, in -toplevel-
 import gobject
ImportError: DLL load failed: One of the library files needed to run 
this application cannot be found.
 >>>
I'd be grateful for any suggestions.
Dave
From: John H. <jdh...@ac...> - 2004年01月20日 18:27:06
What's new in matplotlib 0.41
 http://sourceforge.net/projects/matplotlib
Pcolor optimizations
 Several optimizations have improved the performance of pcolor across
 all backends, 4x performance boost on the GTK backend. Still, slow,
 but getting tolerable.
PS save from GTK backend
 An alpha version of the PS export functionality from the GTK
 backend. Mostly works with a few known problems. You can simply
 call savefig('somefile.ps') or use the PS extension when saving from
 the GUI. [Matthew - still haven't gotten to the problems you
 reported but it's still on the list of things to do!]
Bug fixes
 Fixed bugs in semilogy and in setting dashes under some versions of
 Numeric
bar takes (optional) multiple color args
 You can now pass bar a len(x) list of color args to have bars with
 different colors.
Enjoy!
John Hunter 
From: John H. <jdh...@ac...> - 2004年01月20日 17:48:03
>>>>> "Jean-Baptiste" == Jean-Baptiste Cazier <jea...@de...> writes:
It's a bug that somehow escaped our poor-man's regression testing
suite.
line 2007 in /usr/lib/python2.2/site-packages/matplotlib/axes.py
should read
 l = self.plot(*args, **kwargs)
 ^
not 
 l = selfplot(*args, **kwargs)
Thanks for the report!
JDH
From: Jean-Baptiste C. <jea...@de...> - 2004年01月20日 16:55:28
Saell
I have got problem using semilogy while semilogx works fine
I with matplotlib with python2 on RedHat 9.0 default setup
Any idea of what is going wrong ?
Below is the code I use in the interactive2 mode:
Takk
Kve=C3=B0ja
Jean-Baptiste
Welcome to matplotlib.
 help(matplotlib) -- shows a list of all matlab compatible commands
provided
 help(plotting) -- shows a list of plot specific commands
>>> import matplotlib
>>> from matplotlib.matlab import *
pygtk.require() must be called before importing gtk
matplotlib requires pygtk-1.99.16 or greater -- trying anyway. Please
hold on
>>> from matplotlib.backends.backend_gtk import ShowOn
>>> ShowOn().set(1) # turning on interactive mode
>>> dt=3D0.01
>>> t=3Darange(dt,10.0,dt)
>>> semilogy(t,t)
Traceback (most recent call last):
 File "<<console>>", line 1, in ?
 File "/usr/lib/python2.2/site-packages/matplotlib/matlab.py", line
829, in semilogy
 try: ret =3D gca().semilogy(*args, **kwargs)
 File "/usr/lib/python2.2/site-packages/matplotlib/axes.py", line 2007,
in semilogy
 l =3D selfplot(*args, **kwargs)
NameError: global name 'selfplot' is not defined
>>> semilogx(t,t)
[<matplotlib.lines.Line2D instance at 0x8516034>]
>>>=20
From: John H. <jdh...@ac...> - 2004年01月18日 18:55:26
>>>>> "Steve" == Steve Chaplin <ste...@ya...> writes:
 Steve> When using the matlab interface (with the default GTK+
 Steve> backend), matlab.title() sets the current axis title, but
 Steve> can you set the window title - it defaults to "Figure 1"?
 Steve> -- Steve
In the matlab interface there is a function called
_get_current_fig_manager, which I didn't intend for public consumption
but perhaps I should remove the leading underscore and make it
'public'
The FigureManager class in backend_bases.py is used by backend
implementations. For the GTK backend, it contains a window attribute
with is a gtk.Window. You can change the title by doing
 figManager = _get_current_fig_manager()
 figManager.window.set_title('My title')
or call any of the other methods defined for gtk.Window
 http://www.gnome.org/~james/pygtk-docs/class-gtkwindow.html
For the wx backend there is a 'frame' attribute that you can use to
control the wx frame.
In the next release, I'll make a public version of this function.
JDH
From: Yann Le Du <yan...@no...> - 2004年01月18日 10:00:29
On 2004年1月17日, John Hunter wrote:
> and use of the division / operator with Numeric arrays. For that
> reason I usually try and write
> 
> 
> dashes = dpi/72.0*dash_list
> 
> or 
> 
> dashes = dash_list*(dpi/72.0)
> 
> Apparently I forgot this time. Try the above and see if they help.
> Please let me know.
Yes, it now works fine, thank you !
Y
From: Steve C. <ste...@ya...> - 2004年01月18日 05:32:05
When using the matlab interface (with the default GTK+ backend),
matlab.title() sets the current axis title, but can you set the window
title - it defaults to "Figure 1"?
-- 
Steve
From: John H. <jdh...@ac...> - 2004年01月18日 00:04:38
>>>>> "Yann" == Yann Le Du <yan...@no...> writes:
 Yann> Hello, I've just discovered matplotlib-0.40 (with linux),
 Yann> and going through the tutorial, I get an error (pasted at
 Yann> the end of email) when using dashes in the "Multiple lines
 Yann> with one plot command" example.
This script runs on my system
 from matplotlib.matlab import *
 t = array([0,1,2,3], Float)
 plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
 show()
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtk.py in 
set_dashes(self, dash_offset, dash_list)
 175 dpi = self.drawable.dpi.get()
 176 if dash_list is not None:
--> 177 dashes = dash_list*dpi/72.0
 178 self.gdkGC.line_style = gdk.LINE_ON_OFF_DASH
 179 dl = [int(math.ceil(val)) for val in dash_list]
TypeError: unsupported operand type(s) for /: 'array' and 'float'
This looks a lot like a known bug with 
from __future__ import division 
and use of the division / operator with Numeric arrays. For that
reason I usually try and write
 dashes = dpi/72.0*dash_list
or 
 dashes = dash_list*(dpi/72.0)
Apparently I forgot this time. Try the above and see if they help.
Please let me know.
John Hunter
From: Yann Le Du <yan...@no...> - 2004年01月17日 21:58:24
Hello,
Yet another question : has anyone managed to make an interactive 
matplotlib session from inside the IPython shell ?
Y
From: Yann Le Du <yan...@no...> - 2004年01月17日 19:21:02
Hello,
I've just discovered matplotlib-0.40 (with linux), and going through the
tutorial, I get an error (pasted at the end of email) when using dashes in
the "Multiple lines with one plot command" example.
If instead of putting :
plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
I put :
plot(t, t, 'r-', t, t**2, 'bs', t, t**3, 'g^')
it works fine.
Maybe someone can help ?
Y
========
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtk.py in 
set_dashes(self, dash_offset, dash_list)
 175 dpi = self.drawable.dpi.get()
 176 if dash_list is not None:
--> 177 dashes = dash_list*dpi/72.0
 178 self.gdkGC.line_style = gdk.LINE_ON_OFF_DASH
 179 dl = [int(math.ceil(val)) for val in dash_list]
TypeError: unsupported operand type(s) for /: 'array' and 'float'
From: John H. <jdh...@ac...> - 2004年01月16日 04:10:07
>>>>> "matthew" == matthew arnison <ma...@ca...> writes:
 matthew> Hi, Currently matplotlib outputs postscript graphs which
 matthew> have no bounding box set. This means that by default they
 matthew> fill the whole page. If you want to include several plots
 matthew> in the same page in a document (because you generated
 matthew> them separately, or because the subplot output is a bit
 matthew> messy) then you have to manually crop each postscript
 matthew> graph. (Atleast that is my experience with LaTeX via lyx,
 matthew> Word is presumably similar.)
Hi Matthew, thanks for keeping the flame under my butt re EPS. This
is something that has come up a number of times and isn't hard to
implement. I just haven't taken the time to do it. Work has kept me
pretty busy the last two weeks.
There was a discussion on this mailing list some time ago where
several workarounds were discussed - sourceforge archives are
currently down or I'd post a link. I use the following: PS can be
included directly in LaTeX and sized
 \usepackage[dvips]{graphics}
 \newcommand{\dofig}[2]
 {\center{\scalebox{#1}{\includegraphics*{#2}}}} 
 \begin{figure}[t]
 \dofig{0.5}{somefile.ps}
 \caption{\footnotesize Insert your figure caption here} 
 \label{fig:figref}
 \end{figure}
0.5 is a scaling arg. Don't know how to do it in lyx though.
Others use ps2eps or ps2epsi.
But I can get the eps thing done with little effort -- I already know
the bounding box, it's just a matter of detecting the extension and
adding one line of code to the PS output. 
Stay tuned!
John Hunter
From: matthew a. <ma...@ca...> - 2004年01月15日 23:53:57
Hi,
Currently matplotlib outputs postscript graphs which have no bounding box
set. This means that by default they fill the whole page. If you want to
include several plots in the same page in a document (because you
generated them separately, or because the subplot output is a bit messy)
then you have to manually crop each postscript graph. (Atleast that is my 
experience with LaTeX via lyx, Word is presumably similar.)
I tried a few tools to fix this. I finally found bbfig:
http://rpmfind.net/linux/RPM/contrib/noarch/noarch/bbfig-1.14-2.noarch.html
which correctly calculates the bounding box for an arbitrary
postscript file.
As hinted by this page:
http://www.mcs.kent.edu/mcsinfo/compsys/faq/cmds/bbfig.html
you can do
bbfig yourfile.ps | ghostview -
to see the bounding box visually. But /usr/doc/bbfig-1.14/README.RPM
says you can also do
bbfig myfigure.ps | gs -q -dNODISPLAY -
then add it output to the top of the ps file to have it be correctly
cropped.
bbfig is coded in postscript! But I thought you might be interested
in case you want to fix matplotlib so that it outputs correctly
bounded (e)ps files by default.
Cheers,
Matthew.
From: Steve C. <ste...@ya...> - 2004年01月10日 06:58:26
Whenever I run 'cvs update' I always get a long list of '?' status files
like
? docs/matplotlib.afm.html
? docs/matplotlib.artist.html
...
? htdocs/backends.html
? htdocs/classdocs.html
...
? htdocs/screenshots/axes_demo_large.png
? htdocs/screenshots/axes_demo_small.png
...
? matplotlib/__init__.pyc
? matplotlib/_matlab_helpers.pyc
...
CVS uses the '?' label for files in my working directory which do not
correspond to anything in the source repository.
These files, for example the .pyc files, are not source files, they are
generated from the source files by the build process.
CVS by default knows that it should ignore files such as *.o and *.exe.
It can be told to ignore additional files in a directory by creating the
file .cvsignore in the relevant directory and listing the files to
ignore (either by name or using wildcards).
So to remove the warnings listed above, you could set up the files
docs/.cvsignore:
*.html
htdocs/.cvsignore:
*.html
htdocs/screenshots/.cvsignore:
*.png
matplotlib/.cvsignore:
*.pyc
-- 
Steve
From: John H. <jdh...@ac...> - 2004年01月09日 14:54:15
>>>>> "Birger" == <bir...@te...> writes:
 Birger> Hi. I stumbled over your matplotlib module, and it's
 Birger> exactly what I have been looking for being a long time
 Birger> matlab user.
 Birger> Since sourceforge is down, I have a question which I hope
 Birger> you'll answer, but I fully understand if you don't have
 Birger> the time
No problem, when it comes back up you may want to join the mailing
list
 Birger> (using GTK, latest version on winXP) creating a simple
 Birger> script like this:
 Birger> from matplotlib.matlab import * vector = [1, 2, 3, 4, 5,
 Birger> 3, 2, 1] plot(vec) savefig(r'c:\test.jpg')
 Birger> This does not save the file, but calling 'show()' will
 Birger> show the file and then save the file. Shouldn't it be
 Birger> possible to save a fig without calling show? I have plans
 Birger> to use this in a cgi application, and hope I can do it
 Birger> this way.
There are three ways to do this currently. Are you planning on
running your web server under windows or linux or other? The platform
you are on will determine which route is easiest.
 1) On Linux/UNIX, Run matplotlib in a X virtual frame buffer (Xvfb)
 which is a virtual X windows. There you can save the figures in
 the GTK backend with no window ever popping up. I'm going to do
 some more investigating to see if pygtk is capable of drawing
 with no window in the absence of Xvfb (in which the window is
 simulated). I am using matplotlib in a web application server so
 I can provide some example code.
 2) Alternatively, you can use the GD backend, which is designed to
 do offline drawing. I haven't succeeded in getting gdmodule
 compiled for windows, but I know it's doable. I just haven't
 pressed the issue because so far noone has wanted it.
 3) Finally, a hack solution which would work under windows is to use
 the ps backend to generate the plots (this requires only Numeric
 and produces high quality output) and use another module like PIL
 to convert them to PNG or JPG to serve over the web. This is in
 my opinion the least desirable solution, but one you may want to
 consider if you must work on win32 and can't get GD running. 
 Birger> If I were better at programming, I would have written a
 Birger> PIL module for matplotlib, since matplotlib is a module I
 Birger> will use extensively in the future
I would like to have a PIL and python Tk backend. So when you get
you're programming chops up to speed, definitely think of us!
John Hunter
From: John H. <jdh...@ac...> - 2004年01月08日 23:23:16
>>>>> "matthew" == matthew arnison <ma...@ca...> writes:
 matthew> I think you need to use threads. I'm only just learning
 matthew> how to use them myself. But have a look at:
Have you looked at examples/interactive.py and
examples/interactive2.py? 
JDH
From: matthew a. <ma...@ca...> - 2004年01月08日 23:14:55
I think you need to use threads. I'm only just learning how to use them 
myself. But have a look at:
http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq20.001.htp
and play with something like:
#!/usr/bin/python
# Trying to figure out how to use threads.
# This doesn't work, but I feel it is close.
import time
import thread
from matplotlib.matlab import *
import gtk
gtk.threads_init()
# gtk.mainloop()
figure(1)
plot([1,2,3,4,5,2])
print "figure 1"
gtk.threads_enter()
thread.start_new_thread(show, ())
gtk.threads_leave() 
time.sleep(2)
figure(2)
plot([1,2,3,4,5,2,10])
print "figure 2"
gtk.threads_enter()
thread.start_new_thread(show, ())
gtk.threads_leave() 
time.sleep(2)
...
Cheers,
Matthew.
On Thu, 8 Jan 2004, Flavio C. Coelho wrote:
> Hi,
> 
> I have a problem with matplotlib:
> 
> My program is an interective simulator which needs to re-plot results
> multiple times at the users request.
> 
> But after I issue show() I cannot generate other plots.
> 
> what can I do to circumvent this?
> 
> thanks in advance,
> 
> Flávio Codeço Coelho,
> PhD
> Programa de Computação
> Científica
> Fundação Oswaldo Cruz
> Rio de Janeiro -- Brasil
> 
> 
> ________________________________________________________________________
> 
From: John H. <jdh...@ac...> - 2004年01月08日 18:04:36
>>>>> "Flavio" == Flavio C Coelho <fcc...@fi...> writes:
 Flavio> Hi, I have a problem with matplotlib:
 Flavio> My program is an interective simulator which needs to
 Flavio> re-plot results multiple times at the users request.
 Flavio> But after I issue show() I cannot generate other plots.
 Flavio> what can I do to circumvent this?
If you are using matplotlib in an application, as it sounds like you
are, you don't need to call show at all. You control the GUI mainloop
yourself. See, for example, examples/embedding_in_gtk2.py or
examples/embedding_in_wx.py.
Do the application users need to use the matlab interface plotting
commands themselves, or are they simply interacting with the plots
using widgets you provide? If the latter, I suggest not using the
matlab interface at all, and importing Figure from
backends.backend_gtk or backends.backend_wx. and Subplot from axes
and controlling the plots using the object oriented API.
All of the matlab plotting commands are simply thin wrappers to the
Axes API (hist, psd, scatter, etc... are all accessible from the axes
instance)
Eg,
 subplot(111)
 plot(t,s)
 xlabel('hi mom')
 set(gca(), 'xlim', [0,10])
is
 fig = Figure(figsize=(5,4), dpi=100)
 ax = Subplot(f, 111)
 ax.plot(t,s)
 ax.set_xlabel('hi mom')
 ax.set_xlim([0,10])
You can force a redraw of the figure by doing
 fig.draw()
The moral of the story: don't call show for applications; that is for
python batch scripts.
Will this work for you?
Of course if you have a shell and you want to allow your users to
interact with the plot using the matlab interface, you'll need a
different approach. Something along the lines of
examples/interactive2.py, which is an interactive shell for pygtk. I
haven't worked with custom shells for wx, but interactive control of
matplotlib figures works in PyCrust with the CVS version of matplotlib.
Make sure you are using the CVS version of matplotlib as a number of
critical bugs in the WX backend that affect interactive use have been
fixed since the 0.40 release. Note the API for working interactively
has changed. You now do
 import matplotlib
 matplotlib.use('WX')
 matplotlib.interactive(True)
Ditto for GTK.
Here's a snapshot of the latest version in case your CVS mirrors are
behind:
 http://nitace.bsd.uchicago.edu:8080/files/share/matplotlib-0.41c.tar.gz
Hope this helps!
John Hunter
From: matthew a. <ma...@ca...> - 2004年01月07日 23:27:47
Attachments: subplot_demo.py
That's great.
It's interesting to read your discussion of backend switching issues. It's
something that gnuplot deals with very poorly indeed, which is what
motivated me to seek out matplotlib. I.e. in gnuplot you can freely switch 
backends, but the line styles are set differently (and sometimes very 
awkwardly: X resources for instance!) for each backend.
Anyway, I tried out what's in CVS. As you say, it mostly works. I had
trouble though with my (rather complicated) 2x2 subplot script. The worst
problem is that when I use the Save button to save as .ps, the output is
sized too large to fit on the page: only the lower left subplot is fully
visible.
There are various other layout problems, which I managed to reproduce in
the attached hacked version of subplot_demo.py, but unfortunately I
couldn't reproduce the problem above outside of my script.
Other problems:
* when saving from the GTK window into a .ps file, the lines are not 
clipped by the edge of the plot area: see the top left plot in the 
attached code
* xaxis and yaxis labels often land on top of adjacent subplot titles and
plot areas in savefig('blah.ps') output (I've had trouble with this in the 
-dPS output too)
Also, I tried to save as file.eps, but the save dialog complained and only
accepts .ps. Presumably this is an easy fix?
Cheers,
Matthew.
On Wed, 7 Jan 2004, John Hunter wrote:
> I've made some changes to the GTK backend that enable save to a ps
> figure, either by calling
> 
> savefig('somefile.ps')
> 
> or using a file with the ps extension from the save figure dialog.
> 
> It's not too pretty internally but it works (more or less). Consider
> this a preliminary functional implementation with known bugs that will
> be hammered out later.
> 
> The problem in implementing this is that the AxisText instances (axis
> and tick labels, title) are backend dependent. As Jeremy noted when
> he did the wx backend, this is different than the way other objects
> (lines, patches) are handled. With some refactoring this can be made
> more elegant.
> 
> The other problem is that the default fonts are different between the
> backends, so you'll get a lot of warnings like "Falling back on
> default font". This is another problem we need to clear up -- ie, we
> need a set of shared fontnames between backends.
> 
> Finally, a 'gotcha' that you need to watch out for is that text
> references in scripts will be destroyed by calling a postscript
> savefig (because of the way text instance conversions are handled).
> 
> So if you did
> 
> ax = subplot(111)
> plot(something)
> labels = ax.get_xticklabels()
> savefig('somefile.ps')
> set(labels, 'color', 'r')
> savefig('somefile.png')
> 
> The color change would not take effect because the text references
> have been changed. Moral of story: do not change figure text
> properties after calling savefig for a ps figure with text instances
> obtained before the savefig call. 
> 
> Other than that it should work. Let me know. I've updated CVS but be
> forewarned: CVS mirrors sometime take a while to update.
> 
> JDH
> 
2 messages has been excluded from this view by a project administrator.

Showing results of 57

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