Re: [Matplotlib-users] DreamPie (a new Python shell) and matplotlib

2010-09-03 Thread Eric Firing
On 09/02/2010 07:47 PM, Noam Yorav-Raphael wrote:
> Hello,
>
> I'm the developer of DreamPie, a new graphical Python shell (you can
> check it out at http://dreampie.sourceforge.net )
>
> I worked to make it work nicely with matplotlib -- it runs Tk/GTK/Qt
> event loops when idle, so if matplotlib is in interactive mode it
> works great. I even made DreamPie check if matplotlib in
> non-interactive mode is present, and if so it shows you a message
> suggesting that you switch to interactive mode.
>
> Lately I thought that it may be much easier for users if DreamPie
> would just switch matplotlib to interactive mode automatically.
> However, I'm not entirely comfortable with the idea of changing
> settings silently.
>
> I wanted to ask: what do you think? Are there any cases when you want
> to have matplotlib in non-interactive mode in a shell?

At least with ipython, yes--the point of non-interactive mode is that 
the show() function blocks, so it can be used in scripts in which the 
user is supposed to see a plot, dismiss the window, see another plot, 
etc. Again, at least with ipython, one wants to be *able* to run scripts 
exactly as they would run from the command line.

Whether this sort of thing matters for DreamPie depends on the intended 
uses and users.

Eric

>
> Also, are there any other ways in which DreamPie can be made more
> matplotlib-friendly?
>
> Thanks,
> Noam
>
> --
> 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


--
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] bug? line misses points with negative coordinates

2010-09-03 Thread Sébastien Barthélemy
Hello,

While using sage [1], I got problems drawing a line: for some reason,
the points with negative coordinates are not plotted (or are plotted
on top of others due to an offset problem and thus I cannot see them).
I can only reproduce the bug with specific data sets.

I think I could track down the bug to matplotlib, which sage uses to
render 2d plots.

I included a sage script which generates the data set (in a pickle
file), and a python script which draws the faulty line.

Usage is :

$ sage generate_data.sage
$ python test_mpl.py

I also included the pickled data, thus you don't need sage at all.
I use matplotlib 1.0.0 for python 2.6 on mac os (as provided by macport).

Could somebody here confirm the problem, and give me a hint about what
is going on?

Regards
Sebastien

[1] www.sagemath.org


generate_data.sage
Description: Binary data


test_mpl.py
Description: Binary data


traj_mod.pickle
Description: Binary data
--
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] bug? line misses points with negative coordinates

2010-09-03 Thread Tony S Yu

On Sep 3, 2010, at 4:33 AM, Sébastien Barthélemy wrote:

> Hello,
> 
> While using sage [1], I got problems drawing a line: for some reason,
> the points with negative coordinates are not plotted (or are plotted
> on top of others due to an offset problem and thus I cannot see them).
> I can only reproduce the bug with specific data sets.
> 
> I think I could track down the bug to matplotlib, which sage uses to
> render 2d plots.
> 
> I included a sage script which generates the data set (in a pickle
> file), and a python script which draws the faulty line.
> 
> Usage is :
> 
> $ sage generate_data.sage
> $ python test_mpl.py
> 
> I also included the pickled data, thus you don't need sage at all.
> I use matplotlib 1.0.0 for python 2.6 on mac os (as provided by macport).
> 
> Could somebody here confirm the problem, and give me a hint about what
> is going on?

I can confirm the issue. This appears to be a drawing bug: when I pan the 
drawing so that the negative data touches the edge of the axes frame, the rest 
of the line is drawn. So the line object is being created, but for some reason 
it's not being drawn correctly.

The bug is really finicky: if I plot starting from the 3rd value of your data 
(i.e. slice xdata, ydata with [2:]), the line is drawn completely. The strange 
thing is that the first 100 or so data points defines the exact same point, so 
there's noting special about those first two points. (but this overlaying of 
data may be related to the bug)

I've reproduced the issue on TkAgg, Qt4Agg, and MacOSX backends, so maybe the 
bug is in backend_bases. (Note: unlike Agg backends, MacOSX backend doesn't 
show line even after panning the plot)

I don't really know how to debug drawing errors like this; so this is as far as 
can get.

Best,
-Tony

> 
> Regards
> Sebastien
> 
> [1] www.sagemath.org
> 

--
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] legend: changing the text colour

2010-09-03 Thread karianne

Hi,

I am plotting several different symbols using 3 different colours. The
colours indicate different data sets, whereas the symbols need not be
explained. I would therefore like each label to have a different colour,
i.e. each line in my legend should be written in a different colour
specified. The legend is getting too long if I have to indicate what each
symbol represents, plus it would be a repetition of the 3 data sets in
question. How can I change the colour of the text in the legend?

