Re: [Matplotlib-users] Some remarks/questions about perceived slowness of matplotlib

2006-12-18 Thread David Cournapeau
David Cournapeau wrote:
> Eric Firing wrote:
>> There is a clip function in all three numeric packages, so a native 
>> clip is being used.
>>
>> If numpy.clip is actually slower than your version, that sounds like a 
>> problem with the implementation in numpy.  By all logic a single clip 
>> function should either be the same (if it is implemented like yours) 
>> or faster (if it is a single loop in C-code, as I would expect).  This 
>> warrants a little more investigation before changing the mpl code.  
>> The best thing would be if you could make a simple standalone numpy 
>> test case profiling both versions and post the results as a question 
>> to the numpy-discussion list.  Many such questions in the past have 
>> resulted in big speedups in numpy.
> I am much more familiar with internal numpy code than matplotlib's, so 
> this is much easier for me, too :)
>> One more thought: it is possible that the difference is because myclip 
>> operates on the array in place while clip generates a new array.  If 
>> this is the cause of the difference then changing your last line to 
>> "return a.copy()"  probably would slow it down to the numpy clip speed 
>> or slower.
> It would be scary if a copy of a 8008x256 array of double took 100 ms... 
> Fortunately, it does not, this does not seem to be the problem.
>
> cheers,
>
> David
Ok, so now, with my clip function, still for a 8000x256 double array: we 
have show() after imshow which takes around 760 ms. 3/5 are in 
make_image, 2/5 in the function blop, which is just an alias I put to 
measure the difference between axes.py:1043(draw) and image.py:173(draw) 
in the function Axis.draw (file axes.py):

 def blop(dsu):
 for zorder, i, a in dsu:
  a.draw(renderer)

 blop(dsu)

In make_image, most of the time is taken into to_rgba: almost half of it 
is taken in by the take call in the Colormap.__call__. Almost 200 ms to 
get colors from the indexes seems quite a lot (this means 280 cycles / 
pixel on average !). I can reproduce this number by using a small numpy 
test.

On my laptop (pentium M, 1.2 Ghz), make_image takes almost 85 % of the 
time, which seems to imply that this is where one should focus if one 
wants to improve the speed,

cheers,

David

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread Darren Dale
On Saturday 16 December 2006 20:00, Simson Garfinkel wrote:
> 1. I think that scientific notation should not be the default, unless
> numbers exceed 1E+7.

There are good reasons to use scientific notation for smaller numbers than 
10e+-7: We dont want neighboring tick labels to run into each other on the x 
axis, and we dont tick labels to run out of the window on the y axis. For 
examples, see the attachments at the bottom of this page: 
http://sourceforge.net/tracker/index.php?func=detail&aid=1196027&group_id=80706&atid=560720

Darren

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread Simson Garfinkel
It really depends on your audience as to whether or not 1,000,000  
through 9,000,000 is better displayed in scientific notation or not.  
For audiences that I frequently present to, any scientific notation  
is just unacceptable. You can add quantifiers (like KBps, MBps,  
GBps), but presenting something a 5e+5 Bps will just be lost.  You  
*might* get away with e+3, e+6, and e+9, but never the other e's.


On Dec 18, 2006, at 8:53 AM, Darren Dale wrote:

> On Saturday 16 December 2006 20:00, Simson Garfinkel wrote:
>> 1. I think that scientific notation should not be the default, unless
>> numbers exceed 1E+7.
>
> There are good reasons to use scientific notation for smaller  
> numbers than
> 10e+-7: We dont want neighboring tick labels to run into each other  
> on the x
> axis, and we dont tick labels to run out of the window on the y  
> axis. For
> examples, see the attachments at the bottom of this page:
> http://sourceforge.net/tracker/index.php? 
> func=detail&aid=1196027&group_id=80706&atid=560720
>
> Darren
>


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Calling matplotlib from C++ ?

2006-12-18 Thread yardbird
On Saturday 16 December 2006 19:42, Xavier Gnata wrote:
> Hi,
>
> Each time I'm working on C++ codes using vector or valarray, I would
> like to be able to plot them.
> The problem is that there is no straitforward way to do that in C++.
> My goal is not to code a QT or GTK application but only to be able to
> plot 1D and 2D things from one given large C++ code without having to
> add lots of lines of codes in my code (let say it is intend to be used
> in debug phase).
>
> Questions :
> Is there a way to call pylab plot and imshow from a C++ code ?
> In this case, I do not care if we have to copy the array and it can be
> slow. It would be a so nice feature to debug C++ image processing codes.
> Any example of code is welcome even they are not calling matplotlib but
> anthing else in python.
>
> Xavier.
> ps : In my codes, 2D images are stored as in a class derived from
> valarray (1D array) adding the size of the image along the 2 directions
> as private members.

