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




Showing results of 383

<< < 1 .. 14 15 16 (Page 16 of 16)
From: Kurt F. <kur...@ho...> - 2009年06月01日 21:37:30
I am searched the mailing list and web without success with this problem. I am getting unexpected behaviour when using savefig in the eps format.
The pdf renders the figure as it appears in the plot figure however the alpha for the patches is lost when saving as eps (see code below).
Any help would be greatly appreciated.
Kind Regards,
Kurt
matplotlib '0.98.5.2'
python 2.6.2
ubuntu 9.04
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from numpy import *
from pylab import plot, show, grid, xlabel, ylabel, axhspan, axvspan, savefig
from scipy.optimize import leastsq, fsolve
sample_day = array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,\
22,23,24,25,26,27,28,29,30,31])
sample_measurement = array([0,0,0,0,0,0,0,0.02190,0.04910,0.06540,0.08170,\
0.10930,0.13650,0.15850,0.20200,0.33320,0.52000,0.66110,0.78710,0.85250,\
0.89070,0.91270,0.92890,0.94560,0.96180,0.97280,0.97280,0.97810,0.97810,\
0.98370,0.98370,0.98370])
## Logistic function
logistic = lambda a, x: (a[0] + (a[1]-a[0])/(1 + (a[2]/x)**a[3]))
## Linear first order function
linear_first_order = lambda a, x: (a[0]*x + a[1])
## Column leach model function
column_leach_model = lambda a, x: (array([zeros(len(x)), linear_first_order(a[0:2],x), logistic(a[2:len(a)],x)]).max(0))
## Error function
e = lambda a, x, y: (column_leach_model(a,x)-y)
## Initial conditions
a0 = [0.022,-0.13, 0.0,0.987,15.5,10.3]
## Least-squares regression
a, cov_x, infodict, mesg ,success = leastsq(e, a0, args=(sample_day,sample_measurement), full_output=1)
## Intercept of the linear and logistic functions
intercept = lambda x, a: (logistic(a[2:len(a)],x) - linear_first_order(a[0:2],x))
xint = fsolve(intercept, a[4], args=(a))
def plot_fit():
 # Create a time series data set to evaluate the regression model against 
 x0 = linspace(0,-a[1]/a[0])
 x1 = linspace(-a[1]/a[0], xint)
 x2 = logspace(log10(xint), log10(31.))
 xsample = array([x0,x1,x2]).flatten()
 # Evaluate the regression model
 y = column_leach_model(a, xsample)
 # Plot the experimental data and the regression model results
 plot(sample_day, sample_measurement, marker='o', linestyle='none') 
 xlabel("Duration [days]")
 ylabel("Fraction Recovered [-]")
 plot(xsample, y, linewidth=2)
 patch1 = axvspan(0, -a[1]/a[0], facecolor='.1', alpha=0.25)
 patch2 = axvspan(-a[1]/a[0], xint, facecolor='g', alpha=0.25)
 patch3 = axvspan(xint, 35, facecolor='b', alpha=0.25)
 grid("on")
 savefig('data_model.eps')
 savefig('data_model.pdf')
