Re: [Matplotlib-users] How to get all data points plotted/displayed in a line plot

2010-09-01 Thread Jens Nie
Hi Ben.

It is the version 1.0.0 that i am using, both on Linux and windows. Is there 
any newer (development) version that I should try?

Jens


[...]

Is there any way to enforce plotting each and every point?

I use matplotlib version 1.0.0 on a 32 Bit windows XP system installed via the 
windows installer from sf.
A quick check on a opensuse 11.3 linux box showed the same issue. Using the 
"standard" TK backend instead of Qt4Agg behaves just the same.

Jens


Jens,

Which version of matplotlib are you using?  I wonder if this is the 
path.simplify bug that was fixed for 1.0.

Essentially, there was a bug in some code that caused some points to be skipped 
in the process of displaying images that had datapoints that were closer 
together than could be resolved.  I suspect this is what is happening here, 
because everything looks fine on my latest build.

Ben Root
--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problems with autoscale_view

2010-09-01 Thread xyz

On 30/08/10 23:34, Ryan May wrote:

On Mon, Aug 30, 2010 at 4:44 AM, xyz  wrote:

On 30/08/10 03:51, Benjamin Root wrote:

maxy = max(max(y1), max(y2))
maxx = max(x)

ax.set_xlim((0.0, maxx))
ax.set_ylim((0.0, maxy))

Thank you, but unfortunately I have still the same problems:
* plt.text appears outside x and y coordinates
* and the coordinates starts not from 0

with the updated code:
from pylab import *
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
y1 = [20, 24, 8, 4, 12, 22, 31, 25, 15, 28, 12, 27, 22, 22, 27, 14, 32,
28, 8, 17, 2, 8, 29, 13, 14, 20, 11, 28, 8]
y2= [2, 32, 28, 1, 22, 11, 14, 27, 3, 31, 12, 20, 32, 24, 24, 16, 7, 10,
12, 11, 3, 32, 10, 20, 14, 14, 3, 25, 14]
point_labels1 = ['A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1',
'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1',
'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1',
'A=1']
point_labels2 = ['B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1',
'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1',
'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1',
'B=1']

fig = plt.figure()
ax = fig.add_subplot(111)

ax.set_title('The red point should be on the path')

plt.plot(x, y1, 'bo', x, y2, 'go')
ax.grid(True)
maxy = max(max(y1), max(y2))
maxx = max(x)

ax.set_xlim((0.0, maxx))
ax.set_ylim((0.0, maxy))

fig.autofmt_xdate()

plt.xticks(range(0, 40, 1))

plt.yticks(range(0, 40, 1))
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.legend(('Model length', 'Data length'),
'best', shadow=True, fancybox=True)

for i, label in enumerate(y1):
   plt.text (x[i], y1[i]+0.2, label,
 horizontalalignment='center' )

for i, label in enumerate(y2):
   plt.text (x[i], y2[i]+0.2, label,
 horizontalalignment='center' )


ax.autoscale_view()
plt.savefig('test.png')
plt.show()

What did I wrong?

Like Eric said, the call to ax.autoscale_view() overrides the limits
you set by hand. Remove this line.

Ryan

Thank you, now are plt.text in the coordinates. Unfortunately, now 
overlapping the x and y coordinates.


How is it possible to solve this problem?
--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problems with autoscale_view

2010-09-01 Thread Benjamin Root
On Wed, Sep 1, 2010 at 7:21 AM, xyz  wrote:

>  On 30/08/10 23:34, Ryan May wrote:
>
> On Mon, Aug 30, 2010 at 4:44 AM, xyz   wrote:
>
>
> On 30/08/10 03:51, Benjamin Root wrote:
>
>
> maxy = max(max(y1), max(y2))
> maxx = max(x)
>
> ax.set_xlim((0.0, maxx))
> ax.set_ylim((0.0, maxy))
>
>
> Thank you, but unfortunately I have still the same problems:
> * plt.text appears outside x and y coordinates
> * and the coordinates starts not from 0
>
> with the updated code:
> from pylab import *
> import matplotlib.pyplot as plt
>
> x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
> 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
> y1 = [20, 24, 8, 4, 12, 22, 31, 25, 15, 28, 12, 27, 22, 22, 27, 14, 32,
> 28, 8, 17, 2, 8, 29, 13, 14, 20, 11, 28, 8]
> y2= [2, 32, 28, 1, 22, 11, 14, 27, 3, 31, 12, 20, 32, 24, 24, 16, 7, 10,
> 12, 11, 3, 32, 10, 20, 14, 14, 3, 25, 14]
> point_labels1 = ['A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1',
> 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1',
> 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1', 'A=1',
> 'A=1']
> point_labels2 = ['B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1',
> 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1',
> 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1', 'B=1',
> 'B=1']
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
>
> ax.set_title('The red point should be on the path')
>
> plt.plot(x, y1, 'bo', x, y2, 'go')
> ax.grid(True)
> maxy = max(max(y1), max(y2))
> maxx = max(x)
>
> ax.set_xlim((0.0, maxx))
> ax.set_ylim((0.0, maxy))
>
> fig.autofmt_xdate()
>
> plt.xticks(range(0, 40, 1))
>
> plt.yticks(range(0, 40, 1))
> plt.xlabel('Longitude')
> plt.ylabel('Latitude')
> plt.legend(('Model length', 'Data length'),
> 'best', shadow=True, fancybox=True)
>
> for i, label in enumerate(y1):
>plt.text (x[i], y1[i]+0.2, label,
>  horizontalalignment='center' )
>
> for i, label in enumerate(y2):
>plt.text (x[i], y2[i]+0.2, label,
>  horizontalalignment='center' )
>
>
> ax.autoscale_view()
> plt.savefig('test.png')
> plt.show()
>
> What did I wrong?
>
>
> Like Eric said, the call to ax.autoscale_view() overrides the limits
> you set by hand. Remove this line.
>
> Ryan
>
>
>
> Thank you, now are plt.text in the coordinates. Unfortunately, now
> overlapping the x and y coordinates.
>
> How is it possible to solve this problem?
>
>
I am not sure I understand what you mean.  Could you please attach an image
of the problem?

Ben Root
--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] remove matplotlib an OS X

2010-09-01 Thread Christopher Barker
vbkhp wrote:
> Hi,
> 
> Could anyone tell me how can I remove matplotlib completely on Mac? 

> I  was on version 0.99 and I wanted to upgrade to version 1.0 so i removed
> the matplotlib directory and the egg file (besides the pylab.py,
> pylab.pyo, and pylab.pyc files),

That should have done it -- except perhaps for your matplotlibrc 
file(s), but you may want to keep that anyway.

> and installed the new version using
> .dmg file "matplotlib-1.0.0-python.org-py2.6-macosx10.4". Now, I can
> import and work with pylab when I call it from the terminal, but I can
> not import it other places like IDLE. I get the following error.

If it's different from IDLE than the command line, that indicates that 
you may be running two different versions of Python. You have at least 
two -- the one that Apple supplied and the python.org one.

> Process: Python [922]
> Path:
> /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

This is the python.org one -- which is where that dmg file should have 
put the new matplotlib. So which are you running when you use the 
command line?

one way to tell is with by checking the __file__ attribute on an 
arbitrary module:

In [10]: import numpy

In [11]: numpy.__file__
Out[11]: 
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/__init__.pyc'

So mine is the python.org one -- the Apple one is in /System/

Once you've got that cleared up, at least you can know where your 
problem is -- sorry I can't help you with that crash report.

One more thought -- IDLE uses TK, ans so does (optionally) MPL -- 
perhaps there is a version conflict there? (I'm not a IDLE or Tk user, 
so I don't know if that's likely). You might try testing other back ends:

import matplotlib
matplotlib.use('agg')

for instance.

-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

chris.bar...@noaa.gov

--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem with errorbar in log scale

2010-09-01 Thread Thomas Robitaille
Hi,

When using log scale, if the error is larger than flux, the error bar does not 
plot at all:

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.errorbar([1.],[1.],yerr=[2.])
ax.set_yscale('log')
fig.savefig('test.png')

However, I think it would make more correct to plot the line for the errorbar, 
and to make it go down to -infinity. Would it be possible to fix this? I have 
submitted a bug report:

https://sourceforge.net/tracker/?func=detail&aid=3057653&group_id=80706&atid=560720

Thanks,

Thomas--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] change font name (under certain font.family)