Hi Xavier,

you should really check out the Boost::Python libraries. They allow you, among 
other things, to expose your C++ container classes as python objects. I'm 
using them heavily in my project and I'm very satisfied. Check them out here:

http://www.boost.org/libs/python/doc/

HTH,

  Francesco

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread John Travers
On 18/12/06, Simson Garfinkel <[EMAIL PROTECTED]> wrote:
> It really depends on your audience as to whether or not 1,000,000
> through 9,000,000 is better displayed in scientific notation or not.
> For audiences that I frequently present to, any scientific notation
> is just unacceptable. You can add quantifiers (like KBps, MBps,
> GBps), but presenting something a 5e+5 Bps will just be lost.  You
> *might* get away with e+3, e+6, and e+9, but never the other e's.

Where I come from (Europe) 9,000,000 means 9.0 and 9.000.000 means
what you mean. That is why there is an international standard of
having 9 000 000. Basically these things should be tunable through
simple rc options.
As to the point that different rc options can produce different
results on different machines, as far as I am aware, all options can
be overridden in the script itself (correct me if I am wrong?).

Best regards,
John

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread Darren Dale
On Sunday 17 December 2006 20:06, Eric Firing wrote:
> John Hunter wrote:
> [...]
>
> > Simson> To answer Eric's most recent posting:
> >
> > Simson> 1. I think that scientific notation should not be the
> > Simson> default, unless numbers exceed 1E+7.
> >
> > I agree with this -- scientific notation kicks in too soon IMO.  I
> > think an rc setting would be fine.  I am not adverse to more rc
> > settings personally.  I haven't seen too many problems arising from
> > having a lot of rc settings.
>
> I have added an rc setting called axes.formatter.limits and set the
> defaults to -7, 7, so that now scientific notation starts at 1e+-7. This
> may be too large for some tastes--but at least now it is configurable.
> Maybe other users will comment on what they think the defaults should
> be.  I don't have a strong opinion.

I think think the name for this rc setting could be improved. How about:

(x,y)tick.scientific_notation.threshold
or
axes.scientific_notation.threshold

> I also added a convenience method to the Axes class (called
> ticklabel_format())to make it easier to turn scientific notation on or
> off on either or both axes, with the idea that other formatting control
> might be added to the method later.  I have not made the method a pylab
> function yet; I would rather wait until it settles down and people have
> had a chance to request a different name or turn thumbs down on the
> whole thing or whatever.
>
> Suggestions for better names or other aspects of these API additions are
> welcome. 

Something like use_scientific_notation() would be much clearer, in my opinion.

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread Simson Garfinkel
Well, I come from the United States, where we basically ignore  
international standards and let the rest of the world do what it  
wants. Except when it annoys us.

However, there is something called an internationalization which  
tells clever programmers who use it what to use as a digits separator  
and what to use as a decimal point.  Support for I18N is built into  
most operating systems. Unfortunately, I don' t know the Python API.   
Does anybody?

On Dec 18, 2006, at 10:35 AM, John Travers wrote:

> On 18/12/06, Simson Garfinkel <[EMAIL PROTECTED]> wrote:
>> It really depends on your audience as to whether or not 1,000,000
>> through 9,000,000 is better displayed in scientific notation or not.
>> For audiences that I frequently present to, any scientific notation
>> is just unacceptable. You can add quantifiers (like KBps, MBps,
>> GBps), but presenting something a 5e+5 Bps will just be lost.  You
>> *might* get away with e+3, e+6, and e+9, but never the other e's.
>
> Where I come from (Europe) 9,000,000 means 9.0 and 9.000.000 means
> what you mean. That is why there is an international standard of
> having 9 000 000. Basically these things should be tunable through
> simple rc options.
> As to the point that different rc options can produce different
> results on different machines, as far as I am aware, all options can
> be overridden in the script itself (correct me if I am wrong?).
>
> Best regards,
> John
>
> -- 
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to  
> share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php? 
> page=join.php&p=sourceforge&CID=DEVDEV
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread David L Goldsmith
I wonder: how hard would it be to add some intelligence to the 
interpreter and/or exception handler such that if the manner of (mis)use 
of one of these implied that what the programmer meant was the other, 
then the error message would say something like "Perhaps you meant to 
use axis (or axes, as appropriate) here?"

