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




Showing 10 results of 10

From: John H. <jdh...@ac...> - 2004年11月15日 21:17:22
>>>>> "Chris" == Chris Barker <Chr...@no...> writes:
 Chris> no, I was a bit wrong. Python functions always return one
 Chris> object, and when it appears that you are returning multiple
 Chris> objects, you are really returning a single tuple with
 Chris> multiple objects in it. Have I got it right this time?
Sounds right to me. Your answer does point to the danger of using
nargout in python
 ret = somefunc()
 i,j = ret 
If somefunc is relying on nargout, it will botch it.
I think the only sane use for nargout in python is in auto-conversion
scripts, and then with appropriate warnings. 
Thanks said, I would still like to have it, for that reason.
JDH
From: Chris B. <Chr...@no...> - 2004年11月15日 20:45:51
John Hunter wrote:
> What do you mean that python functions always return a tuple? How
> about functions that return an int, or a string, or whatever? 
> 
>>>>def func(): return 1
>>>>type(func())
> 
> <type 'int'>
> 
> Do you mean that python functions that return tuples always return
> tuples <wink> ?
no, I was a bit wrong. Python functions always return one object, and 
when it appears that you are returning multiple objects, you are really 
returning a single tuple with multiple objects in it. Have I got it 
right this time?
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
 		
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: John H. <jdh...@ac...> - 2004年11月15日 18:56:05
>>>>> "Chris" == Chris Barker <Chr...@no...> writes:
 Chris> Darren Dale wrote:
 >> >I guess there is no way in Python of emulating >Matlab"s
 >> detection of the number of output arguments. I just got a
 >> response from c.l.p. Somebody remembered seeing this at ASPN:
 >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742
 >> expecting() is the workhorse, equivalent to Matlab's nargout:
 Chris> Very cool. but I'd caution against using it. I'd much
 Chris> rather see matplotlib be pythonesque than an exact
 Chris> duplicate of MATLAB. This is NOT pythonesque!
I tend to agree with the caution against using it. But it would be
useful in some contexts, like converting existing matlab m-files to
python/numeric/numarray, the desire for which has occurred in some
contexts. Last time the discussion came up, the lack of nargout was
raised as a problem for any converter code.
 Chris> Precisely speaking, python functions ALWAYS return just one
 Chris> object: A tuple. That tuple can contain any number of other
 Chris> objects, and sequence unpacking means it can look like
 Chris> you're returning multiple values, but you're not
 Chris> really. i.e.
What do you mean that python functions always return a tuple? How
about functions that return an int, or a string, or whatever? 
>>> def func(): return 1
>>> type(func())
<type 'int'>
Do you mean that python functions that return tuples always return
tuples <wink> ?
JDH
From: Chris B. <Chr...@no...> - 2004年11月15日 18:28:10
Darren Dale wrote:
> >I guess there is no way in Python of emulating
> >Matlab"s detection of the number of output arguments.
> 
> I just got a response from c.l.p. Somebody remembered seeing this at ASPN:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742
> 
> expecting() is the workhorse, equivalent to Matlab's nargout:
Very cool. but I'd caution against using it. I'd much rather see 
matplotlib be pythonesque than an exact duplicate of MATLAB. This is NOT 
pythonesque!
Precisely speaking, python functions ALWAYS return just one object: A 
tuple. That tuple can contain any number of other objects, and sequence 
unpacking means it can look like you're returning multiple values, but 
you're not really. i.e.
def test():
	return (1,2,3) # same as return 1,2,3
