Re: [Matplotlib-users] Unexplained label on plot

2007-06-13 Thread Steve Schmerler
Stuart Yarrow wrote:
> Hi All,
> 
> An extra label is appearing on the plot I'm generating. I wonder if anyone
> could explain what it means/how to get rid of it?
> 
> The plot is available at http://test.outpost.org.uk/example.png - the
> unexplained label is the '+4.05674e7' in the upper right hand corner. This
> value doesn't appear to be related to what I'm doing numerically.
> 
> # Plot Results
> lines1 = []
> plot1 = pylab.subplot(211)
> lines1.extend(pylab.plot(In, thrust / g, 'b-'))
> pylab.ylabel('Thrust (kgf)')
> pylab.grid(True)
> ax2 = pylab.twinx()
> lines1.extend(pylab.plot(In, inputFlow * 6, 'g--'))

Couldn't it be because of "inputFlow * 6", which may cause the 
plotted values to be large (so it is related to what you do 
numerically)? The same happens for e.g. plot(array([1,2,3])+1e5), i.e. 
if the values' changes are small compared to their magnitude. Without 
that, the tick numbers would read 11.0, 12.0, 13.0 in this 
example, which may not look very pretty.

HTH

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Warning message

2007-06-25 Thread Steve Schmerler
Beha Online wrote:
> I receive the following message when I import pylab with: "from pylab import 
> *":
> 
> /usr/lib64/python2.4/site-packages/matplotlib/numerix/__init__.py:67:
> DeprecationWarning: Numeric use as a numerix backed for matplotlib is
> deprecated
> DeprecationWarning, stacklevel=1)
> 

In your ~/.matplotlib/matplotlibrc file set "numerix: numpy" in order to 
use numpy. AFAIK, the support for Numeric and numarray will be dropped 
sooner or later.

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Steve Schmerler
kaushik.ghose wrote:

> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')
> 
> matplotlib renders it fine, but won't save it to svg correctly - the 
> summation symbol doesn't show up.
> 
> Is this a configuration issue on my part, or is svg support for latex 
> currently incomplete?

AFAIK, the latex support for the SVG backend isn't fully working yet. 
For rcParams['text.usetex']=True you'll get an error. With 
rcParams['text.usetex']=False I get the same issue that you see (Sum 
symbol missing when I open the .svg in Inkscape).

See also 
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg03340.html

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Latex equations and SVG export

2007-07-06 Thread Steve Schmerler
Edin Salkovic wrote:
> Hi kaushik,
> 
> On 7/6/07, kaushik.ghose <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> When I do
>>
>> m.text(0,0,'$\sum_{n=1}^{100}$');m.axis('off');m.savefig('test.svg')
> 
> Shouldn't that be:
> r'$\sum_{n=1}^{100}$'   # i.e. a "raw" string.
> 
> or:
> 
> '$\\sum_{n=1}^{100}$'  # Escaped backslash
> 

>From my experience, with usetex True and without r'', the TeX string is parsed
correctly even for stuff like text(0,0,'$\sum_{n=1}^{100}$ with $\Omega$'), i.e.
mathmode and textmode combined.

Here, indeed, with usetex False, using r'' produces the \sum sign in the .svg 
but
"n=1" and "100" are not alinged correctly (they both appear above \sum). With 
usetex
True there is the NotImplementedError (mpl 0.90.0dev3131).

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. -- 
Douglas Adams


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Fitting a curve

2007-08-30 Thread Steve Schmerler
Wolfgang Kerzendorf wrote:
> I know this is not completely matplotlib related but perhaps you can 
> help me none the less:
> I want to fit a curve to a set of data. It's a very easy curve: y=ax+b.
> But I want errors for a and b and not only the rms. Is that possible. 
> What tasks do you recommend for doing that.
> Thanks in advance
> Wolfgang
> 

from http://mathworld.wolfram.com/LeastSquaresFitting.html:

(but here: y = a*x+b, so a <-> b)!

For the standard errors on a and b:

n = float(len(x))
xm = mean(x)
ym = mean(y)
SSxx = dot(x,x) - n*xm**2.0
SSyy = dot(y,y) - n*ym**2.0
SSxy = dot(x,y) - n*xm*ym
r = sqrt(SSxy**2.0 / (SSxx*SSyy))
s = sqrt((SSyy - (SSxy**2.0 / SSxx)) / (n-2.0))

sea = s / sqrt(SSxx)
seb = s * sqrt(1.0/n + (xm**2.0 / SSxx))

The values of sea, seb agree with gnuplot's "Asymptotic Standard Error".

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as quickly as 
possible.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Vector magnitude?

2007-09-05 Thread Steve Schmerler
Robert Dailey wrote:
> Hi,
> 
> I have two questions:
> 
> 1) Is there any way to represent vectors? Currently I'm using 'array' for
> vectors.
> 

