[Matplotlib-users] spines versus subplotzero

2009-08-02 Thread jason-sage
I'm trying to understand some of the changes in 0.99, for example, the 
recommended way of getting a plot so that the axes cross at the origin 
(i.e., the axes are in the middle of the plot).  I see two examples that 
seem to give this:

http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html

http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline2.html

Is one or the other of these methods the recommended way to get a plot 
with axes in the middle that cross at the origin?  Or are they both good 
and apply to different situations?


Thanks,

Jason

--
Jason Grout


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] show figures in a loop

2009-08-02 Thread Janwillem

I have an application where I would like to use show in a loop but as stated
in 18.1 of the manual that does not work.
# WARNING : illustrating how NOT to use show
for i in range(10):
# make figure i
show()
So I made a workaround in a custom wxDialog with a wxStaticBitmap and a few
buttons and put the matplotlib figure in the bitmap with something like:
wi,hi = figure.get_size_inches()
width,height = bitmap_plot.GetSize()
dpi = int(min(width/wi,height/hi))
figure.savefig('/tmp/tmp.png',dpi = dpi)
image = wx.Image('/tmp/tmp.png',wx.BITMAP_TYPE_ANY)
bitmap = wx.BitmapFromImage(image)
bitmap_plot.SetBitmap(bitmap)
Thus scaling the figure using the dpi option of savefig and then loading it
into the wxStaticBitmap.

To me it seems there might be a lot of unnecessary data handling. What is
the clever solution?
mant thanks
-- 
View this message in context: 
http://www.nabble.com/show-figures-in-a-loop-tp24776045p24776045.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] show figures in a loop

2009-08-02 Thread Sandro Tosi
Hello Janwillem,

On Sun, Aug 2, 2009 at 14:11, Janwillem wrote:
>
> I have an application where I would like to use show in a loop but as stated
> in 18.1 of the manual that does not work.
> # WARNING : illustrating how NOT to use show
> for i in range(10):
>    # make figure i
>    show()

call show() outside teh loop:

for i in :

plt.show()

and that would show all the figure generated up to there.

> So I made a workaround in a custom wxDialog with a wxStaticBitmap and a few

so, you want to embed in a WxWidgets application?

> To me it seems there might be a lot of unnecessary data handling. What is
> the clever solution?

Is the solution above fine for you?

Probably if you explain us better what you want to achieve, we can
help you in a better way.

Regards,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] spines versus subplotzero

2009-08-02 Thread John Hunter
On Sun, Aug 2, 2009 at 2:14 AM,  wrote:
> I'm trying to understand some of the changes in 0.99, for example, the
> recommended way of getting a plot so that the axes cross at the origin
> (i.e., the axes are in the middle of the plot).  I see two examples that
> seem to give this:
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html
>
> http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline2.html
>
> Is one or the other of these methods the recommended way to get a plot
> with axes in the middle that cross at the origin?  Or are they both good
> and apply to different situations?

I'll let Andrew and JJ fill in some color, since they wrote the spine
and axes_grid, respectively, but both are good.  The spines are in the
mainline and JJ's solution is in a toolkit, so when in doubt go with
something in the mainline since that is more likely to be stable.
Both JJ and Andrew will be attending the scipy sprint this year (if
you're going to be there be sure to stop by), and one of the items on
our agenda is to incorporate their work into a unified API in the
mainline.  So there may be some changes to one or both approaches, but
hopefully soon we will have most of the feature set of both in our
main axis code.

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend neutral idle event won't repeat

2009-08-02 Thread John Hunter
On Sat, Aug 1, 2009 at 12:05 PM, Mark Rubelmann wrote:
> Hi,
>
> I'm writing a script to plot data being read from a serial connection in
> real time.  I'm trying to use an idle_event callback to continually read the
> incoming data and plot it.  The problem is that the callback is only getting
> invoked once.  I found this page:
> http://www.scipy.org/Cookbook/Matplotlib/Animations, which suggests using
> backend-specific stuff.  This is intended to be a quick-and-dirty thing
> though so I was really hoping to avoid that.  Here's my code:

Wriing a GUI neutal idle event handler is not easy -- I've spent some
time on it but crashed and burned on tk -- but my guess is that the
problem you are having in your code is that GTK expects you to return
True is you want the func to be called again.  As soon as you return
False the event handler is terminated.  You return nothing, which is
None, which is False.  A simple "return True" may cure what ails you
vis-a-vis gtk.  But pylab animation is not supported, so I suggest
that you code to your GUI of choice for animation until we get a
proper GUI neutral animation event API.

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Set tight axis for log? / axis('tight') doesn't work

2009-08-02 Thread plaf

Dear all,
I need some help :)