Second, how can I change the marker in the legend? I am plotting using
errorbar(), but the marker shows up as a dot, and I would like it to show up
as a '+', without having to change the actual dots in the plot.

Here is a snippet of my code:

import matplotlib as mpl
import matplotlib.pyplot as plt

fig = plt.figure(); ax = []
for k in range(1,4):
ax.append(fig.add_subplot(3,1,k))
for [data,col,leg] in
[[data1,'k','set1'],[data2,'r','set2'],[data3,'b','both']]:
   
ax[-1].errorbar(data[:,2],data[:,4],xerr=data[:,3],yerr=data[:,5],fmt='.',color=col,label=leg)
ax[-1].plot(x,y,'-',color=col,label=leg)
lgd=ax[-1].legend(loc='lower right')
#this is what I tried to change the symbols in the legend, but it
also changes the plot
#symbols and I would like to avoid that:
plt.setp(lgd.get_lines(), marker='+')


I have searched this forum, other forums, and google, without finding an
answer to my questions. If there is another post or webpage already dealing
with these problems I apologise for posting them here too and ask you to
please direct me to the right pages.

Cheers, Karianne
-- 
View this message in context: 
http://old.nabble.com/legend%3A-changing-the-text-colour-tp29614647p29614647.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
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] bug? line misses points with negative coordinates

2010-09-03 Thread Sébastien Barthélemy
CC to matplotlib-devel & matplotlib-users

2010/9/3 Tony S Yu :
> On Sep 3, 2010, at 4:33 AM, Sébastien Barthélemy wrote:
>
>> Hello,
>>
>> While using sage [1], I got problems drawing a line: for some reason,
>> the points with negative coordinates are not plotted (or are plotted
>> on top of others due to an offset problem and thus I cannot see them).
>> I can only reproduce the bug with specific data sets.
>>
>> [1] www.sagemath.org
>>
>> I think I could track down the bug to matplotlib, which sage uses to
>> render 2d plots.
>>
>> I included a sage script which generates the data set (in a pickle
>> file), and a python script which draws the faulty line.
>>
>> Usage is :
>>
>> $ sage generate_data.sage
>> $ python test_mpl.py
>>
>> I also included the pickled data, thus you don't need sage at all.
>> I use matplotlib 1.0.0 for python 2.6 on mac os (as provided by macport).
>>
>> Could somebody here confirm the problem, and give me a hint about what
>> is going on?
>
> I can confirm the issue.

Great, thank you. I filed a bug:
https://sourceforge.net/tracker/?func=detail&aid=3058804&group_id=80706&atid=560720

> This appears to be a drawing bug: when I pan the drawing so that the negative 
> data touches the edge of the axes frame, the rest of the line is drawn. So 
> the line object is being created, but for some reason it's not being drawn 
> correctly.
>
> The bug is really finicky: if I plot starting from the 3rd value of your data 
> (i.e. slice xdata, ydata with [2:]), the line is drawn completely. The 
> strange thing is that the first 100 or so data points defines the exact same 
> point, so there's noting special about those first two points. (but this 
> overlaying of data may be related to the bug)
>
> I've reproduced the issue on TkAgg, Qt4Agg, and MacOSX backends, so maybe the 
> bug is in backend_bases. (Note: unlike Agg backends, MacOSX backend doesn't 
> show line even after panning the plot)
>
> I don't really know how to debug drawing errors like this; so this is as far 
> as can get.

--
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] How to get all data points plotted/displayed in a line plot

2010-09-03 Thread Eric Firing
On 08/31/2010 01:08 AM, Jens Nie wrote:
> Hi everyone.
> I face a problem here, which I can’t seem to handle by myself, so any
> help is really appreciated.
> I would like to do a simple line plot of a huge dataset as an overview
> to quickly compare success of different measurement scenarios, and it
> seems that not every datapoint is displayed. I played a little with the
> lod parameter, both for the creation of the axis and the plot command.
> However timing the plot command and the display itself do not show
> differences. Here are a few lines of code that help to reproduce the
> problem.

Jens,

I'm confident this is the same bug as was reported more recently on the 
list and the tracker:

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

That report will make it easier to debug because it illustrates the 
problem with a relatively few points.


Eric

> import time
> import matplotlib
> matplotlib.use("Qt4Agg")
> import matplotlib.pyplot as plt
> import numpy as np
> xData=np.linspace(0, 10.0, 1e6)
> yData=np.zeros(xData.shape)
> xDataDetail=np.linspace(0.0, 2*np.pi, 1000)
> yDataDetail=np.exp(-xDataDetail)*np.sin(10.0*xDataDetail)
> yData[10:10+len(yDataDetail)]=yDataDetail
> fig=plt.figure()
> axes=fig.add_subplot(111)
> tic=time.time()
> axes.plot(xData, yData, "b-")
> toc=time.time()
> axes.grid(True)
> print "Plotting took %g s." % (toc-tic)
> plt.show()
> The code shows how I usually use the matplotlib environment and creates
> a simple dataset of 1 million zeros with a short non trivial peak
> within, that is to be plotted as a blue solid line.
> You can see what happens, when you vary the width of the displaying
> window. On my system usually the minimum amplitude varies when resizing
> the window.
> 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
>
>
>
> --
> 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