DG

belinda thom wrote:
> On Dec 16, 2006, at 8:10 PM, John Hunter wrote:
>
>   
>> Simson> 3. If I was going to make a major change to the API at
>> Simson> this point, it would be to make it so that you don't have
>> Simson> a class/function/ identifier called "axes" and another one
>> Simson> called "axis." I frequently get confused between these two
>> Simson> words; I imagine that non-native English speakers get
>> Simson> confused even more frequently. Irregular noun plurals in
>> Simson> English are confusing, and it probably isn't necessary to
>> Simson> use both.  One approach would be to never allow "axis," to
>> Simson> only allow "xaxis" and "yaxis" and perhaps something
>> Simson> (either_axis?) for the abstract super-class, but this may
>> Simson> be a bigger change than you wish to consider at the
>> Simson> present time.
>>
>> Yes, this is a confusing and poor nomenclature.  We're probably stuck
>> with it at this point, since it fairly deeply ingrained.
>> 
>
> The axis/axes function names are Matlab relics, so to have used  
> something else would probably have caused other complaints.
>
> On the bright side, at least w/matplotlib, you're not paying out the  
> wazoo :-) for such things.
>
> --b
>
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 
ERD/ORR/NOS/NOAA 

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread David L Goldsmith
Simson Garfinkel wrote:
> It really depends on your audience as to whether or not 1,000,000  
> through 9,000,000 is better displayed in scientific notation or not.  
> For audiences that I frequently present to, any scientific notation  
> is just unacceptable. You can add quantifiers (like KBps, MBps,  
> GBps), but presenting something a 5e+5 Bps will just be lost.  You  
> *might* get away with e+3, e+6, and e+9, but never the other e's.
>   
Ah, "Engineering" notation - that could be a useful helper function.

DG
>
> On Dec 18, 2006, at 8:53 AM, Darren Dale wrote:
>
>   
>> On Saturday 16 December 2006 20:00, Simson Garfinkel wrote:
>> 
>>> 1. I think that scientific notation should not be the default, unless
>>> numbers exceed 1E+7.
>>>   
>> There are good reasons to use scientific notation for smaller  
>> numbers than
>> 10e+-7: We dont want neighboring tick labels to run into each other  
>> on the x
>> axis, and we dont tick labels to run out of the window on the y  
>> axis. For
>> examples, see the attachments at the bottom of this page:
>> http://sourceforge.net/tracker/index.php? 
>> func=detail&aid=1196027&group_id=80706&atid=560720
>>
>> Darren
>>
>> 
>
>
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 
ERD/ORR/NOS/NOAA 

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Calling matplotlib from C++ ?

2006-12-18 Thread Christopher Barker
yardbird wrote:
> On Saturday 16 December 2006 19:42, Xavier Gnata wrote:

>> Each time I'm working on C++ codes using vector or valarray, I would
>> like to be able to plot them.

> you should really check out the Boost::Python libraries. They allow you, 
> among 
> other things, to expose your C++ container classes as python objects. I'm 
> using them heavily in my project and I'm very satisfied.

What this means is that you'd be using python to drive your C++ code, 
rather than using C++ code to drive a python/mpl code. In addition to 
Boost::Python, there are some other options to consider:

pyrex, Cxx, SWIG.

The other option is to use your C++ code to drive Python. This can be 
done by embedding a python interpreter in your C++ app. See the 
odfficial pyhton docs, and lots of other stuff online.

You also might want to check out Elmer:

http://elmer.sourceforge.net/

I've never used it, but it looks pretty cool. It's a tool that provides 
the infrastructure for calling python from C/C++.

Honestly, though, I'd go with the first approach -- drive your C++ code 
from Python -- I think that in addition to making it easy to plot 
results, etc, you'll be able to write unit tests, etc in python, and 
even get a full scripting engine, which could turn out to be very useful..

-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