I have been trying to plot several subplots, with the y axis being in linear
and the x axis in log.

I need both axis to be tight to the data.

Here's what I have:

import wx
import scipy.io.matlab as matlab
import numpy
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.pyplot import *
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import \
FigureCanvasWxAgg as FigCanvas, \
NavigationToolbar2WxAgg as NavigationToolbar
from pylab import *

fig = Figure((6.5, 5.0), dpi=100)
axes = fig.add_subplot(xlen,ylen,pos, polar=False, autoscale_on=False)

 axes.errorbar(data1[0,0][0], mean(data2[n],1),
(var(data2[n],1)/sqrt(len(data2[n]))),
(var(data2[n],1)/sqrt(len(data2[n]
axes.set_xscale('log')
axes.axis('tight') 
axes.set_ylim([0,max(mean(tuning[n],1))*1.2+0.1])
   
I also used to have error (AttributeError: 'MaskedArray' object has no
attribute 'putmask') with this code.

I have been looking for solution in forum archive, and someone suggested
using set_autoscale_on(False) but I tried and this didn't work.

Any help would be much much appreciated!
Thanks!
-- 
View this message in context: 
http://www.nabble.com/Set-tight-axis-for-logaxis%28%27tight%27%29-doesn%27t-work-tp24777527p24777527.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] show figures in a loop

2009-08-02 Thread Janwillem

The problem:
I have files with time versus signal data of a large series of measurements.
The python application (using wxPython actually) scans the file, applies
some math (numpy/scipy) on each record of data and than must show the signal
as a plot. After clicking OK the next record of measurement data is
processed and  shown. So I do need some construct that allows showing a
series of figure one after the other. My solution works ok but I would think
that there should be an elegant shortcut that directly scales the
mathplotlib figure to a bitmap that can be shown.
Does that better explain the purpose of my question?
Cheers,Janwillem



Janwillem wrote:
> 
> I have an application where I would like to use show in a loop but as
> stated in 18.1 of the manual that does not work.
> # WARNING : illustrating how NOT to use show
> for i in range(10):
> # make figure i
> show()
> So I made a workaround in a custom wxDialog with a wxStaticBitmap and a
> few buttons and put the matplotlib figure in the bitmap with something
> like:
> wi,hi = figure.get_size_inches()
> width,height = bitmap_plot.GetSize()
> dpi = int(min(width/wi,height/hi))
> figure.savefig('/tmp/tmp.png',dpi = dpi)
> image = wx.Image('/tmp/tmp.png',wx.BITMAP_TYPE_ANY)
> bitmap = wx.BitmapFromImage(image)
> bitmap_plot.SetBitmap(bitmap)
> Thus scaling the figure using the dpi option of savefig and then loading
> it into the wxStaticBitmap.
> 
> To me it seems there might be a lot of unnecessary data handling. What is
> the clever solution?
> mant thanks
> 

-- 
View this message in context: 
http://www.nabble.com/show-figures-in-a-loop-tp24776045p2465.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend neutral idle event won't repeat

2009-08-02 Thread John Hunter
On Sun, Aug 2, 2009 at 8:08 AM, John Hunter wrote:

> Wriing a GUI neutal idle event handler is not easy -- I've spent some
> time on it but crashed and burned on tk -- but my guess is that the
> problem you are having in your code is that GTK expects you to return
> True is you want the func to be called again.  As soon as you return
> False the event handler is terminated.  You return nothing, which is
> None, which is False.  A simple "return True" may cure what ails you
> vis-a-vis gtk.  But pylab animation is not supported, so I suggest
> that you code to your GUI of choice for animation until we get a
> proper GUI neutral animation event API.

I should phrase this last bit differently: I would like to support
this, and spent a fair amount of time trying to get this working
properly across backends.  I think it *does* work on GTK and WX.  I
encountered some problems in tkagg: since tk does not have a native
idle event loop that I could wrap, I tried to use python threading to
implement it, and ran into problems with cross thread signal handling
(including losing CTRL-C and some strange on-exit behavior) so
commented out the code, and have not attempted qt or macosx.  I think
it would be great if we could abstract the idle handler and timeout
handler across the GUIs so that mpl animation would be easier, but to
date this has eluded me.  So in the meantime, I would stick to the API
of the GUI of your choice until we can get proper support for this as
an mpl event.

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] show figures in a loop

2009-08-02 Thread John Hunter
On Sun, Aug 2, 2009 at 8:14 AM, Janwillem wrote:
>
> The problem:
> I have files with time versus signal data of a large series of measurements.
> The python application (using wxPython actually) scans the file, applies
> some math (numpy/scipy) on each record of data and than must show the signal
> as a plot. After clicking OK the next record of measurement data is
> processed and  shown. So I do need some construct that allows showing a
> series of figure one after the other. My solution works ok but I would think
> that there should be an elegant shortcut that directly scales the
> mathplotlib figure to a bitmap that can be shown.
> Does that better explain the purpose of my question?

You are probably doing the best thing using wx for the event handling
in this app, but you do not need to save to png.  You can get access
to the rendered figure in code as either a python buffer or string,
using one of several *Agg backend methods, eg buffer_rgba,
tostring_rgb, tostring_argb.  See for example

  
http://matplotlib.sourceforge.net/examples/pylab_examples/agg_buffer_to_array.html

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend neutral idle event won't repeat

2009-08-02 Thread Mark Rubelmann
Thanks for the reply John.  Not quite the answer I was looking for
though ;)  I tried your suggestion of returning True but it didn't solve
the problem.  Oh well, not the end of the world.  Being a die-hard KDE user,
I started trying to get things working with Qt.  I got my animation working
but thus far haven't been able to catch key press events.  My guess is that
I'm just missing something about how it's supposed to be done so I'll
probably figure it out.

Thanks again,
Mark

On Sun, Aug 2, 2009 at 9:17 AM, John Hunter  wrote:

> On Sun, Aug 2, 2009 at 8:08 AM, John Hunter wrote:
>
> > Wriing a GUI neutal idle event handler is not easy -- I've spent some
> > time on it but crashed and burned on tk -- but my guess is that the
> > problem you are having in your code is that GTK expects you to return
> > True is you want the func to be called again.  As soon as you return
> > False the event handler is terminated.  You return nothing, which is
> > None, which is False.  A simple "return True" may cure what ails you
> > vis-a-vis gtk.  But pylab animation is not supported, so I suggest
> > that you code to your GUI of choice for animation until we get a
> > proper GUI neutral animation event API.
>
> I should phrase this last bit differently: I would like to support
> this, and spent a fair amount of time trying to get this working
> properly across backends.  I think it *does* work on GTK and WX.  I
> encountered some problems in tkagg: since tk does not have a native
> idle event loop that I could wrap, I tried to use python threading to
> implement it, and ran into problems with cross thread signal handling
> (including losing CTRL-C and some strange on-exit behavior) so
> commented out the code, and have not attempted qt or macosx.  I think
> it would be great if we could abstract the idle handler and timeout
> handler across the GUIs so that mpl animation would be easier, but to
> date this has eluded me.  So in the meantime, I would stick to the API
> of the GUI of your choice until we can get proper support for this as
> an mpl event.
>
> JDH
>
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend neutral idle event won't repeat

2009-08-02 Thread John Hunter
On Sun, Aug 2, 2009 at 10:35 AM, John Hunter wrote:
> On Sun, Aug 2, 2009 at 9:39 AM, Mark Rubelmann wrote:
>> Thanks for the reply John.  Not quite the answer I was looking for
>> though ;)  I tried your suggestion of returning True but it didn't solve
>> the problem.  Oh well, not the end of the world.  Being a die-hard KDE user,
>> I started trying to get things working with Qt.  I got my animation working
>> but thus far haven't been able to catch key press events.  My guess is that
>> I'm just missing something about how it's supposed to be done so I'll
>> probably figure it out.
>
> You should be able to use mpl key press events even while embedding in qt

oops posted in the wrong thing from my buffer.  Meant to post this link

http://matplotlib.sourceforge.net/search.html?q=codex+key_press_event

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend neutral idle event won't repeat

2009-08-02 Thread John Hunter
On Sun, Aug 2, 2009 at 9:39 AM, Mark Rubelmann wrote:
> Thanks for the reply John.  Not quite the answer I was looking for
> though ;)  I tried your suggestion of returning True but it didn't solve
> the problem.  Oh well, not the end of the world.  Being a die-hard KDE user,
> I started trying to get things working with Qt.  I got my animation working
> but thus far haven't been able to catch key press events.  My guess is that
> I'm just missing something about how it's supposed to be done so I'll
> probably figure it out.