--
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] bug? line misses points with negative coordinates

2010-09-03 Thread Tony S Yu

On Sep 3, 2010, at 10:23 AM, Sébastien Barthélemy wrote:

> CC to matplotlib-devel & matplotlib-users
> 
> 2010/9/3 Tony S Yu :
>> On Sep 3, 2010, at 4:33 AM, Sébastien Barthélemy wrote:
>> 
>>> Hello,
>>> 
>>> While using sage [1], I got problems drawing a line: for some reason,
>>> the points with negative coordinates are not plotted (or are plotted
>>> on top of others due to an offset problem and thus I cannot see them).
>>> I can only reproduce the bug with specific data sets.
>>> 
>>> [1] www.sagemath.org
>>> 
>>> I think I could track down the bug to matplotlib, which sage uses to
>>> render 2d plots.
>>> 
>>> I included a sage script which generates the data set (in a pickle
>>> file), and a python script which draws the faulty line.
>>> 
>>> Usage is :
>>> 
>>> $ sage generate_data.sage
>>> $ python test_mpl.py
>>> 
>>> I also included the pickled data, thus you don't need sage at all.
>>> I use matplotlib 1.0.0 for python 2.6 on mac os (as provided by macport).
>>> 
>>> Could somebody here confirm the problem, and give me a hint about what
>>> is going on?
>> 
>> I can confirm the issue.
> 
> Great, thank you. I filed a bug:
> https://sourceforge.net/tracker/?func=detail&aid=3058804&group_id=80706&atid=560720
> 
>> This appears to be a drawing bug: when I pan the drawing so that the 
>> negative data touches the edge of the axes frame, the rest of the line is 
>> drawn. So the line object is being created, but for some reason it's not 
>> being drawn correctly.
>> 
>> The bug is really finicky: if I plot starting from the 3rd value of your 
>> data (i.e. slice xdata, ydata with [2:]), the line is drawn completely. The 
>> strange thing is that the first 100 or so data points defines the exact same 
>> point, so there's noting special about those first two points. (but this 
>> overlaying of data may be related to the bug)
>> 
>> I've reproduced the issue on TkAgg, Qt4Agg, and MacOSX backends, so maybe 
>> the bug is in backend_bases. (Note: unlike Agg backends, MacOSX backend 
>> doesn't show line even after panning the plot)
>> 
>> I don't really know how to debug drawing errors like this; so this is as far 
>> as can get.

I'm not sure if I should respond to this email or the bug report, but since I 
made the claim here, I'll correct myself here: The bug is not in the drawing 
code as I had suggested. 

The bug is related to path simplification. If you turn off path simplification 
(e.g. plt.rc('path', simplify=False), the line is drawn in its entirety. This 
also explains why the bug disappeared when I trimmed the first two points: path 
simplification is triggered from data sets with atleast 128 points (your data 
has 129, so trimming two points turned off path simplification).

I just wanted to correct my earlier comments.

-T



--
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] legend: changing the text colour

2010-09-03 Thread Jae-Joon Lee
On Fri, Sep 3, 2010 at 11:04 PM, karianne  wrote:
> Hi,
>
> I am plotting several different symbols using 3 different colours. The
> colours indicate different data sets, whereas the symbols need not be
> explained. I would therefore like each label to have a different colour,
> i.e. each line in my legend should be written in a different colour
> specified. The legend is getting too long if I have to indicate what each
> symbol represents, plus it would be a repetition of the 3 data sets in
> question. How can I change the colour of the text in the legend?

Do something like

l1, = plot([1,2,3])
leg = legend([l1], ["Test"])

leg_texts = leg.get_texts() # list of matplotlib Text instances.
leg_texts[0].set_color("b")


>
> Second, how can I change the marker in the legend? I am plotting using
> errorbar(), but the marker shows up as a dot, and I would like it to show up
> as a '+', without having to change the actual dots in the plot.

I think it is best to use a proxy artist.

http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

For example,


col, leg = "b", "test"
errorbar([1,2,3], [1,2,1],xerr=[0.1, 0.1, 0.1], yerr=[0.1, 0.1, 0.1],
 fmt='.',color=col)
l2, = plot([],[], "+", color=col)
l2.remove() # remove from the axes

legend([l2], [leg])


IHTH,

-JJ

ps. A code snippet, that cannot be run standalone, is not very useful.
If you do not want to post your own data, use some fake data.

--
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