# now call it:
a,b,c = test()
(a,b,c) = test()
x = test(); a,b,c = x
x = test(); a = x[0]; b = x[1]; c = x[2]
# Are all equivalent
if one uses the last two forms, expecting() will break.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
 		
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Darren D. <dd...@co...> - 2004年11月15日 06:27:08
Hi John,
> >> I guess there is no way in Python of emulating Matlab"s
> >> detection of the number of output arguments.
>
> Darren> I just got a response from c.l.p. Somebody remembered
> Darren> seeing this at ASPN:
> Darren> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742
>
> Darren> expecting() is the workhorse, equivalent to Matlab's
> Darren> nargout:
>
> Darren> import inspect,dis
>
> Hi Darren,
>
> Wow, I didn't know this was possible in python. Does it work under
> python2.2?
The ASPN page says it has been tested on 2.3.3. I dont have a 2.2 installation 
handy to check it.
>
> Perhaps you would like to write up nargin and nargout function with
> some doc strings and send them my way? I could add them to the matlab
> interface. But we need to make sure they are 2.2 compliant.
I will give it a shot in my free time, but without getting into it, my next 
month is pretty full.
>
> As an aside, do we need nargout to make "find" work like matlab's?
> Isn't it enough just to check the shape of the input array and
> processing it one way for 1D arrays and another way for 2D arrays?
>
The problem is that mlab.find() is currently a thin wrapper around a numeric 
or numarray method, which only works for 1D arrays. ravelling the arrays 
passed to find would make it easy to continue using the method called by 
find(), but I had trouble figuring out how to process the 1xM results of that 
method back into an NxM or MxN array that could be used to index an N-D 
array. 
It would be nice to be able to address Numeric and numarray with a single 
index. Matlab does this. For example, if a=array([[1,2],[3,4]]), a[0] would 
be 1, a[1] would be 3 (Matlab's convention, again if memory serves.) 
-- 
Darren
From: John H. <jdh...@ac...> - 2004年11月15日 04:30:14
>>>>> "Darren" == Darren Dale <dd...@co...> writes:
 >> I guess there is no way in Python of emulating Matlab"s
 >> detection of the number of output arguments.
 Darren> I just got a response from c.l.p. Somebody remembered
 Darren> seeing this at ASPN:
 Darren> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742
 Darren> expecting() is the workhorse, equivalent to Matlab's
 Darren> nargout:
 Darren> import inspect,dis
Hi Darren,
Wow, I didn't know this was possible in python. Does it work under
python2.2?
Perhaps you would like to write up nargin and nargout function with
some doc strings and send them my way? I could add them to the matlab
interface. But we need to make sure they are 2.2 compliant.
As an aside, do we need nargout to make "find" work like matlab's?
Isn't it enough just to check the shape of the input array and
processing it one way for 1D arrays and another way for 2D arrays?
 
Cheers,
JDH
From: John H. <jdh...@ac...> - 2004年11月15日 04:17:59
>>>>> "Jos=E9" =3D=3D Jos=E9 Alexandre Nalon <na...@te...> writes:
 Jos=E9> Hello, I think I've found a bug in mathtext - sorry if this
 Jos=E9> appeared before, I couldn't find it in the list archives.
 Jos=E9> When I try:
 Jos=E9> xlabel(r"$-(\Omega_a^' + \Omega_a)$")
 Jos=E9> I don't get what I expected. The label shows -\Omega_a and
 Jos=E9> stops there. Further tests showed that, whenever I try a
 Jos=E9> single quote in a mathtext string, the text is not rendered
 Jos=E9> from the quote on.
 Jos=E9> This might not be a bug, I might be doing something
 Jos=E9> wrong. If this is the case, please tell me how to do it
 Jos=E9> right.
I don't believe your use of ' is valid TeX. Try
Omega_a^\prime
 Jos=E9> Thanks in advance.
Sure thing,
JDH
From: Darren D. <dd...@co...> - 2004年11月15日 03:56:45
> xlabel(r"$-(\Omega_a^' + \Omega_a)$")
>
> I don't get what I expected. The label shows -\Omega_a and stops
> there. Further tests showed that, whenever I try a single quote
> in a mathtext string, the text is not rendered from the quote on.
>
> This might not be a bug, I might be doing something wrong. If
> this is the case, please tell me how to do it right.
>
try replacing ^' with ^\prime
Darren
From: <na...@te...> - 2004年11月15日 03:39:10
Hello,
I think I've found a bug in mathtext - sorry if this appeared
before, I couldn't find it in the list archives.
When I try:
xlabel(r"$-(\Omega_a^' + \Omega_a)$")
I don't get what I expected. The label shows -\Omega_a and stops
there. Further tests showed that, whenever I try a single quote
in a mathtext string, the text is not rendered from the quote on.
This might not be a bug, I might be doing something wrong. If
this is the case, please tell me how to do it right.
Thanks in advance.
---
José Alexandre Nalon
na...@te...
From: Darren D. <dd...@co...> - 2004年11月15日 03:36:41
 >I guess there is no way in Python of emulating
 >Matlab"s detection of the number of output arguments.
I just got a response from c.l.p. Somebody remembered seeing this at ASPN:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742
expecting() is the workhorse, equivalent to Matlab's nargout:
import inspect,dis
def expecting():
 """Return how many values the caller is expecting"""
 f = inspect.currentframe()
 f = f.f_back.f_back
 c = f.f_code
 i = f.f_lasti
 bytecode = c.co_code
 instruction = ord(bytecode[i+3])
 if instruction == dis.opmap['UNPACK_SEQUENCE']:
 howmany = ord(bytecode[i+4])
 return howmany
 elif instruction == dis.opmap['POP_TOP']:
 return 0
 return 1
def cleverfunc():
 howmany = expecting()
 if howmany == 0:
 print "return value discarded"
 if howmany == 2:
 return 1,2
 elif howmany == 3:
 return 1,2,3
 return 1
def test():
 cleverfunc()
 x = cleverfunc()
 print x
 x,y = cleverfunc()
 print x,y
 x,y,z = cleverfunc()
 print x,y,z
test()

Showing 10 results of 10

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