You should be able to use mpl key press events even while embedding in qt

/Users/jdhunter/Library/Preferences/Aquamacs Emacs/customizations.el

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subplot [was: executing function when view interval changes]

2009-08-02 Thread Alan G Isaac
> On Sat, Aug 1, 2009 at 7:32 PM, Alan 
> G Isaac wrote:
>> Which reminds me, was there a decision on subplot2grid etc? 
>> http://sourceforge.net/mailarchive/message.php?msg_name=6e8d907b0905172009j21b5077fp242c7598ee9fb2c9%40mail.gmail.com>
>>  


On 8/2/2009 1:00 AM John Hunter wrote:
> There 
> are two pieces to this thread: the non-pythonic 1 based addressing of 
> the current subplot command ("don't blame me, talk to the mathworks"), 
> and the ability to easily specify column or row spans across the grid. 
>  The former is a minor wart that is unlikely to change, the latter is
> a significant feature that we should definitely support. 


I'm hoping you will "link" these two in the following way:
introduce a *new* command (e.g., subplot2grid) that supports
the spans *and* introduces Pythonic indexing.  (Then subplot
can just stick around as a less capable little brother with
Matlab-style indexing for as long as you deem necessary.)

Alan


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] show figures in a loop

2009-08-02 Thread Janwillem