I suppose you mean vectors in the Matlab way? Then you should have a look at
http://scipy.org/NumPy_for_Matlab_Users#head-e9a492daa18afcd86e84e07cd2824a9b1b651935
In short: of course you can do all linalg with numpy.array. With numpy.matrix,
some operations (like dot products) can be written more conveniently.

> 2) Is there a way to calculate the magnitude (length) of a vector?
> 

a = array([3,1,4])
len(a)
a.size # only for a rank-1 array
a.shape[0]

For some basics on numpy, you may also check out:
http://scipy.org/Documentation

HTH

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. --
Douglas Adams


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Vector magnitude?

2007-09-07 Thread Steve Schmerler
Norbert Nemec wrote:

> 
>> 2) Is there a way to calculate the magnitude (length) of a vector?
> numpy.linalg.norm(X)
> 

This makes more sense than len(). I've got confused by "length" :)

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. --
Douglas Adams


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] dual y scales

2007-09-12 Thread Steve Schmerler
Alan G Isaac wrote:
> I need to make some dual y-scale plots:
> on time series plotted against the left axis,
> with a second plotted again the right axis (which has its 
> own scale).  I think Matplotlib did not used to provide
> dual scale plotting: is it now available?
> 

You mean something like two_scales.py in the mpl examples? (in svn or download 
from the homepage)

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as quickly as 
possible.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] mpl returns wrong revision number

2007-10-31 Thread Steve Schmerler
I installed svn r4071. `svn info ` and
`svnversion ` report the correct rev number. But

$ ipython -pylab

In [1]: matplotlib.__version__
Out[1]: '0.90.1'

In [2]: matplotlib.__revision__
Out[2]: '$Revision: 3975 $'

If I'm right, this is because in matplotlib/__init__.py:
__revision__ = '$Revision: 3975 $'
which is the last rev where *this file* changed. Shouldn't
matplotlib.__revision__ report the latest global revision number?
Like that:

import subprocess as su
p = su.Popen('svnversion ',
 shell=True, stdin=su.PIPE, stdout=su.PIPE)
revnr = p.stdout.read().strip()
print revnr

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. --
Douglas Adams


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] grayscale

2007-11-12 Thread Steve Schmerler
Johann Cohen-Tanugi wrote:
> hello,
> is there a quick way to get a figure in greyscale?

You can do something like plot([1,2,3], color='0.9'), where the string '0.9' 
denotes the gray scale of the plotted line. See also `help plot`, `help colors`.

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as quickly as 
possible.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [OT] Confusion with mailing lists

2007-12-05 Thread Steve Schmerler
rex wrote:
 > massimo sandal <[EMAIL PROTECTED]> [2007-12-04 09:18]:
 >> On a related note, I *hate* that hitting "reply" uses the mail address
 >> of the parent poster, instead than that of the mailing list. The scipy
 >> and the gentoo mailing list (two other examples I know) behave more
 >> properly. Is this a sourceforge quirk?
 >
[...]
 > If you choose to use old software that doesn't recognize the List-Post
 > header, please don't complain about software that follows RFC standards.

If you happen to use Mozilla Thunderbird, there is an extension [1] that
enables Reply-To-List.
This works with a patched version of Thunderbird, which is included in
several major distros.

[1] http://alumnit.ca/wiki/index.php?page=ReplyToListThunderbirdExtension

-- 
Random number generation is the art of producing pure gibberish as quickly as
possible.

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem with modules

2008-02-28 Thread Steve Schmerler
On Thu, Feb 28, 2008 at 05:40:00PM +, Davide Cellai wrote:
> 1. To begin with, I've copied the lines:
> 
> deb http://anakonda.altervista.org/debian packages/
> deb-src http://anakonda.altervista.org/debian sources/
>

I'm sure matplotlib is in Ubuntu's official repos by now [1]. Same for Debian.

> 2. When I try to run some examples I have downloaded from the website, the
> program complains about modules. For example, if I try
> python hline_demo.py
> 

Ubuntu's latest version is 0.90.1. According to [2], the pyplot
module was introduced with 0.91.2.

[1] 
http://packages.ubuntu.com/search?keywords=matplotlib&searchon=names&suite=all§ion=all
[2] http://matplotlib.sourceforge.net/whats_new.html

cheers,
steve

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] variable line thickness in a plot

2008-03-11 Thread Steve Schmerler
On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:
> The API for the plot function states that the line thickness can only be a
> single floating point number.
> 

Really? Try

plot([1,2,3], lw=math.pi)

cheers,
steve

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] variable line thickness in a plot