[EMAIL PROTECTED]

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread David L Goldsmith
Simson Garfinkel wrote:
> Well, I come from the United States, where we basically ignore  
> international standards and let the rest of the world do what it  
> wants. Except when it annoys us.
>   
Insert wink or smiley face here to signify irony, yes?
> However, there is something called an internationalization which  
> tells clever programmers who use it what to use as a digits separator  
> and what to use as a decimal point.  Support for I18N is built into  
> most operating systems. Unfortunately, I don' t know the Python API.   
> Does anybody?
>
> On Dec 18, 2006, at 10:35 AM, John Travers wrote:
>
>   
>> On 18/12/06, Simson Garfinkel <[EMAIL PROTECTED]> wrote:
>> 
>>> It really depends on your audience as to whether or not 1,000,000
>>> through 9,000,000 is better displayed in scientific notation or not.
>>> For audiences that I frequently present to, any scientific notation
>>> is just unacceptable. You can add quantifiers (like KBps, MBps,
>>> GBps), but presenting something a 5e+5 Bps will just be lost.  You
>>> *might* get away with e+3, e+6, and e+9, but never the other e's.
>>>   
>> Where I come from (Europe) 9,000,000 means 9.0 and 9.000.000 means
>> what you mean. That is why there is an international standard of
>> having 9 000 000. Basically these things should be tunable through
>> simple rc options.
>> As to the point that different rc options can produce different
>> results on different machines, as far as I am aware, all options can
>> be overridden in the script itself (correct me if I am wrong?).
>>
>> Best regards,
>> John
>>
>> -- 
>> ---
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to  
>> share your
>> opinions on IT & business topics through brief surveys - and earn cash
>> http://www.techsay.com/default.php? 
>> page=join.php&p=sourceforge&CID=DEVDEV
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> 
>
>
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


-- 
ERD/ORR/NOS/NOAA 

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread Pierre GM
On Monday 18 December 2006 13:29, David L Goldsmith wrote:
> Simson Garfinkel wrote:
> > It really depends on your audience as to whether or not 1,000,000
> > through 9,000,000 is better displayed in scientific notation or not.
> > For audiences that I frequently present to, any scientific notation
> > is just unacceptable. You can add quantifiers (like KBps, MBps,
> > GBps), but presenting something a 5e+5 Bps will just be lost.  You
> > *might* get away with e+3, e+6, and e+9, but never the other e's.
>
> Ah, "Engineering" notation - that could be a useful helper function.

A few months ago the question got asked on this very list. 
The idea is to define a specific formatter. Here's what I'd come with (I copy 
the initial post for convenience at the end of the message).

If it's found useful, I could put it in the cookbook (now that I remember how 
to edit the wiki). Or I could leave our dear developers add it to the core.


P.

#--