Thanks for the hint, I now have:
#figure is a matplotlib Figure
#bitmap is a wx.StaticBitmap
w_figure, h_figure = figure.get_size_inches()
w_bitmap, h_bitmap = bitmap.GetSize()
dpi = int(min(w_bitmap/w_figure,h_bitmap/h_figure))
figure.set_dpi(dpi)
figure.canvas.draw()
w_canvas, h_canvas = figure.canvas.get_width_height()
buffer = figure.canvas.tostring_rgb()
bmp = wx.BitmapFromBuffer(w_canvas, h_canvas, buffer)
bitmap.SetBitmap(bmp)
The size and dpi lines are meant to get a proper sizing of the canvas before
making a bitmap. This because I assume that the draw() converts vector
graphics to raster graphics. I am not sure all this is the cleverest way
but, when called from a wx.EVT_SIZE event it resizes nicely be it somewhat
slow.



Janwillem wrote:
> 
> I have an application where I would like to use show in a loop but as
> stated in 18.1 of the manual that does not work.
> # WARNING : illustrating how NOT to use show
> for i in range(10):
> # make figure i
> show()
> So I made a workaround in a custom wxDialog with a wxStaticBitmap and a
> few buttons and put the matplotlib figure in the bitmap with something
> like:
> wi,hi = figure.get_size_inches()
> width,height = bitmap_plot.GetSize()
> dpi = int(min(width/wi,height/hi))
> figure.savefig('/tmp/tmp.png',dpi = dpi)
> image = wx.Image('/tmp/tmp.png',wx.BITMAP_TYPE_ANY)
> bitmap = wx.BitmapFromImage(image)
> bitmap_plot.SetBitmap(bitmap)
> Thus scaling the figure using the dpi option of savefig and then loading
> it into the wxStaticBitmap.
> 
> To me it seems there might be a lot of unnecessary data handling. What is
> the clever solution?
> mant thanks
> 