2010-09-01 Thread Stan West
From: Yi Shang [mailto:mirandaisb...@gmail.com] 
Sent: Friday, August 27, 2010 17:33
 
Hi Ben,
Thanks for the reply. I did try to match font.family and font.$family and I am
using matplotlib 0.99.0. 
I did find something interesting...
 
For testing, I tried only using font.family line, (deleting font.$family
line). I got reasonable font for "monospace", "fantasy" "sans-serif" and
"serif" family, but "cursive" looked exactly the same as "sans-serif", which
is the default font.family value.

Do you have any of the fonts in plt.rcParams['font.cursive']? If not,
matplotlib falls back to another font. You might have gotten a warning message
of the form "... font_manager.py:1242: UserWarning: findfont: Font family
['cursive'] not found. Falling back to Bitstream Vera Sans".

Then, I added font.$family line. When font.family and font.$family  match, as
you suggested, I always get the default font as if I only specified
font.family as sans-serif. {''font.family' : 'fantasy',  'font.fantasy' :
'Chicago'} gives me the default font, {''font.family' : 'fantasy',
'font.fantasy' : 'foo'} also gives me the default font ('Chicago is actually
in 'fantasy' family, 'foo' is not). 
 
Then I tried to mismatch font.family and font.$family, since they are not
matching, font.$family is not taking effect, I am getting whatever font.family
line is giving me.
 
I think the syntax I used may be wrong. Anyone has any idea how to specify a
specific font name within a font family?

The font families font.sans-serif, font.serif, etc., must be lists of names of
fonts, whereas font.family is a string naming either one of the families or a
font. So, you could use either

params = {'font.family' : 'sans-serif', 'font.sans-serif' : ['Arial']}

or

params = {'font.family' : 'Arial'}

to specify a font.

--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] draw after set_data

2010-09-01 Thread Philippe Crave
Hi,

I use qt4 backend.
I update some lines doing something like that:

   def draw_curves(self, datas, x):
   for y in datas:
   self.lines[i].set_data(x, y)
   min_y, max_y = self.min_max(y)
   self.ax[i].axis((0, x[-1], min_y, max_y))
   #self.ax[i].draw_artist(self.lines[i])
   #self.fig.canvas.blit(self.ax[i].bbox)
   self.fig.canvas.draw()


the self.fig.canvas.draw() is very slow. (I have 20 subplot in that figure).
I tried to use:
   self.ax[i].draw_artist(self.lines[i])
   self.fig.canvas.blit(self.ax[i].bbox)
it's very fast. But it does not update the scale of the plot.
and it does not remove the old datas.

Can someone help me on that ?
if I plot a sin(x) at first, I get it between 0 and 1. then, if I plot
2.sin(x), it does not update the zoom to 0-2

thank you,
Philippe

--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Change default font

2010-09-01 Thread Ali Fessi
  Hi,

is there a way to change the default font, e.g., to Times New Roman?! 
I've been looking at the rcparams but it's kind of confusing.

Cheers.

--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Change default font

2010-09-01 Thread Tony S Yu

On Sep 1, 2010, at 5:10 PM, Ali Fessi wrote:

>  Hi,
> 
> is there a way to change the default font, e.g., to Times New Roman?! 
> I've been looking at the rcparams but it's kind of confusing.
> 
> Cheers.


Yes, but first you should make sure the font is on your system and is of the 
correct type, i.e. TrueType (TTF). AND you have to make sure know the name of 
it (some fonts may have names that aren't obvious). To check the name, type the 
following in the python interpreter:

>>> from matplotlib import font_manager
>>> font_manager.findfont('Times New Roman')

If the font manager finds it, then it should return the path to a ttf file with 
a similar name; otherwise, it'll return some default font (on my system 
Vera.ttf).

Assuming you've got all that sorted out, you can set the default font in each 
script, or in your matplotlibrc file (i.e. globally). But first note that Times 
New Roman is a serif font; matplotlib uses sans-serif fonts by default (at 
least on my system). So if you decide to go with Times New Roman, or another 
serif font, you need to change the font family, as well. Here's some examples

1) In a script, add:

import matplotlib.pyplot as plt
plt.rc('font', family='serif')
plt.rc('font', serif='Times New Roman')


2) In your matplotlibrc file, add:

font.family: serif
font.serif: Times New Roman

Best,
-Tony
--
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users