plot_fit()
show()
_________________________________________________________________
View photos of singles in your area Click Here
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT
From: lucab <l.b...@gm...> - 2009年06月01日 20:11:49
Mike,
thanks so much for the response. my intent is to build compound paths that
(ideally) include bezier curve approximations to circle segments and
straight-line elements. the final output will most likely be an SVG file so
it would be nice to keep the beziers. but since i'm new to matplotlib, scipy
and python in general this may be trying to bite off more than i can chew.
;)
lb
Michael Droettboom-3 wrote:
> 
> If your path has bezier curve segments, then, yes, PathPatch is the most 
> direct method (see the dolphin.py example). However, if you just need a 
> series of line segments, then Polygon is probably much simpler for 
> filling areas.
> 
> Mike
> 
> 
-- 
View this message in context: http://www.nabble.com/display-a-path--tp23805921p23820801.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Drain, T. R <the...@jp...> - 2009年06月01日 19:44:54
FYI I just went through this w/ an application of ours. There is no easy way to handle this. You can do this:
Display* disp = XOpenDisplay( 0 );
if ( ! disp )
{
 // no DISPLAY variable is set - no x connection
}
However, if the DISPLAY variable is set but doesn't point to a usable x-server (or it can't connect to the x-server), this will actually call halt/exit inside the X library. The X library has this coded as the standard error behavior. You can set a custom X11 IO error handler but it's kind of worthless because if the error handler ever returns, the X11 library will exit. The work around is to do a setjmp/longjump call in the error handler. 
Here's the resulting code we use to check for a valid x-server connection. We actually trap 3 different conditions (success, no display, display but can't connect). You modify this a little bit if you just wanted to check for a valid display.
====================================
#include <X11/Xlib.h>
#include <setjmp.h>
static jmp_buf s_displayJumpBuf;
static int s_xIOhandler( Display* disp )
{
 // Jump back to the status function.
 longjmp( s_displayJumpBuf, 1 );
 return 0;
}
int serverStatus()
{
 typedef int (*ErrorHandler)( Display* display );
 
 // Initial execution path. setjmp() returns 0 to begin with. If
 // XOpenDisplay fails and calls the error handler, then execution
 // will resume here but with a non-zero return value.
 if ( setjmp( s_displayJumpBuf ) == 0 )
 {
 // Set our handler and try to open the display.
 ErrorHandler prevHandler = XSetIOErrorHandler( s_xIOhandler );
 
 Display* disp = XOpenDisplay( 0 );
 // Restore the previous handler.
 XSetIOErrorHandler( prevHandler );
 // Success - valid X11 display.
 if ( disp )
 {
 return 0;
 }
 // DISPLAY env variable not set.
 return -1;
 }
 else
 {
 // X11 IO error indicates that a DISPLAY variable was set but
 // that it's invalid.
 return -2;
 }
}
> -----Original Message-----
> From: Christopher Barker [mailto:Chr...@no...]
> Sent: Monday, June 01, 2009 11:45 AM
> To: mat...@li...
> Subject: Re: [Matplotlib-users] Non-X11 fallback on import
> 
> Alexander Lamaison wrote:
> > I would like it to work
> > is to use the default backend if X is available and, otherwise, fall
> > back to using the Agg backend. How can I do this?
> 
> I had a similar need a good while back with wxPython. I found some C
> code on the net that tries to connect to an X server and fails
> gracefully if it can't. I also wrote a Python wrapper around it. I
> haven't used it for years, and can't even find it on my machine, but
> thanks to the glory of archives and google, here it is:
> 
> http://osdir.com/ml/python.wxpython/2004-03/msg00294.html
> 
> You'd use it like:
> 
> import matplotlib
> import isX
> 
> if isX.isX:
> matplotlib.use("wxGTK") or whatever..
> else:
> matplotlib.use("AGG")
> 
> 
> note that you can also just check and see if the "DISPLAY" environment
> variable is set, but that won't be as reliable.
> 
> However, as the whole user interaction has to be totally different, I
> wonder if you can't just have a different start-up script depending on
> whether they want to run the GUI version or not.
> 
> 
> -Chris
> 
> 
> 
> 
> --
> Christopher Barker, Ph.D.
> Oceanographer
> 
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
> 
> Chr...@no...
> 
> -----------------------------------------------------------------------
> -------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity
> professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp as they present alongside digital heavyweights like
> Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Christopher B. <Chr...@no...> - 2009年06月01日 18:42:44
Alexander Lamaison wrote:
> I would like it to work
> is to use the default backend if X is available and, otherwise, fall
> back to using the Agg backend. How can I do this?
I had a similar need a good while back with wxPython. I found some C 
code on the net that tries to connect to an X server and fails 
gracefully if it can't. I also wrote a Python wrapper around it. I 
haven't used it for years, and can't even find it on my machine, but 
thanks to the glory of archives and google, here it is:
http://osdir.com/ml/python.wxpython/2004-03/msg00294.html
You'd use it like:
import matplotlib
import isX
if isX.isX:
 matplotlib.use("wxGTK") or whatever..
else:
 matplotlib.use("AGG")