-- 
View this message in context: 
http://www.nabble.com/show-figures-in-a-loop-tp24776045p24779255.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] date representation : ValueError: invalid literal for float()

2009-08-02 Thread jorge sanchez
Hi,


I am trying to plot netstat (network stats taken from
/proc/net/netstat on linux), the parsed file looks like this:

Tue Jul 28 17:11:39 2009
TcpExt:   TcpExt:
SyncookiesSent   35367
SyncookiesRecv   83175
SyncookiesFailed   626981
EmbryonicRsts   2683828
PruneCalled   0
RcvPruned   0
OfoPruned   0
OutOfWindowIcmps   0
LockDroppedIcmps   0
ArpFilter   0
TW   731933844
TWRecycled   2519
TWKilled   0
PAWSPassive   0
PAWSActive   0
PAWSEstab   0
DelayedACKs   260793151
DelayedACKLocked   39078
DelayedACKLost   8463534
ListenOverflows   5702696
ListenDrops   5702696
TCPPrequeued   757095
TCPDirectCopyFromBacklog   20396543
TCPDirectCopyFromPrequeue   41213784
TCPPrequeueDropped   0
TCPHPHits   1980793902
TCPHPHitsToUser   969080
TCPPureAcks   1329017292
TCPHPAcks   1527716572
TCPRenoRecovery   441952
TCPSackRecovery   158939
TCPSACKReneging   590
TCPFACKReorder   2354
TCPSACKReorder   12
TCPRenoReorder   77537
TCPTSReorder   3
TCPFullUndo   364
TCPPartialUndo   2267
TCPDSACKUndo   57659
TCPLossUndo   1377902
TCPLoss   83058
TCPLostRetransmit   65
TCPRenoFailures   597875

I am collecting this information every 3 minutes and want to plot
every indivudal value (like for example TCPLoss) in separate date
graph. Anyhow I have problems setting the date value

This is the exception I get:
Traceback (most recent call last):
  File "./graph_last.py", line 86, in 
main()
  File "./graph_last.py", line 75, in main
ax.plot(counter['date'],counter.__dict__[count])
  File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 2654, in plot
for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
397, in _grab_next_args
for seg in self._plot_2_args(remaining, **kwargs):
  File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
339, in _plot_2_args
func(x[:,j], y[:,j])
  File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
320, in makeline
axes=self.axes,
  File "/usr/lib/python2.5/site-packages/matplotlib/lines.py", line
284, in __init__
self.set_data(xdata, ydata)
  File "/usr/lib/python2.5/site-packages/matplotlib/lines.py", line
405, in set_data
self.recache()
  File "/usr/lib/python2.5/site-packages/matplotlib/lines.py", line
410, in recache
x = ma.asarray(self.convert_xunits(self._xorig), float)
  File "/usr/lib/python2.5/site-packages/numpy/core/ma.py", line 2123,
in asarray
return array(data, dtype=dtype, copy=0)
  File "/usr/lib/python2.5/site-packages/numpy/core/ma.py", line 574,
in __init__
self._data = c.astype(tc)
ValueError: invalid literal for float(): Tue Jul 28 17:15:01 2009



This is the script based on the date example:
#!/usr/bin/python
import re
import datetime
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.mlab as mlab

days = mdates.DayLocator()
hours = mdates.HourLocator()
daysFmt = mdates.DateFormatter('%c')
class Mylist(list):
def append(self,x):
if not self.__contains__(x):
return super(Mylist, self).append(x)
else:
raise AttributeError