2008-03-11 Thread Steve Schmerler
On Tue, Mar 11, 2008 at 01:23:55PM -0700, eliss wrote:
> On 3/11/08, Steve Schmerler <[EMAIL PROTECTED]> wrote:
> >
> > On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:
> > > The API for the plot function states that the line thickness can only be
> > a
> > > single floating point number.
> > >
> >
> > Really? Try
> >
> >plot([1,2,3], lw=math.pi)
> >
> > cheers,
> > steve
> 
> 
> Sorry, I don't get your point. math.pi is just a single floating point
> number. How can I use that to create lines with variable thickness?

Ah sorry for the noise, I didn't read your message well. I somehow thought you
ment an *integer* rather than a float. 

So, I'm not sure whether you want a single line that changes width and color or 
several lines that change. In the latter case you could of course just loop over
your properties. Something like

x = linspace(0,3,50)
for w in [0,1,2,3,4,5]: 
plot(x, sin(x*w), lw=w, color=(w/5.0,0,(5-w)/5.0));

If you don't want that, then the example from Troels Kofoed Jacobsen will be
a nice way to go. Didn't know about mlab.poly_between. Didn't find it in the 
CHANGELOG.

cheers,
steve

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to close a figure ?

2006-06-06 Thread Steve Schmerler
leau2001 wrote:
> I made some figure in a loop and i want to close after the figure show.
> 

Not absolutely sure what you mean, but to produce some plots and save
them in a loop I do

f = figure()
for i in range(..):
plot(...)
savefig(...)
f.clf() # clear figure for re-use
close(f)


cheers,
steve

-- 
Random number generation is the art of producing pure gibberish as
quickly as possible.



___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] usetex: different fonts

2006-06-18 Thread Steve Schmerler
With usetex mpl creates different fonts on the axes ticks and the 
$\times 10^$ labels.



In [1]: matplotlib.__version__
Out[1]: '0.87.3'
(from svn)

--
Random number generation is the art of producing pure gibberish as 
quickly as possible.

___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] usetex: different fonts

2006-06-19 Thread Steve Schmerler
Ryan Krauss wrote:
> Sorry, I didn't scroll down low enough in the message to see the png
> you already attached.
> 
> Ryan
> 

The latest update (Darren's mail) makes the plots (exponents etc.) look
just cool. Thanks!

cheers,
steve

-- 
Random number generation is the art of producing pure gibberish as
quickly as possible.



___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] _mathtext_data.py uppercase greek

2006-07-13 Thread Steve Schmerler
In case there is some interest, I changed _mathtext_data.py to support 
nonslanted uppercase greek characters rather (\Omega & stuff, see .diff).



BTW, in _mathtext_data.py there is a line

font = FT2Font('/usr/local/share/matplotlib/cmr10.ttf')