class EngrFormatter(ScalarFormatter):
"""A variation of the standard ScalarFormatter, using only multiples of 
three
in the mantissa. A fixed number of decimals can be displayed with the optional 
parameter `ndec` . If `ndec` is None (default), the number of decimals is 
defined
from the current ticks.
"""
def __init__(self, ndec=None, useOffset=True, useMathText=False):
ScalarFormatter.__init__(self, useOffset, useMathText)
if ndec is None or ndec < 0:
self.format = None
elif ndec == 0:
self.format = "%d"
else:
self.format = "%%1.%if" % ndec
#
def _set_orderOfMagnitude(self, mrange):
"""Sets the order of margnitude."""
locs = N.absolute(self.locs)
if self.offset: 
oom = math.floor(math.log10(mrange))
else:
if locs[0] > locs[-1]: 
val = locs[0]
else: 
val = locs[-1]
if val == 0: 
oom = 0
else: 
oom = math.floor(math.log10(val))
if oom <= -3:
self.orderOfMagnitude = 3*(oom//3)
elif oom <= -1:
self.orderOfMagnitude = -3
elif oom >= 4:
self.orderOfMagnitude = 3*(oom//3)
else:
self.orderOfMagnitude = 0
#
def _set_format(self):
"""Sets the format string to format all ticklabels."""
# set the format string to format all the ticklabels
locs = (N.array(self.locs)-self.offset) / 10**self.orderOfMagnitude + 
1e-15
sigfigs = [len(str('%1.3f'% loc).split('.')[1].rstrip('0')) \
   for loc in locs]
sigfigs.sort()
if self.format is None:
self.format = '%1.' + str(sigfigs[-1]) + 'f'
if self._usetex or self._useMathText: 
self.format = '$%s$' % self.format
#..
class MinimalFormatter(Formatter):
"""A minimal formatter: just the plain data !"""
def __init__(self,sigfigs=None):
if sigfigs is None:
self.fmt = "%f"
else:
self.fmt = "%.%if" % sigfigs
def __call__(self,x,pos=None):
return str(self.fmt % x).rstrip('0')

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Usability with matplotlib

2006-12-18 Thread Eric Firing
Pierre,

Offhand, it looks like it should go into ticker.py, so I will probably 
do that.

Eric

Pierre GM wrote:
> On Monday 18 December 2006 13:29, David L Goldsmith wrote:
>> Simson Garfinkel wrote:
>>> It really depends on your audience as to whether or not 1,000,000
>>> through 9,000,000 is better displayed in scientific notation or not.
>>> For audiences that I frequently present to, any scientific notation
>>> is just unacceptable. You can add quantifiers (like KBps, MBps,
>>> GBps), but presenting something a 5e+5 Bps will just be lost.  You
>>> *might* get away with e+3, e+6, and e+9, but never the other e's.
>> Ah, "Engineering" notation - that could be a useful helper function.
> 
> A few months ago the question got asked on this very list. 
> The idea is to define a specific formatter. Here's what I'd come with (I copy 
> the initial post for convenience at the end of the message).
> 
> If it's found useful, I could put it in the cookbook (now that I remember how 
> to edit the wiki). Or I could leave our dear developers add it to the core.
> 
> 
> P.
> 
> #--
> 
> class EngrFormatter(ScalarFormatter):
> """A variation of the standard ScalarFormatter, using only multiples of 
> three
> in the mantissa. A fixed number of decimals can be displayed with the 
> optional 
> parameter `ndec` . If `ndec` is None (default), the number of decimals is 
> defined
> from the current ticks.
> """
> def __init__(self, ndec=None, useOffset=True, useMathText=False):
> ScalarFormatter.__init__(self, useOffset, useMathText)
> if ndec is None or ndec < 0:
> self.format = None
> elif ndec == 0:
> self.format = "%d"
> else:
> self.format = "%%1.%if" % ndec
> #
> def _set_orderOfMagnitude(self, mrange):
> """Sets the order of margnitude."""
> locs = N.absolute(self.locs)
> if self.offset: 
> oom = math.floor(math.log10(mrange))
> else:
> if locs[0] > locs[-1]: 
> val = locs[0]
> else: 
> val = locs[-1]
> if val == 0: 
> oom = 0
> else: 
> oom = math.floor(math.log10(val))
> if oom <= -3:
> self.orderOfMagnitude = 3*(oom//3)
> elif oom <= -1:
> self.orderOfMagnitude = -3
> elif oom >= 4:
> self.orderOfMagnitude = 3*(oom//3)
> else:
> self.orderOfMagnitude = 0
> #
> def _set_format(self):
> """Sets the format string to format all ticklabels."""
> # set the format string to format all the ticklabels
> locs = (N.array(self.locs)-self.offset) / 10**self.orderOfMagnitude + 
> 1e-15
> sigfigs = [len(str('%1.3f'% loc).split('.')[1].rstrip('0')) \
>for loc in locs]
> sigfigs.sort()
> if self.format is None:
> self.format = '%1.' + str(sigfigs[-1]) + 'f'
> if self._usetex or self._useMathText: 
> self.format = '$%s$' % self.format
> #..
> class MinimalFormatter(Formatter):
> """A minimal formatter: just the plain data !"""
> def __init__(self,sigfigs=None):
> if sigfigs is None:
> self.fmt = "%f"
> else:
> self.fmt = "%.%if" % sigfigs
> def __call__(self,x,pos=None):
> return str(self.fmt % x).rstrip('0')
> 
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] gradients in bar graphs

2006-12-18 Thread Jeff Huang
Is it possible to have gradients in the bar graphs made by matplotlib? I
couldn't find anything about it in the user guide.

Thanks

Jeff


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] gradients in bar graphs

2006-12-18 Thread John Hunter
> "Jeff" == Jeff Huang <[EMAIL PROTECTED]> writes:

Jeff> Is it possible to have gradients in the bar graphs made by
Jeff> matplotlib? I couldn't find anything about it in the user
Jeff> guide.

Here is some example code form the mailing list

To: Christopher Barker <[EMAIL PROTECTED]>
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] graphs
From: John Hunter <[EMAIL PROTECTED]>
Date: Tue, 16 May 2006 15:01:15 -0500
> "Christopher" == Christopher Barker <[EMAIL PROTECTED]> writes:

Christopher> That I don't know. The Agg renderer certainly can do
Christopher> a nice job with gradients, but I don't know if MPL
Christopher> support that.

You can emulate gradients using matplotlib images -- either with colormaps or
defining your own rgba endpoints for the gradients.  Here's an example
of an axes background gradient

from pylab import figure, show, nx, cm

fig = figure()