class Counter():
def __init__(self):
self.names = Mylist()
def __setitem__(self,key,value):
'''
Now try to append the name to the list
'''
try:
self.names.append(key)
except AttributeError:
pass

try:
self.__dict__[key].append(value)
except KeyError:
self.__dict__[key] = list()

def __getitem__(self,key):
'''
Return the list
'''
return list(self.__dict__[key])
def main():
try:
file = open("netstat_output",)
except IOError:
print "There was a problem with the file\n"

counter = Counter()
lastline = re.compile('')
date = re.compile(r"\b\w{3} \w{3} \d{2} \d\d:\d\d:\d\d \d{4}\b")
tcpext = re.compile('Tcpext:',re.IGNORECASE)
lines = file.readlines()


for line in lines:
if (date.search(line)):
counter['date'] = line
elif (lastline.search(line)):
pass
elif (tcpext.search(line)):
pass
else:
currlist = line.split()
counter[currlist[0]] = currlist[1]


for count in counter.names:
 fig = plt.figure()
 ax = fig.add_sub

Re: [Matplotlib-users] Include icon in plot

2009-08-02 Thread Jae-Joon Lee
A snippet of code does not help in general.
Please take your time to create a simple, standalone code that
reproduces your problem and post that code in this mailing list so
that we can easily test.

Here is the code, based on yours, that works for me.

im = Image.open("icon.jpg")

ax = gca()
limx = ax.get_xlim()
limy = ax.get_ylim()
ax.set_autoscale_on(False)

[x0, y0], [x1, y1] = ax.bbox.get_points()

datawidth = limx[1] - limx[0]
dataheight = limy[1] - limy[0]
pixelwidth = x1 - x0
pixelheight = y1 - y0
adaptedwidth = im.size[0] * (datawidth/pixelwidth)
adaptedheight = im.size[1] * (dataheight/pixelheight)

ax.imshow(im, origin="lower",
  extent=(0.5, 0.5+adaptedwidth, 0.5, 0.5+adaptedheight))


plt.draw()

-JJ