I think this is a obsolete location, right? (at least I don't have it)

cheers,
steve

--
Random number generation is the art of producing pure gibberish as 
quickly as possible.
--- _mathtext_data.py.orig	2006-07-14 07:28:59.0 +0200
+++ _mathtext_data.py	2006-03-17 03:17:12.0 +0100
@@ -4,7 +4,7 @@
 
 # this dict maps symbol names to fontnames, glyphindex.  To get the
 # glyph index from the character code, you have to use a reverse
-# dictionary grom font.get_charmaps, eg,
+# dictionary from font.get_charmaps, eg,
 """
 from matplotlib.ft2font import FT2Font
 font = FT2Font('/usr/local/share/matplotlib/cmr10.ttf')
@@ -82,17 +82,16 @@
 r'\imath'   : ('cmmi10',   8),
 r'\jmath'   : ('cmmi10',  65),
 r'\wp'  : ('cmmi10',  14),
-r'\Gamma'   : ('cmmi10',  37),
-r'\Delta'   : ('cmmi10',  11),
-r'\Theta'   : ('cmmi10',  12),
-r'\Lambda'  : ('cmmi10',  26),
-r'\Xi'  : ('cmmi10',   4),
-r'\Pi'  : ('cmmi10',  33),
-r'\Sigma'   : ('cmmi10',  16),
-r'\Upsilon' : ('cmmi10',  19),
-r'\Phi' : ('cmmi10',  15),
-r'\Psi' : ('cmmi10',  27),
-r'\Omega'   : ('cmmi10',  23),
+r'\Gamma'   : ('cmr10',   19),
+r'\Delta'   : ('cmr10',6),
+r'\Theta'   : ('cmr10',7),
+r'\Lambda'  : ('cmr10',   14),
+r'\Xi'  : ('cmr10',3),
+r'\Pi'  : ('cmr10',   17),
+r'\Sigma'   : ('cmr10',   10),
+r'\Phi' : ('cmr10',9),
+r'\Psi' : ('cmr10',   15),
+r'\Omega'   : ('cmr10',   12),
 r'\alpha'   : ('cmmi10',  13),
 r'\beta': ('cmmi10',  35),
 r'\gamma'   : ('cmmi10',  24),

-
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


[Matplotlib-users] tick labeling question

2006-08-03 Thread Steve Schmerler
Hi all

How can I change the default behavior of the tick labeling from say

1  2   3   4  x1e-5

to

1e-5  2e-5  3e-5  4e-5 ?

My thesis supervisor wants it that way :(

cheers,
steve

-- 
Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] tick labeling question

2006-08-03 Thread Steve Schmerler
Darren Dale wrote:
> On Thursday 03 August 2006 11:59, Alexander Michael wrote:
>> On 8/3/06, Steve Schmerler <[EMAIL PROTECTED]> wrote:
>>> Hi all
>>>
>>> How can I change the default behavior of the tick labeling from say
>>>
>>> 1  2   3   4  x1e-5
>>>
>>> to
>>>
>>> 1e-5  2e-5  3e-5  4e-5 ?
>>>
>>> My thesis supervisor wants it that way :(
>>>
>>> cheers,
>>> steve
>> There is problably a better way, but onne way is to set  the label
>> formatter yourself:
>>
>> import pylab
>> import matplotlib
>>
>> pylab.plot([1.0E-5,2.5E-5,3.0E-5], [1.0, 3.0, 2.0])
>>
>> ax = pylab.gca()
>> ax.xaxis.set_major_formatter(
>> matplotlib.ticker.FormatStrFormatter('%g'))
> 
> Use OldScalarFormatter instead.
> 

OK, I'll try that one too ...

Thanks.


-- 
Random number generation is the art of producing pure gibberish as
quickly as possible.


-
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] tick labeling question

2006-08-03 Thread Steve Schmerler

Alexander Michael wrote:
On 8/3/06, *Steve Schmerler* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
wrote:


Hi all

How can I change the default behavior of the tick labeling from say

1  2   3   4  x1e-5

to

1e-5  2e-5  3e-5  4e-5 ?

My thesis supervisor wants it that way :(

cheers,
steve


There is problably a better way, but onne way is to set  the label 
formatter yourself:


import pylab
import matplotlib

pylab.plot([1.0E-5,2.5E-5,3.0E-5], [1.0, 3.0, 2.0])

ax = pylab.gca()
ax.xaxis.set_major_formatter(
matplotlib.ticker.FormatStrForm
atter('%g'))

pylab.show()

You can craft an arbitrarily constructed string by using 
matplotlib.ticker.FuncFormatter

 instead of matplotlib.ticker.FormatStrFormatter.

Hope this helps,
Alex



Yes, after a look at the docs I found that FuncFormatter is what I
wanted. With the help of a little function (which I wrote some time ago)
that converts a float number into a raw string I can use FuncFormatter
straightforward (see attached file).

cheers,
steve

--
Random number generation is the art of producing pure gibberish as
quickly as possible.

from pylab import *
from numpy import logspace
##import utils
##from mpl_settings import *
rcParams['text.usetex'] = True

def make_label(num, precision = 3, format = 'e', start_text = ''):
"""
Convert number 'num' into raw string for matplotlib labels.
"""
format_str = '%.' + str(precision) + format
s = format_str %num

if format == 'e':
ss = s.split(format)
float_str = ss[0]
ex = ss[1]
# '+05' -> '05' 
if ex.startswith('+'):
ex = ex[1:]
while ex.startswith('0'):
ex = ex[1:]
elif ex.startswith('-'):
   while ex.startswith('-0'):
ex = ex[0] + ex[2:]
if ex != '':
label_str = r'$%s%s\times 10^{%s}$' %(start_text, float_str, ex) 
else:
label_str = r'$%s%s$' %(start_text, float_str) 

elif format == 'f':
label_str = r'$%s%s$' %(start_text, s)

else:
raise StandardError, "[make_label] only formats 'e' and 'f' allowed"
sys.exit(1)
return label_str   

def ax_tick_format(num, pos):
##return utils.make_label(num, precision = 2)
return make_label(num, precision = 2)

formatter = FuncFormatter(ax_tick_format)

f = figure()
ax = f.gca() 
ax.yaxis.set_major_formatter(formatter)

y = logspace(-1,-30,100)
plot(y)
ylabel('lalala')
subplots_adjust(left=0.15)

show()

-
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] legend outside of the plot

2006-08-04 Thread Steve Schmerler
Christian Meesters wrote:
> Hi,
> 
> As far I understand this a plot is per default covering the more or less 
> whole 
> space. Now, is it possible to position a legend outside of a plot, e.g. on 
> the right of the plot. "legend" offers to supply the loc-argument with a 
> tuple to do that, but that doesn't create more space and hence most legends 
> will appear truncated. The only solution I came up with is to limit the 
> plotting area (using "axes") and to position the legend manually. Is there an 
> alternative?
> 
> TIA
> Cheers
> Christian
> 

I think you have to fiddle with the axes (see figlegend_demo.py in the
examples folder). As far as I know, there is no such thing like
gnuplot's "set key out" switch.

cheer,
steve

-- 
Random number generation is the art of producing pure gibberish as
quickly as possible.


-
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] Debian etch binary

2006-11-06 Thread Steve Schmerler
Hi

I installed

python-matplotlib_0.87.5-2.1_amd64.deb (rev. 2761)

on Debian etch (Python 2.4.4c0) and get this warning when trying to plot 
something:

In [1]: plot([1,2,3])
/usr/lib/python2.4/site-packages/matplotlib/font_manager.py:989: 
UserWarning: Could not match sans-serif, normal, normal.  Returning 
/usr/share/matplotlib/mpl-data/cmtt10.ttf
   warnings.warn('Could not match %s, %s, %s.  Returning %s' % (name, 
style, variant, self.defaultFont))
Out[1]: []


-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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


Re: [Matplotlib-users] ZeroDivisionError in scale_range

2006-11-11 Thread Steve Schmerler
W Netzberg wrote:
> The following code throws ZeroDivisionError:
> import numpy, pylab
> z = numpy.random.normal(-0.37727, 0.1, size=10)
> pylab.plot(z)
> pylab.show ()
> The stack trace:
> Traceback (most recent call last):
>   File "", line 3, in ?
>   File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 
> 2018, in plot
> ret =  gca().plot(*args, **kwargs)
>   File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 2790, 
> in plot
> self.autoscale_view()
>   File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 817, 
> in autoscale_view
> self.set_ylim(locator.autoscale())
>   File "/usr/lib/python2.4/site-packages/matplotlib/ticker.py", line 
> 798, in autoscale
> return take(self.bin_boundaries(dmin, dmax), [0,-1])
>   File "/usr/lib/python2.4/site-packages/matplotlib/ticker.py", line 
> 768, in bin_boundaries
> scale, offset = scale_range(vmin, vmax, nbins)
>   File "/usr/lib/python2.4/site-packages/matplotlib/ticker.py", line 
> 733, in scale_range
> var = dv/max(abs(vmin), abs(vmax))
> ZeroDivisionError: float division
> 
> Any ideas?
> 

Works fine here.

pylab.matplotlib.__version__
'0.87.5'

pylab.matplotlib.__revision__
'$Revision: 2761 $'

Which version are you using?

cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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


Re: [Matplotlib-users] ZeroDivisionError in scale_range

2006-11-13 Thread Steve Schmerler
W Netzberg wrote:

> I can't find a 0.87.5 rpm for fc5, might have to build it from source to 
> see if this behavior goes away... Seems to be related to numpy. If I 
> replace:
> numpy.random.normal(-0.37727, 0.1, size=10)
> with an array normal() returns, the problem goes away. Strange. Again 
> this is under 0.87.3.
> 

Hmmm I don't really get it :). You replaced 
numpy.random.normal(-0.37727, 0.1, size=10) with an array? But this 
already returns one ...

Anyway I would suggest upgrading (the latest is 0.87.7).

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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


Re: [Matplotlib-users] ZeroDivisionError in scale_range

2006-11-13 Thread Steve Schmerler
W Netzberg wrote:
> I aggree it doesn't make much sense, but that's what I got and attached 
> a plot to prove it!
> Seems that some sort of rounding takes place, but only when I use 
> numpy.random.normal(). It is strange.

Can you post a short working and not-working (i.e. chopping off) example?

> 
> I had problems building latest version from source last night. Do you 
> know where I can find the latest rpm for fc5?
> 

No, sry. I'm still building from source myself.

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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


Re: [Matplotlib-users] Upgrade matplotlib [newbie]

2006-11-18 Thread Steve Schmerler
Frank Zwaard wrote:
> Hi
> 
> sorry for the stupid question but I have installed an RPM version of
> matplotlib and now I would like to upgrade it. Unfortunately I would
> like to install a version that doesn't have an RPM.
> I downloaded the source and built it, but I don't know if I can just
> install it over the old version or if I have to remove the old version
> and then install the old one ...
> What should I do with Scipy and Numpy?
> 
> Is there some docs about this?
> 

Infos on compatible numpy/scipy versions: http://scipy.org/Download

I'm not sure which numpy version is required by the latest mpl, but the 
latest tarballs should work. If you have numpy/scipy installed via a 
package manager, check the versions. If they are not too old, try to 
just upgrade mpl and see if it works, otherwise install (1) numpy, (2) 
scipy, (3) mpl.
Always remove/uninstall/backup the old installations first (to be on the 
safe side also everything in ~/.matplotlib, maybe back up your 
matplotlibrc file). Install to /usr/local/lib/python2.x/site-packages 
(instead of /usr/lib) with python setup.py install --prefix=/usr/local 
to avoid clashes with your package manager (I experienced such things).

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] Problem with savefig and usetex

2006-12-11 Thread Steve Schmerler
Nicolas Champavert wrote:
> Hello,
> 
>   I have some problems when trying to save a figure with usetex=True. 
> Sometimes, it is not possible to save the figure when trying to put an 
> xlabel with LaTeX inside.
> It works with pylab.xlabel('M$_\odot$') but not with 
> pylab.xlabel('10$^3$ M$_\odot$') (see below). Do you know why ?
> 


Works fine here, with and w/o raw strings.

In [75]: rcParams['text.usetex']=True

In [76]: plot([1,2,3])
Out[76]: []

In [77]: xlabel('10$^3$ M$_\odot$')
Out[77]: 

In [78]: savefig('test.eps')

In [79]: matplotlib.__version__
Out[79]: '0.87.7'

In [80]: matplotlib.__revision__
Out[80]: '$Revision: 2835 $'


Maybe you need to upgrade, but that's just a guess.

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as
quickly as possible.


-
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] Problem with savefig and usetex

2006-12-11 Thread Steve Schmerler
Darren Dale wrote:
> On Monday 11 December 2006 09:59, Nicolas Champavert wrote:
>> Steve Schmerler a écrit :
>>> Nicolas Champavert wrote:
>>>> Hello,
>>>>
>>>>   I have some problems when trying to save a figure with usetex=True.
>>>> Sometimes, it is not possible to save the figure when trying to put an
>>>> xlabel with LaTeX inside.
>>>> It works with pylab.xlabel('M$_\odot$') but not with
>>>> pylab.xlabel('10$^3$ M$_\odot$') (see below). Do you know why ?
>>> Works fine here, with and w/o raw strings.
> [...]
>> I had matplotlib revision 2835. I made an upgrade. Now I have revision
>> 2905. I still have problem but it is very strange:
>> - when I plot [0,1] with xlabel(r'(10$^3$ M$_\odot$)'), it works.
>> - when I plot [1,2] with xlabel(r'Upper mass for the IMF (10$^3$
>> M$_\odot$)'), it works.
>> - but it doesn't work if I plot [0,1] with xlabel(r'Upper mass for the
>> IMF (10$^3$ M$_\odot$)')...
> 
> It sounds like an issue with one of the dependencies, probably ghostscript. I 
> have matplotlib-0.87.7, svn revision 2905, and gpl-ghostscript-8.54. I can 
> not reproduce the problem here.
> 

I seem to be running ESP Ghostscript 8.15.3 (this is what 'gs --version' 
and 'apt-cache show gs' tell me). All the examples work fine here ...

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] *EGG* now freezes at this same place always....

2006-12-13 Thread Steve Schmerler
[EMAIL PROTECTED] wrote:
> Thanks for help.  Now it freezes always here...
> 
> 
> GTK requires pygtk
> GTKAgg requires pygtk
> TKAgg requires TkInter

I never used eggs, but I guess you need to install these libs by yourself.

apt-cache search for this stuff and make sure you install the *-dev 
versions of the packages.

Seems that you need (list may not exhaustive) python-gtk2-dev (pygtk) 
and tk8.4-dev, python-tk, ... (TkInter, this is a little tricky to 
search for, check the dependencies)

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] error in simple plot command

2006-12-14 Thread Steve Schmerler
Brian Blais wrote:

> 
> plot([1],[0],'o')
> 
> I get a floating point/divide by zero error:
> 
> 
> /usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, 
> vmax, n, 
> threshold)
>  731 dv = abs(vmax - vmin)
>  732 meanv = 0.5*(vmax+vmin)
> --> 733 var = dv/max(abs(vmin), abs(vmax))
>  734 if var < 1e-12:
>  735 return 1.0, 0.0
> 
> ZeroDivisionError: float division
> 
> 
> Is there a fix for this?
> 


You have to upgrade.

In [39]: plot([1],[0],'o')
Out[39]: []

In [40]: matplotlib.__version__
Out[40]: '0.87.7'

In [41]: matplotlib.__revision__
Out[41]: '$Revision: 2835 $'

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] saving data to a file

2007-01-03 Thread Steve Schmerler
belinda thom wrote:
> Hi,
> 
> Is there a way for me to keep adding the next row of a 2d array to a  
> file via load? (matlab's save had a very useful -append option).
> 
> I managed to get 2d laod/save working, e.g.
> 
>import numpy as N
>import pylab as P
>import bthom.utils as U
># a numpy 2d array
>a = N.arange(12,dtype=N.float).reshape((3,4))
>a[0][0] = N.pi
># checking out the matploblib save/load stuff
>P.save("data.csv", a, fmt="%.4f", delimiter=";")
>aa = P.load("data.csv", delimiter= ";")
>x,y,z,w = P.load("data.csv", delimiter=";", unpack=True)
> 
> The above took me longer than it perhaps should have b/c of advice  
> I'd gotten elsewhere recommending trying to keep numpy and pylab  
> separate when possible (to take advantage of all of numpy's features;  
> it seems numpy doesn't even have the all-to-handy load/save  
> functionality).
> 
> When I try similar tricks to write one row at a time, I'm hosed in  
> that the shape is gone:
> 
># checking out a way to keep appending
>fname = "data1.csv"
>U.clobber_file(fname) #this thing just ensures 0 bytes in file
>f = open(fname,"a")
>nrows,ncols = a.shape
>for i in range(nrows) :
>P.save(f, a[i,:], fmt="%d", delimiter=";")
>f.close()
>aaa = P.load("data1.csv", delimiter= ";")
> 
> in particular:
> 
>% cat data1.csv
>3
>1
>2
>4
>
>11
> 
> Thanks in advance,
> --b
> 

This is because pylab.save() writes every 1D-array (like a[i,:]) as 
"column vector". In the definition of the save() function:

[...]
 if len(X.shape)==1:
 origShape = X.shape
 X.shape = len(X), 1
[...]

This reshapes the 1D-array (len(a[i,:].shape) == 1) to a 2D-array of 
shape Nx1 and a loop over the first axis writes the rows (in this case 
one element per row) to file.

There are several ways to do what you want:

#---#

# generate data
a = N.arange(12,dtype=N.float).reshape((3,4))
a[0][0] = N.pi
P.save("data.csv", a, fmt="%.4f", delimiter=";")

# (A)
# rather hackish way, define your own save(), not
# really useful, just to show that it works
def save2(fname, X, fmt='%.18e',delimiter=' '):

 if is_string_like(fname):
 if fname.endswith('.gz'):
 import gzip
 fh = gzip.open(fname,'wb')
 else:
 fh = file(fname,'w')
 elif hasattr(fname, 'seek'):
 fh = fname
 else:
 raise ValueError('fname must be a string or file handle')


 X = N.asarray(X)
 origShape = None
 if len(X.shape)==1:
 origShape = X.shape
# >
##X.shape = len(X), 1
 X.shape = 1, len(X)
# <
 for row in X:
 fh.write(delimiter.join([fmt%val for val in row]) + '\n')

 if origShape is not None:
 X.shape = origShape


fname = "data1.csv"
f = open(fname,"a")
nrows,ncols = a.shape
for i in range(nrows) :
 save2(f, a[i,:], fmt="%f", delimiter=";")
f.close()
aaa = P.load("data1.csv", delimiter= ";")
print aaa

print "---"

# (B)
# do it without a save() function
fname = "data2.csv"
f = open(fname,"a")
nrows,ncols = a.shape
delim = ';'
fmt = '%f'
for i in range(nrows):
 # just like in pylab.save()
 f.write(delim.join([fmt %val for val in a[i,:]]) + '\n')
f.close()
aaa = P.load("data2.csv", delimiter= ";")
print aaa

print "---"

# (C)
# probably the best: save a 1xn "row vector" per line
fname = "data3.csv"
f = open(fname,"a")
nrows,ncols = a.shape
for i in range(nrows) :
 P.save(f, a[i,:].reshape((1,ncols)), fmt="%f", delimiter=";")
f.close()
aaa = P.load("data3.csv", delimiter= ";")
print aaa


HTH

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] Importing Binary files

2007-02-05 Thread Steve Schmerler
Kumar Appaiah wrote:
> On Fri, Feb 02, 2007 at 05:14:37AM -0800, Vijay Kumar wrote:
>> Hi,
>>
>> I want to import binary files generated from C/FORTRAN into matplotlib for
>> plotting. 
>> Can this be done using 'load'?
> 
> If you are using SciPy, scipy.io has a few functions which may
> help. scipy.io.fromfile, for example.
> 

Or, if you have to pay attention to endianess, you could use something 
like this.

import numpy as N

def load_binary_data(filename, dtype=float):
 """
 We assume that the data was written
 with write_binary_data() (little endian).
 """
 f = open(filename, "rb")
 data = f.read()
 f.close()
 _data = N.fromstring(data, dtype)
 # data has been written by write_binary_data() in little endian 
if sys.byteorder == 'big':
 _data = _data.byteswap()
 return _data


def write_binary_data(filename, data, dtype=float):
 """
 Write binary data to a file and make sure it is always in little 
endian format.
 """
 f = open(filename, "wb")
 _data = N.asarray(data, dtype)
 # check byteorder of the system, convert to little endian if needed
 if sys.byteorder == 'big':
 _data = _data.byteswap()
 f.write(_data)
 f.close()

hth

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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


Re: [Matplotlib-users] Iterate and save multiple plots

2007-03-20 Thread Steve Schmerler
Ana Paula Leite wrote:
> Dear all,
> 
> I have a list with about 300 elements like the following:
> listNames = ['name1', 'name2', 'name3', ...]
> 
> I want to iterate through this list, creating several figures where each 
> one will include two subplots.
> The problem is that I want to label each figure like in the following 
> example:
> 
> 'name1_name2.png'
> 
> How do I concatenate those names in the savefig() function?
> 

How about

name = "%s_%s.png" %(listNames[0], listNames[1])
savegig(name)

or

name = listNames[0] + "_" + listNames[1] + ".png"

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] how to plot

2007-04-02 Thread Steve Schmerler
massimo sandal wrote:
> javi markez bigara ha scritto:
>> hi everyone,
>> i would like to know how to plot several linear regresions with the 
>> same group of points

Don't understand exactly what you want to do ...

> 
> what do you mean?
> 
> however, if you dig the matplotlib and the scipy documentation, you'll 
> find (a)how to plot points (easy) (b)how to calculate linear regressions 
> (this one is less straightforward than it should be, however now I don't 
> remember the details - I can check my code if you have trouble in 
> finding it by yourself).

One easy possibility (using numpy):


In [8]: import numpy as N

# make some sample data with noise
In [9]: x = N.linspace(0,10,100); y = 3*x + 5 + N.random.randn(len(x))*3

In [10]: p = N.polyfit(x, y, 1)

In [11]: p
Out[11]: array([ 3.02862193,  5.14341042])

In [12]: plot(x, y, 'o')
Out[12]: []

In [13]: plot(x, N.polyval(p,x), 'r')
Out[13]: []


Note: matplotlib also has random numbers (e.g. pylab.randn, but I think 
this is imported from numpy), as well as linspace and also polyfit and 
polyval, so importing numpy wouldn't even be necessary here. Another 
lin. reg. function is scipy.stats.linregress  All roads lead to Rome.

-- 
cheers,
steve

Random number generation is the art of producing pure gibberish as 
quickly as possible.

-
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] SVG vs PNG

2007-05-12 Thread Steve Schmerler
Fernando Perez wrote:
> 
> Did you install pstoedit?  If you do, you'll see that inkscape will
> then be able to load .eps/.ps files in a fully editable format.  I've
> used it to fix decade-old plots for which the only thing around was
> the eps file.
> 

I tried to export an .svg from MPL (0.90.0rev3131) with
rcParams['text.usetex']=True and got a NotImplementedError (same for the pdf 
backend
with usetex, see attached log). I was wondering: Is it (technically) possible 
to have
.svg export capabilities with usetex-support and if so, has there been no need 
for
this feature so far (not that I need it urgently, just curious..)?

Anyway, to work with MPL-images (.ps/.eps) in Inkscape, I installed pstoedit but
loading these files doesn't work (seems not to recognize them as images).
Sorry if I'm driving the Inkscape-stuff a bit OT here, but:
What version of Inkscape & friends are you using? I'm using pstoedit 3.44, 
Inkscape
0.44.1. The Latex-formula-feature of Inkscape is also not working and the error 
seems
related to pstoedit. Maybe someone had similar experiences ...

Thanks for any hint!

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. -- 
Douglas Adams

Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 796, in savefig
return fig.savefig(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 732, in savefig
self.canvas.print_figure(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py", line 114, in print_figure
orientation, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 483, in print_figure
orientation, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_svg.py", line 330, in print_figure
self.figure.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 574, in draw
for a in self.axes: a.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/axes.py", line 1285, in draw
a.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/axis.py", line 601, in draw
tick.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/axis.py", line 176, in draw
if self.label1On: self.label1.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/text.py", line 905, in draw
Text.draw(self, renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/text.py", line 415, in draw
self._fontproperties, angle)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backend_bases.py", line 383, in draw_tex
raise NotImplementedError
NotImplementedError
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] figure dpi output problem

2007-05-26 Thread Steve Schmerler
Jeff Whitaker wrote:
> [EMAIL PROTECTED] wrote:
>> I'm trying to get matplotlib to make a 600x300 png, but matplotlib won't
>> let me; it keeps making a 612x312 png instead.  Here's a sample script
>> that has the problem on my system:
>>
>> figure(figsize=(6., 3.))
>> plot(arange(10))
>> savefig('test.png', dpi=100.)
>>
>> If I set dpi to 50., it makes a 312x162 png.  It appears to be adding a 6
>> pixel border to the edge of all the pngs.  How do I get rid of it?
>>
>> Windows XP SP2, Python 2.5, matplotlib 0.90.
>>
>> Jordan
>>
>>   
> 
> I get a 600x300 png with that script, using the latest SVN.
> 
> -Jeff
> 

Me too, on Linux, mpl 0.90dev3131. If it's adding a constant border of 6 on two
sides, can you tell mpl to export e.g. 588x288 (more hack than solution, 
though...)?

-- 
cheers,
steve

I love deadlines. I like the whooshing sound they make as they fly by. -- 
Douglas Adams


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users