xmin, xmax = xlim = 0,2
ymin, ymax = ylim = -1,1
ax = fig.add_subplot(111, xlim=xlim, ylim=ylim,
autoscale_on=False)
X = [[.6, .6],[.7,.7]]

ax.imshow(X, interpolation='bicubic', cmap=cm.Blues,
  extent=(xmin, xmax, ymin, ymax), alpha=1)
t = nx.arange(xmin, xmax,0.01)
ax.plot(t, nx.sin(2*nx.pi*t), lw=2, color='black')
show()


Likewise, you can make your own gradient bars charts:

from pylab import figure, show, nx, cm

def gbar(ax, x, y, width=0.5, bottom=0):
X = [[.6, .6],[.7,.7]]
for left,top in zip(x, y):
right = left+width
ax.imshow(X, interpolation='bicubic', cmap=cm.Blues,
  extent=(left, right, bottom, top), alpha=1)

fig = figure()

xmin, xmax = xlim = 0,10
ymin, ymax = ylim = 0,1
ax = fig.add_subplot(111, xlim=xlim, ylim=ylim,
 autoscale_on=False)
X = [[.6, .6],[.7,.7]]

ax.imshow(X, interpolation='bicubic', cmap=cm.copper,
  extent=(xmin, xmax, ymin, ymax), alpha=1)

N = 10
x = nx.arange(N)+0.25
y = nx.mlab.rand(N)
gbar(ax, x, y, width=0.7)
ax.set_aspect('normal')
show()

Viewer discretion is advised.

If you want to get clever, you can define patterns and fills this way
too.  We should add an interface to expose this functionality more
readily...

JDH


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Using Apple's freetype2 for mpl on OS X

2006-12-18 Thread Tom Loredo

Hi folks-

I'd like to report a possible way for OS X mpl users to use Apple's freetype2
(in their X11), to see if there are any problems with it I may need to be
aware of, and if not, to offer it as a possible solution to others installing
mpl from source on OS X.  I know Apple's freetype2 was "broken" in Panther,
but it's possible things are different with Tiger.

The basic issue is that Apple's X11 installs a version of freetype2 under
/usr/X11R6/ which might be usable by mpl, and which can conflict with other
copies users might install to build mpl.

With Panther (10.3), I followed mpl build instructions and installed my own
freetype2.  I tried two different methods:  using i-Installer, and directly
from source (into /usr/local/).  Both approaches worked fine with mpl.
However, using either version led to problems with other X11 software I tried
to install.  The issues I remember had to do with GTK (i.e., installing PyGTK
and an unrelated GTK app, geda, from source).  There were troublesome issues
having to do with freetype2 and some other X11 libs.  According to some
anecdotal reports I found online, it appears Apple did something strange to
the freetype version (at least in Panther versions of X11), so gcc/ld would
link against it even if a more recent version was in /usr/local/, but then
there would be freetype issues at runtime.  My eventual solution involved
removing various parts of Apple's X11, and putting links in /usr/X11R6/ to the
new installs in /usr/local/.  (I have a script to do this, if anyone needs
it.)

This was such a headache that when I just upgraded to Tiger (10.4; a clean
install), I thought I'd see if mpl could be installed using the new freetype2 
in Apple's X11.  (I also did not install zlib, since 10.4 includes it in
/usr/lib/.)  To do so, I had to modify "add_ft2font_flags" in setupext.py,
adding this to the top:

# Added to provide access to Apple's freetype2 when their X11 is installed
if sys.platform=='darwin':
# Add paths to Apple's X11R6.
module.library_dirs.extend(
['/usr/X11R6/lib'])

module.include_dirs.extend(
['/usr/X11R6/include'])

(Also, the docstring is incorrect and should be fixed to refer to freetype2
rather than gd.)  With this change, mpl built without any errors, and as far
as I can tell so far, is working just fine.  I've come across a few missing
font/font replacement warnings, but I don't know whether installing a new
freetype2 would have avoided these.

If anyone can see a problem with this procedure, please let me know.
Otherwise, it means that Tiger users who have installed Apple's X11 need to
install just one library (libpng) before installing mpl, so long as the above
change is made to setupext.py.  I don't know if the change would have any
ramifications for those who don't install X11 or who do install it and *also*
install freetype2 in /usr/local/.  If no problems are anticipated, perhaps
the change can be incorporated into mpl.

Thanks for any feedback on this.

-Tom


-
This mail sent through IMP: http://horde.org/imp/

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users