On Fri, Jul 31, 2009 at 3:44 PM, Bas van Leeuwen wrote:
> Hello,
>
> I tried to implement a solution for this issue. Basically I want to
> give the x and y position in datacoords and the width + height in
> pixels.
> However, when using the following code:
>
>            im = Image.open("../Icons/Program Icon.png")
>
>            limx = self.mainAxes.get_xlim()
>            limy = self.mainAxes.get_ylim()
>
>            [x0, y0], [x1, y1] = self.mainAxes.bbox.get_points()
>
>            datawidth = limx[1] - limx[0]
>            dataheight = limy[1] - limy[0]
>            pixelwidth = x1 - x0
>            pixelheight = y1 - y0
>            adaptedwidth = im.size[0] * (datawidth/pixelwidth)
>            adaptedheight = im.size[1] * (dataheight/pixelheight)
>
>
>            for peak in Blocks.peaks(self.quote.Close,
> self.peakSpanSlider.value()):
>                self.mainAxes.imshow(im, origin = 'lower', extent =
> (date2num(peak.datetime), date2num(peak.datetime) + 100 , 400, 425)) #
> left right bottom top
>            self.mainAxes.set_xlim(limx)
>            self.mainAxes.set_ylim(limy)
>
> There is no visible result. When zooming in to a place where an image
> should be present I encounter the following error every time I move
> the mouse.
>
> Traceback (most recent call last):
>  File "C:\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py",
> line 135, in mouseReleaseEvent
>    FigureCanvasBase.button_release_event( self, x, y, button )
>  File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py",
> line 1198, in button_release_event
>    self.callbacks.process(s, event)
>  File "C:\Python25\lib\site-packages\matplotlib\cbook.py", line 155, in 
> process
>    func(*args, **kwargs)
>  File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py",
> line 2048, in release_zoom
>    self.draw()
>  File "C:\Python25\lib\site-packages\matplotlib\backend_bases.py",
> line 2070, in draw
>    self.canvas.draw()
>  File "C:\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py",
> line 133, in draw
>    FigureCanvasAgg.draw(self)
>  File "C:\Python25\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 279, in draw
>    self.figure.draw(self.renderer)
>  File "C:\Python25\lib\site-packages\matplotlib\figure.py", line 772, in draw
>    for a in self.axes: a.draw(renderer)
>  File "C:\Python25\lib\site-packages\matplotlib\axes.py", line 1545, in draw
>    im.draw(renderer)
>  File "C:\Python25\lib\site-packages\matplotlib\image.py", line 233, in draw
>    im = self.make_image(renderer.get_image_magnification())
>  File "C:\Python25\lib\site-packages\matplotlib\image.py", line 220,
> in make_image
>    rx = widthDisplay / numcols
> ZeroDivisionError: float division
>
> Any idea what might cause this issue? Did I do something wrong? I know
> it's not pretty, but it should work right?
>
> Cheers!
> Bas
>
>
>
> 2009/7/30 Bas van Leeuwen :
>> Hi JJ,
>>
>> Thank you for your kind and speedy reply, I completely glanced over
>> the extent parameter.
>> Datacoords are actually what I need so this is perfect for me.
>>
>> To clarify what I want, I want to mark certain parts of a graph with
>> an icon representing the reason it's interesting. Icons are for peaks,
>> trends, correlation, etc.
>>
>> Thank you very much!
>>
>> Bas
>>
>>
>> 2009/7/30 Jae-Joon Lee :
>>> The location of the image can be set by specifying the "extent"
>>> keyword, however, this is set in data coordinate.
>>> figimage may be close to what you want.
>>>
>>> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.figimage
>>>
>>> As far as I know, there is no direct support in matplotlib to place an
>>> image with arbitrary transformation. But it may not be difficult to
>>> implement. However, "annotate a plot with icons" is not enough to
>>> figure out what you really want.
>>> Maybe some screenshots from other plotting tool will be helpful. Or,
>>> please elaborate how you want to position your image.
>>>
>>> -JJ
>>>
>>>
>>> On Thu, Jul 30, 2009 at 12:11 PM, Bas van Leeuwen wrote:
 Hi all,

 Is there any way to annotate a plot with icons?
 The only way to include an image that I've found is using 

Re: [Matplotlib-users] Change the text of yticklabels

2009-08-02 Thread Jae-Joon Lee
Use pylab's yticks command.

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks

Or Axes.set_yticklabels together with Axes.set_yticks.

http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_yticklabels

-JJ


On Fri, Jul 31, 2009 at 4:07 PM, Lukas Hetzenecker wrote:
> Hello,
>
> I have y values in the range of -100 to 100.
> I want that the negative values are shown as positive (the minus gets removed
> from the output).
>
> I tried a for loop over all self.ax.get_yticklabels() and call
> label.set_text("...") on each item but it didn't work - nothing got changed.
>
> If I print the label in the loop they seem to be empty:
> Text(0,0,'')
> Text(0,0,'')
> Text(0,0,'')
> ..
>
> Is there anything I do wrong?
>
> Thanks,
> Lukas
>
> --
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Include icon in plot

2009-08-02 Thread John Hunter
On Sun, Aug 2, 2009 at 1:28 PM, Jae-Joon Lee wrote:
> A snippet of code does not help in general.
> Please take your time to create a simple, standalone code that
> reproduces your problem and post that code in this mailing list so
> that we can easily test.
>
> Here is the code, based on yours, that works for me.

The other approach is to use a figimage and use the ax.transData
instance to convert data coords to fig coords for the offsets.

JDH

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] clabel and bbox

2009-08-02 Thread Jae-Joon Lee
On Sat, Aug 1, 2009 at 5:04 PM, Andres Luhamaa wrote:
> Thank You,
>
> but now I have another little annoying issue. Besides clabel I add some
> text manually to my plot with plt.text and sometimes the clabel and
> plt.text overlap, and no matter in which order I plot them, the string
> from clabel is always above the one from plt.text, but I would like, if
> the manually added text would be more visible.
>