note that you can also just check and see if the "DISPLAY" environment 
variable is set, but that won't be as reliable.
However, as the whole user interaction has to be totally different, I 
wonder if you can't just have a different start-up script depending on 
whether they want to run the GUI version or not.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: pgb205 <pau...@op...> - 2009年06月01日 18:08:33
et say i have two arrays
time_array=[00:00:00,00:00:10...17:59:50,18:00:00]
and
data_array=[1,12..34,2]
both of them with the same number of elements.
I want to graph data_array on y axis vs time_array on x_axis.
However, I'm unable to do this using matplotlib because it complains
time_array is not in numeric form.
I guess I should do plot=(data_array) and somehow mark the x axis with
time_array data at periodic intervals. Any suggestion on how to mark x-axis
with times?
thanks
-- 
View this message in context: http://www.nabble.com/Labeling-X-axis-with-time-data-tp23819363p23819363.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Alexander L. <li...@la...> - 2009年06月01日 17:30:05
I have a script that uses matplotlib to plot graphs both displayed as
a GUI and as PDF documents. The script may need to be run from remote
terminals without X11-passthrough so they way I would like it to work
is to use the default backend if X is available and, otherwise, fall
back to using the Agg backend. How can I do this?
I've been trying to catch a RuntimeError and then retry with a
different backend but part of matplotlib remains loaded and won't let
me change backend:
try:
 import matplotlib.pyplot as plt
except RuntimeError:
 # retry import but without GUI capability
 import matplotlib
 plt.use('Agg')
 import matplotlib.pyplot as plt
Has anyone managed this?
Many thanks.
Alex
From: Michael D. <md...@st...> - 2009年06月01日 12:58:58
If your path has bezier curve segments, then, yes, PathPatch is the most 
direct method (see the dolphin.py example). However, if you just need a 
series of line segments, then Polygon is probably much simpler for 
filling areas.
Mike
lucab wrote:
> i apologize in advance for what is undoubtedly a silly question, but, having
> looked through the coding examples and the forum i am still a little
> confused...
>
> am i correct in understanding that the only way to draw / display a path on
> an axes is by converting it to a PathPatch and adding that to the axes?
>
> ideally i would like to display a PathPatch as well as parts of the path
> that surround it. to do this i would like to show the PathPatch with no edge
> and then also show part of the path (with no fill).
>
> thanks in advance,
>
> lb
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Michael D. <md...@st...> - 2009年06月01日 12:51:07
There's no easy way to do what you ask. You can, however, use math mode 
to get to those characters in STIX. For example, set mathtext.fontset 
to "stix" and then:
 r'$\mathcal{Caligraphic} \mathtt{Monospace}$'
Mike
Nicolas Pourcelot wrote:
> Thanks, it works well.
>
> However, I forgot that computer modern does not include accented 
> characters (unlike latin modern), so I eventually used Stix :
>
> mpl.rc('font', family = 'serif', serif = 'STIXGeneral')
>
> By the way, is there any way to use Stix for sans-serif as well, or 
> even cursive and monospace ? I don't know how to do that, since Stix 
> seems to contain all of them in a single file (STIXGeneral.ttf) ?
>
> Nicolas
>
>
> Michael Droettboom a écrit :
>> The name of the Computer Modern Roman font that ships with matplotlib 
>> is "cmr10", so
>>
>> mpl.rc('font', family = 'serif', serif = 'cmr10')
>>
>> should work.
>>
>> Mike
>>
>> Nicolas Pourcelot wrote:
>>> Hi,
>>>
>>> is there any way to use Computer Modern in any text in matplotlib ?
>>>
>>> In http://matplotlib.sourceforge.net/users/customizing.html, I read 
>>> the following :
>>>
>>> #font.serif : Bitstream Vera Serif, New Century Schoolbook, 
>>> Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 
>>> L, Times New Roman, Times, Palatino, Charter, serif
>>> #font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, 
>>> Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
>>> #font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, 
>>> cursive
>>> #font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, 
>>> Western, fantasy
>>> #font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus 
>>> Mono L, Courier New, Courier, Fixed, Terminal, monospace
>>> So, Computer Modern is not listed there.
>>>
>>> However, Computer Modern is used in mathtext, so I suppose there is 
>>> a way to use it also in plain text, but I can't figure it...
>>>
>>> I tried :
>>> /mpl.rc('font', family = 'serif', serif = 'computer modern roman')/
>>> but it did not work.
>>>
>>> Thanks a lot,
>>>
>>> Nicolas P.
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>> ------------------------------------------------------------------------------ 
>>>
>>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
>>> is a gathering of tech-side developers & brand creativity 
>>> professionals. Meet
>>> the minds behind Google Creative Lab, Visual Complexity, Processing, 
>>> & iPhoneDevCamp as they present alongside digital heavyweights like 
>>> Barbarian Group, R/GA, & Big Spaceship. 
>>> http://p.sf.net/sfu/creativitycat-com 
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>>
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
8 messages has been excluded from this view by a project administrator.

Showing results of 383

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