please define "more visible".
Maybe adjusting the zorder is sufficient?

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=zorder#matplotlib.artist.Artist.set_zorder

If not, I would adjust the clable position manually (of course, this
is not a good choice if you need to do this for a lot of plots).
I'm not sure if there are more elegant solutions.

-JJ

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] spines versus subplotzero

2009-08-02 Thread Jae-Joon Lee
Yes, using spines will be best in most situation.

The problem with using axes_grid toolkit is that some mpl commands
that changes the properties of the ticks and ticklabels do not work.

I think you may consider to use axes_grid if you want to keep both of
the bottom and top axis, which I guess would be very rare.

-JJ


On Sun, Aug 2, 2009 at 8:59 AM, John Hunter wrote:
> On Sun, Aug 2, 2009 at 2:14 AM,  wrote:
>> I'm trying to understand some of the changes in 0.99, for example, the
>> recommended way of getting a plot so that the axes cross at the origin
>> (i.e., the axes are in the middle of the plot).  I see two examples that
>> seem to give this:
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html
>>
>> http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline2.html
>>
>> Is one or the other of these methods the recommended way to get a plot
>> with axes in the middle that cross at the origin?  Or are they both good
>> and apply to different situations?
>
> I'll let Andrew and JJ fill in some color, since they wrote the spine
> and axes_grid, respectively, but both are good.  The spines are in the
> mainline and JJ's solution is in a toolkit, so when in doubt go with
> something in the mainline since that is more likely to be stable.
> Both JJ and Andrew will be attending the scipy sprint this year (if
> you're going to be there be sure to stop by), and one of the items on
> our agenda is to incorporate their work into a unified API in the
> mainline.  So there may be some changes to one or both approaches, but
> hopefully soon we will have most of the feature set of both in our
> main axis code.
>
> JDH
>
> --
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Change the text of yticklabels

2009-08-02 Thread Eric Firing
Jae-Joon Lee wrote:
> Use pylab's yticks command.
> 
> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks
> 
> Or Axes.set_yticklabels together with Axes.set_yticks.
> 
> http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_yticklabels
> 
> -JJ

Or a make a very simple custom Formatter:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter

class PositiveFormatter(ScalarFormatter):
 def pprint_val(self, x):
 return ScalarFormatter.pprint_val(self, np.abs(x))

x = np.arange(0,20,0.1)
y = 100 * np.sin(x)
plt.plot(x, y)
ax = plt.gca()
ax.yaxis.set_major_formatter(PositiveFormatter())
plt.show()


This is a much safer way to handle it than trying to modify tick labels 
directly.

Eric
> 
> 
> On Fri, Jul 31, 2009 at 4:07 PM, Lukas Hetzenecker wrote:
>> Hello,
>>
>> I have y values in the range of -100 to 100.
>> I want that the negative values are shown as positive (the minus gets removed
>> from the output).
>>
>> I tried a for loop over all self.ax.get_yticklabels() and call
>> label.set_text("...") on each item but it didn't work - nothing got changed.
>>
>> If I print the label in the loop they seem to be empty:
>> Text(0,0,'')
>> Text(0,0,'')
>> Text(0,0,'')
>> ..
>>
>> Is there anything I do wrong?
>>
>> Thanks,
>> Lukas
>>
>> --
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> ___
>> Matplotlib-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> --
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] polar() is not equal to ax.plot (where ax is a PolarAxes)?

2009-08-02 Thread plaf

Hi all,

I have been trying both ways of plotting polar and found that they behave
differently?
Is it just me?

I have sets of theta and R to plot, and when I plotted in console using
polar() it produces different plot (!) than when I used ax.plot() from my
application. I compared this with the plot produced in Matlab using the same
sets of data, and found that it looked closer to my plot produced using
polar().

I am confused :(

Thank you  
-- 
View this message in context: 
http://www.nabble.com/polar%28%29-is-not-equal-to-ax.plot-%28where-ax-is-a-PolarAxes%29--tp24784409p24784409.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users