[Matplotlib-users] ImportError when import pylab

2009-06-27 Thread Daniel
hi list,

I'm new to matplotlib. My environment is WinXP, PythonWin 2.6.2, NumPy
1.3.0, matplotlib 0.98.5.3.

>>> import matplotlib.pylab as pylab
Traceback (most recent call last):
  File "", line 1, in 
  File "D:\Python26\lib\site-packages\matplotlib\pylab.py", line 253, in

from matplotlib.pyplot import *
  File "D:\Python26\lib\site-packages\matplotlib\pyplot.py", line 75, in

new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "D:\Python26\lib\site-packages\matplotlib\backends\__init__.py", line
25, in pylab_setup
globals(),locals(),[backend_name])
  File "D:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py",
line 8, in 
import tkagg # Paint image to Tk photo blitter extension
  File "D:\Python26\lib\site-packages\matplotlib\backends\tkagg.py", line 1,
in 
import _tkagg
ImportError: DLL load failed: cannot find the module

I searched the web and it's said because of lack of msvcp71.dll, but there
is already on in my C:\windows\system32\

anyone can help?
Thanks.
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Fast plotting of many data points in Python?

2009-07-11 Thread Daniel Platz
Hi,

I am programming a oscilloscope module in Python. For this reason, I
want to plot very many data points as fast as possible. This can be
more than 100 000 at once. So far I have been using the ploting module
of wxPython. However, it becomes unstable for more than 25000 points.
Can someone recommend me a faster plotting library? It would be really
cool if one could embed this in wxPython. If someone has an idea I
would be very glad about answer.

With kind regards,

Daniel

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib and wing ide

2009-07-24 Thread Daniel Platz
Hello,

I am looking for a way to get interactive plotting in wing ide to run
(preferably matplotlib). I have tried to thread the show() method of
matplotlib with a Timer from the threading module. This was suggested
in the wingware how-tos pdf. Unfortunately, it does not work for me.
The show() method does not return and the shell freezes. Has anyone
experience with interactive plotting in wing? Thanks in advance.

With kind regards,

Daniel

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


[Matplotlib-users] Custom ticklabels on colorbar

2009-08-20 Thread Daniel Platz
Hello,

I would like to have some custom ticklabels on a colorbar. In detail, I 
want the four labels '-\pi', -\pi/2', '0', \pi/2', \pi'. I tried to set 
manually each text object obtained from cb.ax.get_xticklabels():

t = cb4.ax.get_xticklabels()
for j in t:
j.set_text(r'$\pi$')
j.set_fontsize(10)
j.set_family('serif')

However, no matter what I set for text, it has no effect on the 
displayed figure.

Another problem is that I want to adjust the fontsize of the colorbar 
ticklabels on four subplots. This only works for the last two subplots 
with the syntax shown above. The same syntax has no effect on the first 
two subplots.

If anybody has some ideas I would be really gald about an answer.

Thanks in advance

Daniel

--
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Custom ticklabels on colorbar

2009-08-20 Thread Daniel Platz
The setting of the new ticklabels works now. But the first label is 
attached to the second tick. I tried to adapt the clim range by using 
the vmin and vmax option of pcolor but it did not help.

I also still have the problem that the changes are only performed on the 
last two subplots (in one loop run). The code of the plotting loop is:
for i in range(len(fname)):
 # Load data from file
 data1_amp = np.loadtxt(fname[4*i])
 data1_phase = np.loadtxt(fname[4*i+1])
 data2_amp = np.loadtxt(fname[4*i+2])
 data2_phase = np.loadtxt(fname[4*i+3])

 # Display data using pcolor
 ax1 = fig1.add_subplot(len(fname)/4,4,4*i+1)
 pc1 = ax1.pcolorfast(data1_amp,cmap=mpl.cm.Oranges)
 ax1.set_xlim((0,250))
 ax1.set_ylim((0,256))
 ax1.set_xticklabels('')
 ax1.set_yticklabels('')
 cb1 = fig1.colorbar(pc1,ax=ax1,orientation='horizontal',pad=0.00)
 cb1.ax.set_xticklabels(range(5),fontsize=10)

 ax2 = fig1.add_subplot(len(fname)/4,4,4*i+2)
 pc2 = ax2.pcolorfast(data1_phase,cmap=nat_per)
 ax2.set_xlim((0,250))
 ax2.set_ylim((0,256))
 ax2.set_xticklabels('')
 ax2.set_yticklabels('')
 cb2 = fig1.colorbar(pc2,ax=ax2,orientation='horizontal',pad=0.00, 
   ticks=[-np.pi,-np.pi/2,0,np.pi/2,np.pi])
 cb2.ax.set_xticklabels(range(5),fontsize=10)

 ax3 = fig1.add_subplot(len(fname)/4,4,4*i+3)
 pc3 = ax3.pcolorfast(data2_amp,cmap=mpl.cm.Oranges)
 ax3.set_xlim((0,250))
 ax3.set_ylim((0,256))
 ax3.set_xticklabels('')
 ax3.set_yticklabels('')
 cb3 = fig1.colorbar(pc1,ax=ax3,orientation='horizontal',pad=0.00)
 cb3.ax.set_xticklabels(range(5),fontsize=10)

 ax4 = fig1.add_subplot(len(fname)/4,4,4*i+4)
 pc4 = 
ax4.pcolorfast(data2_phase,cmap=nat_per,vmin=-np.pi-0.1,vmax=np.pi+0.001)
 ax4.set_xlim((0,250))
 ax4.set_ylim((0,256))
 ax4.set_xticklabels('')
 ax4.set_yticklabels('')
 cb4 = fig1.colorbar(pc2,ax=ax4,orientation='horizontal',pad=0.00, 
ticks=[-np.pi, -np.pi/2, 0.0, np.pi/2, np.pi])
     cb4.ax.set_xticklabels([r'$-\pi$', r'$-\frac{\pi}{2}$', r'$0$', 
r'$\frac{\pi}{2}$', r'$\pi$'],fontsize=10)




Daniel


Jouni K. Seppänen wrote:
> Daniel Platz  writes:
> 
>> t = cb4.ax.get_xticklabels()
>> for j in t:
>> j.set_text(r'$\pi$')
>> j.set_fontsize(10)
>> j.set_family('serif')
> 
> Try cb4.ax.set_xticklabels([r'$-\pi$', ...]); draw()
> 
>> Another problem is that I want to adjust the fontsize of the colorbar 
>> ticklabels on four subplots. This only works for the last two subplots 
>> with the syntax shown above. The same syntax has no effect on the first 
>> two subplots.
> 
> You should be able to pass font properties to set_xticklabels. If that
> doesn't work, please post a complete example.
> 


--
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Custom ticklabels on colorbar

2009-08-25 Thread Daniel Platz
Jae-Joon Lee wrote:
> On Fri, Aug 21, 2009 at 10:01 AM, Scott
> Sinclair wrote:
>>> I just realized that I did not give the correct plot object when creating
>>> the colorbar. Now it works perfectly to pass arguments by set_xticklabels().
>>>
>>> However, another question just arose. To format the numbers on the tick
>>> labels I tried to pass a format string when creating the colorbar with the
>>> format parameter. But it has no effect. The same when I give a
>>> FormatStrFormatter object. I also tried to use
>>> cb.ax.axis.set_major_formatter(). The effect of this was. That it sets the
>>> labels to the range between 0 and 1. Is there a solution for this problem
>>> besides entering the tick labels manually?
> 
> The tick locator and tick formatter needs to be passed during the
> colorbar creation. Otherwise,
> it gets very tricky to deal with. This is because the data coordinate
> of the colorbar axes is not directly associated with the ticklabels.
> 
> If passing the formatter during the colorbar creation has no effect,
> this should be filed as a bug. Please post a small standalone example
> that reproduces your problem. Also, please report your version of
> matplotlib. If you're using older version, I recommend you to test it
> with newer version.
> 
> Just in case, my quick test worked fine.
> 
> imshow([[1,2],[2,3]])
> cb=colorbar(format=r"$%2.1f\%%$")
> 
> -JJ
> 

I just tried this but it did not work for me. The code that I am using 
looks like this

 ax1 = fig1.add_subplot(3,len(fname)/2,i+1,frameon=False)
 temp = np.linspace(data1_amp.min(),data1_amp.max(),3)
 pc1 = ax1.imshow(data1_amp,cmap=nat,vmin=temp[0],vmax=temp[-1])
 ax1.set_xlim((0,250))
 ax1.set_ylim((0,256))
 ax1.set_xticks([])
 ax1.set_yticks([])
 ax1.set_xticklabels('')
 ax1.set_yticklabels('')
 if i==0:
 ax1.set_ylabel('Amplitude 
[mV]',family='serif',size=10,weight='bold')
 ax1.set_title(title[i],family='serif',fontsize=10,weight='bold')
 cb1 = 
fig1.colorbar(pc1,ax=ax1,orientation='horizontal',pad=0.025,ticks=temp,format=r"$%2.1f\%%$")
 cb1.ax.set_xticklabels(temp,fontsize=10,family='serif')
 setp(cb1.ax.get_xticklines(),visible=False)
 plt.draw()
 a= ax1.get_position().get_points()
 b= cb1.ax.get_position().get_points()
 temp = [a[0,0], b[0,1], (a[1,0]-a[0,0]), (b[1,1]-b[0,1])]
 cb1.ax.set_position(temp)

I am using matplotlib 0.98.5.2. If anyone has an idea I would be very 
glad if you can post here.

Thanks in advance

Daniel



--
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Installing MatPlotLib on Snow Leopard

2009-12-08 Thread Daniel Brown
Good morning list,

I have been trying to install the latest matplotlib on Snow Leopard
with the latest X-Code for a few days.  I have tried the installer
packages (wrong versions) and the source (build errors) and neither
worked.  I finally got it installed correctly by using MacPorts.  I
wrote up what I did in case anyone else is having issues installing on
Snow Leopard [1].

Cheers,

Daniel

[1] - 
http://www.endlesslycurious.com/2009/12/08/installing-matplotlib-on-snow-leopard-with-macports/

--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] controlling padding between axis and ticklabels in polar plots

2010-04-13 Thread Daniel Platz
Hello,

I have a question concerning the label positions of x- or y-ticks. My
problem is that I want to make a polar plot with ticklabels. To
generate such a plot you can use the following simple example script.

# #
import numpy as np
import matplotlib.pyplot as plt

r = np.linspace(0, 10, 100)
t = np.linspace(0, 4*np.pi, 100)

fig = plt.figure(1)
fig.clf()
ax = fig.add_subplot(1,1,1, polar=True)
ax.plot(t, r, lw=2)

plt.draw()
plt.show()
# ##

When generating a polarplot with this script one realizes that the
r-ticklabels (y-ticklabels) end up on the gridlines. This looks looks
kind of ugly especially for the last ticklabel ("10") which breaks the
solid line at the outer plot boundary. So I would like to move the
ticklabels a little bit to the right.

My question is: Is there a simple trick to change the default
ticklabelpad between the axis and the ticklabels or do I have to do
this manually by changing the position of every single ticklabel?

About a short answer I would be very glad.

With kind regards,

Daniel

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Mac backend problems for nearly all backends.

2010-05-25 Thread Daniel Welling
$%$^&#!!!  My sincere apologies, gmail sent before I was ready.  To
continue:
GtkCairo: looks great, crashes ipython on resize.

Wx: color issues, not stable.
Qt: installs from fink, but won't load.

In any case, it's not the Gtk/Qt/Wx problems that are important, it's the
OSX backend issue.  Others whom I work with do not have this issue, but
installed using EPD.
Has anyone else experienced such problems?

Thanks for your help; let me know if there's more info I can provide.

-dw

On Tue, May 25, 2010 at 12:47 PM, Daniel Welling wrote:

> Greetings.
>
> I did quite a bit of digging on this and cannot find similar problems, but
> if I did miss an earlier discussion, then I apologize.
>
> In any case, I have been having royal problems with GUI backends and
> matplotlib.
> Some background on where I've been having these problems:
> Machine 1: OSX 10.5.8 G5 PPC
> Machine 2: OSX 10.5.7 Macbook pro/Intel
> Code versions: python 2.5.4, Numpy 1.3.0, Scipy 0.7.0 (all obtained through
> fink.)
> MPL versions: 99.0.1 and 99.1.1 (Older obtained through fink, newer
> installed from source.)
>
> Here are the issues; behavior is consistent on both machines:
>
> MacOSX backend: Loads plots quickly, but when I try to save, I cannot type
> in the file name area of the save file dialog.  Furthermore, with ipython, I
> can continue to use the ipython prompt up until the I shut the plot window.
> ipython then freezes until I control-c it.  This occurs in both versions.
>
> TkAgg backend: In 99.0.1, this works fine.  However, it is slow, hence my
> want for a different working backend.  in 99.1.1, the plot window opens but
> the picture is never drawn.  After a moment, segfault back to the x11
> prompt.  Blerg.
>
> GtkAgg: Bad color (e.g. the background is pink rather than gray, color
> tables are way goofed up.  Writes to file fine.)
>
>
--

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


[Matplotlib-users] Mac backend problems for nearly all backends.

2010-05-25 Thread Daniel Welling
Greetings.

I did quite a bit of digging on this and cannot find similar problems, but
if I did miss an earlier discussion, then I apologize.

In any case, I have been having royal problems with GUI backends and
matplotlib.
Some background on where I've been having these problems:
Machine 1: OSX 10.5.8 G5 PPC
Machine 2: OSX 10.5.7 Macbook pro/Intel
Code versions: python 2.5.4, Numpy 1.3.0, Scipy 0.7.0 (all obtained through
fink.)
MPL versions: 99.0.1 and 99.1.1 (Older obtained through fink, newer
installed from source.)
Compilers: gcc/g++ 4.0.1/Mac.

Here are the issues; behavior is consistent on both machines:

MacOSX backend: Loads plots quickly, but when I try to save, I cannot type
in the file name area of the save file dialog.  Furthermore, with ipython, I
can continue to use the ipython prompt up until the I shut the plot window.
ipython then freezes until I control-c it.  This occurs in both versions.

TkAgg backend: In 99.0.1, this works fine.  However, it is slow, hence my
want for a different working backend.  in 99.1.1, the plot window opens but
the picture is never drawn.  After a moment, segfault back to the x11
prompt.  Blerg.

I've tried nearly all of the GUI tool kits, but ran into some problem:
GtkAgg: Bad color (e.g. the background is pink rather than gray, color
tables are way goofed up.  Writes to file fine.)
GtkCairo: looks great, crashes ipython on resize.
Wx: color issues, not stable.
Qt: installs from fink, but won't load.
Fltk: Couldn't get it to install via fink; can't remember why.

In any case, it's not the Gtk/Qt/Wx problems that are important, it's the
OSX backend issue.  Others whom I work with do not have this issue, but
installed using the EPD.
Has anyone else experienced such problems?  Anyone know possible fixes?
Given that this occurs on two different machines with two different MPL
versions (a total of 4 combinations), I'm guessing it's my fault somehow.

Thanks for your help; let me know if there's more info I can provide.
--

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


Re: [Matplotlib-users] Mac backend problems for nearly all backends.

2010-05-25 Thread Daniel Welling
Thanks for the info...
1)The problem does manifest in the same manner through the normal python
prompt.
2) I'm not sure what is meant by a "framework install."  Everything (except
MPL 99.1.1) was installed through fink.
3) I've never had problems with Fink software before, and I have a crapload
(technical term) of stuff installed.  This is neither here nor there,
however, as it seems that not all Pythons are created equal.
4) A colleague of mine claims to have everything working on a new Intel mac
(I'm guessing 10.5.8) right out of MacPorts; I'll talk to him more and try
to find out what is different between our two cases.
5) I have yet to try installing wxPython for python 2.5; this may work in
the end.  It's not in fink, so I've put off installing it manually.  I'll
give it a shot and let you know how it works.
6) Although I use x11 and not the native Mac terminal, I'm not sure if this
requires me to install different packages for the gui stuff.  Could you guys
expand on this, please?

Finally, I've had some measure of success by installing Qt4 (through Fink)
and using the Qt4Agg backend.  Because the current stable fink Qt4 release
(4.6.1) has a bug, I need to apply the fix found here:
http://old.nabble.com/Qt4-backend:-critical-bug-with-PyQt4-v4.6%2B-td26205716.html
in order to allow more than one plot per session to be shown.  I'll re-write
the fix here for convenience and clarity (the original did not have the
proper module references in it, so this saves some 5 minutes of
tab-completion work in ipython...)

# Add this before "FigureManagerQT" class
class FigureWindow(QtGui.QMainWindow):
def __init__(self):
super(FigureWindow, self).__init__()
def closeEvent(self, event):
super(FigureWindow, self).closeEvent(event)
if QtCore.PYQT_VERSION_STR.startswith('4.6'):
self.emit(QtCore.SIGNAL('destroyed()'))
# Replace "QtGui.QMainWindow" by "FigureWindow" in
"FigureManagerQT"'s constructor

This works perfectly on my Intel machine running MPL 99.1.1.  It's fast and
looks sharp.  I'll report back on the PPC/99.0 combo tomorrow; Qt4 takes a
thousand hours to compile.

Thanks for the input.

On Tue, May 25, 2010 at 8:48 PM, Jonathan Stickel  wrote:

> On 05/25/2010 matplotlib-users-requ...@lists.sourceforge.net wrote:
> > From: Christopher Barker 
> > Subject: Re: [Matplotlib-users] Mac backend problems for nearly all
> > backends.
> > To: matplotlib-users@lists.sourceforge.net
> > Message-ID: <4bfc626c.40...@noaa.gov>
> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >
> > Jonathan Stickel wrote:
> > > > I've experienced many of the same problems on Mac OS X 10.6.3
> > (Snow
> > > > Leopard).  I have python/scipy/numpy/matplotlib/ipython all
> > installed
> > > > via Macports.
> >
> > Just to be clear -- this sounds like a MacPorts problem, not
> > necessarily
> > an OS-X problem.
> >
> >
> > > >  I finally have the WXagg backend
> > > > working, but that required installed WXPython with the gtk/X11
> > backend.
> >
> > Does MacPorts not allow a native wx? Maybe becasue you're running 64
> > bit?
> >
>
> Right, I am running Snow Leopard and have Python 2.6 installed 64 bit.
> Apparently, Carbon requires 32 bit and wxWidgets/wxPython does not (yet)
> support Cocoa.  This problem will bite you in one form or another on Mac
> OS X, regardless of whether you are using Macports or something else.
>
> > Anyway, I guess that's why I don't use macports for python.
>
> See above.
>
> >
> >
> > >> >> In any case, I have been having royal problems with GUI
> > backends and
> > >> >> matplotlib.
> > >> >> Some background on where I've been having these problems:
> > >> >> Machine 1: OSX 10.5.8 G5 PPC
> >
> > That's what I've been running, and I've had no real issues (Haven't
> > tried the OS-X back-end) -- but I'm using the python.org python.
> >
> > >> >> Machine 2: OSX 10.5.7 Macbook pro/Intel
> > >> >> Code versions: python 2.5.4, Numpy 1.3.0, Scipy 0.7.0 (all
> > obtained through
> > >> >> fink.)
> >
> > OK -- then a fink issue, rather than a Macports one -- same idea,
> > though.
> >
> > My impression is that neither fink nor macports do well with Mac GUI
> > stuff -- unless you're talking X11.
>
> Not exactly true.  Fink and Macports are tools and have their
> shortcomings, but both can be immensely useful for installing all this
> stuff.  Otherwise, you do it manually, which of course can cause you
> trouble as well.  Anyway, getting off topic.  I only intended to report
> some form of success with the wx backend.
>
> Jonathan
>
>
> --
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--

___
Matplotlib-users mailing list

Re: [Matplotlib-users] Mac backend problems for nearly all backends.

2010-05-25 Thread Daniel Welling
2) In which case, it's not a framework install.  Fink puts everything into
/sw/; there's nothing to do with pyton in /Library/Frameworks.
Thanks for the clarification; I'm tempted to get Python from source and try
this...

-dw

On Tue, May 25, 2010 at 10:41 PM, Michiel de Hoon wrote:

>
> > 1)The problem does manifest in the same manner through the normal python
> prompt.
>
> OK that is good to know.
>
>
> > 2) I'm not sure what is meant by a "framework install."  Everything
> (except MPL 99.1.1)
> > was installed through fink.
>
> This is important. Check where python is installed. If 'which python' shows
> /Library/Frameworks/Python.framework/Versions/2.6/bin/python or something
> similar, you have a framework version. If on the other hand it shows
> /usr/bin/python, /usr/local/bin/python, or something similar, you don't have
> a framework version. I don't know what fink installs by default. If you
> don't have Python installed as a framework, some backends (including the
> MacOSX backend) will not interact properly with the window manager. This is
> a Mac peculiarity. If you build Python from source, you can specify to
> install a framework version by passing the --enable-framework option to the
> configure script.
>
>
> > 6) Although I use x11 and not the native Mac terminal, I'm not sure if
> this requires me to > install different packages for the gui stuff.  Could
> you guys expand on this, please?
>
> Some backends go make use of X11 (e.g., the gtkcairo backend), others do
> not (e.g., the MacOSX backend). The MacOSX backend should work with both the
> native Mac terminal and with an X11 terminal.
>
> --Michiel.
>
>
--

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


[Matplotlib-users] threading problems

2008-06-19 Thread Daniel Ashbrook
I need to have a plot window hang around and be occasionally updated by 
my script as it does things. I've been looking through examples and have 
not been able to get anything to work.

My current approach, inspired by strip_chart_demo.py and others in the 
animation examples, is:

import gobject, matplotlib, sys
matplotlib.use('GTKAgg')
import matplotlib.pylab as pylab
import threading, time, random

class PylabThread(threading.Thread):
   def __init__(self):
 threading.Thread.__init__(self)
   def update(self):
 pylab.draw()
   def run(self):
 gobject.idle_add(self.update)
 pylab.plot([random.random() for i in xrange(1000)])
 pylab.show()


if __name__ == "__main__":
   p = PylabThread()
   p.start()

   i = 0
   while True:
 print i
 i += 1
 time.sleep(.5)


Running this, however, yields the odd behavior that you only get numbers 
printed every half second (as you should) if you move the mouse (or hit 
keys, or otherwise generate events) within the plot window!

What's going on, and how can I fix this?

Thanks!



dan

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] threading problems

2008-06-19 Thread Daniel Ashbrook
John Hunter wrote:
> Use the gtk mainloop and do your figure updates in a timeout add or a
> idle handler (as suggested in the animation tutorial at
> http://www.scipy.org/Cookbook/Matplotlib/Animations

Excellent, thanks. Your sample code adapted nicely; appended below for 
posterity.


dan



import gobject
import numpy as np
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
import threading, time

class PylabThread(threading.Thread):
   def __init__(self):
 threading.Thread.__init__(self)
 self.fig = plt.figure()
 ax = self.fig.add_subplot(111)
 self.line, = ax.plot(np.random.rand(10))
 ax.set_ylim(0, 1)
   def update(self):
 self.line.set_ydata(np.random.rand(10))
 self.fig.canvas.draw_idle()
 return True  # return False to terminate the updates
   def run(self):
 gobject.timeout_add(100, self.update)  # you can also use idle_add 
to update when gtk is idle
 plt.show()


if __name__ == "__main__":
   p = PylabThread()
   p.start()

   i = 0
   while True:
 print "%.2f: %d" % (time.time(), i)
 i += 1
 time.sleep(.5)

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] threading problems

2008-06-19 Thread Daniel Ashbrook
John Hunter wrote:
> I don't think this is what you want.  gtk is already threaded.  By
> doing things in the gtk mainloop, you are using their threading.  You
> are asking for a world of pain if you try and mix in python threading
> unless you really know what you are doing.  The point of the example
> is that you don't need to use python threads.  All your printing and
> figure updating can be done in function calls activated by the gtk
> loop.

Ok, I think I see your point. Let me explain what I'm after, then. I'm 
doing some distributed computing and need to have a pylab process 
running remotely that accepts plotting commands. The issue is that the 
show() command takes over the main thread of execution, so I can't have 
my listening process running. Essentially I need to:

1) Pop up a figure()
2) Start the drawing loop
3) Start the socket listener
4) When the listener gets commands, execute them (plot, etc)

Is this something that I can do?


Thanks,


dan

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ginput then show causes segfault

2009-02-21 Thread Daniel Soto
i'd like to plot some data, get user input, and then plot the original  
data and user input.  when i try to show() the data i get a segfault  
after about ten seconds.

any clue what i'm doing wrong?  using mac os x 10.5 with enthought  
distribution.

thanks,
drs

#!/usr/bin/env python

import pylab

x = pylab.arange(0,10,0.1)
y = pylab.sin(x)

# plot and get user input, then close fig
pylab.plot(x,y)
points = pylab.ginput(2)
points = pylab.array(points)
pylab.close()

# replot with chosen points
pylab.plot(x,y)
pylab.plot(points[:,0],points[:,1],'ko')
pylab.show()
# wait for it, wait for it...now segfault


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ginput then show causes segfault

2009-02-22 Thread Daniel Soto
i'd like to plot some data, get user input, and then plot the original  
data and user input.  when i try to show() the data i get a segfault  
after about ten seconds.

any clue what i'm doing wrong?  using mac os x 10.5 with enthought  
distribution.

thanks,
drs

#!/usr/bin/env python

import pylab

x = pylab.arange(0,10,0.1)
y = pylab.sin(x)

# plot and get user input, then close fig
pylab.plot(x,y)
points = pylab.ginput(2)
points = pylab.array(points)
pylab.close()

# replot with chosen points
pylab.plot(x,y)
pylab.plot(points[:,0],points[:,1],'ko')
pylab.show()
# wait for it, wait for it...now segfault



--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] upgrading matplotlib within EPD

2009-02-25 Thread Daniel Soto
does anyone know how to upgrade the matplotlib package that ships with  
the enthought python distribution?  the current enthought release  
matplotlib is 0.98.3 and i'd like to upgrade to 0.98.5.  i'm on an os  
x intel platform running leopard.

thank you,
daniel soto

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] sluggish pdfs with large data sets

2009-03-02 Thread Daniel Soto
hello,

i'm using matplotlib on os x and am having issues with plots of large  
data sets.  i have some plots which contain about ~1 points and  
the pdf files generated bring preview.app and quicklook to their knees  
when they open the pdf files.

here is a small file that reproduces my issues.  at 1000 points it is  
snappy and at 1 it is a pig.

is there a setting to downsample or otherwise compress?

best,
drs



import matplotlib.pyplot
import scipy

x = scipy.rand(1)
matplotlib.pyplot.plot(x)
matplotlib.pyplot.savefig('rand.pdf')

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] sluggish pdfs with large data sets

2009-03-03 Thread Daniel Soto
thanks for the suggestion.  i'm running 0.98.3 and have tried

pdf.compression
path.simplify
agg.path.chunksize

without any change in filesize (176KB) or time to open file (13 sec).

are there any other options or backends that might help?

drs

On 3 Mar 2009, at 05:29, Michael Droettboom wrote:

> With recent versions of matplotlib, you can set the "path.simplify"  
> rcParam to True, which should reduce the data so that vertices that  
> have no impact on the plot appearance (at the given dpi) are removed.
>
> You can do either, in your script:
>
> from matplotlib import rcParam
> rcParam['path.simplify'] = True
>
> or in your matplotlibrc file:
>
> path.simplify: True
>
> Hope that helps.  The amount of reduction this produces is somewhat  
> data-dependent.
>
> Cheers,
> Mike
>
> Daniel Soto wrote:
>> hello,
>>
>> i'm using matplotlib on os x and am having issues with plots of  
>> large  data sets.  i have some plots which contain about ~1  
>> points and  the pdf files generated bring preview.app and quicklook  
>> to their knees  when they open the pdf files.
>>
>> here is a small file that reproduces my issues.  at 1000 points it  
>> is  snappy and at 1 it is a pig.
>>
>> is there a setting to downsample or otherwise compress?
>>
>> best,
>> drs
>>
>>
>>
>> import matplotlib.pyplot
>> import scipy
>>
>> x = scipy.rand(1)
>> matplotlib.pyplot.plot(x)
>> matplotlib.pyplot.savefig('rand.pdf')
>>
>> --
>> Open Source Business Conference (OSBC), March 24-25, 2009, San  
>> Francisco, CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the  
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source  
>> participation
>> -Receive a $600 discount off the registration fee with the source  
>> code: SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] sluggish pdfs with large data sets

2009-03-03 Thread Daniel Soto
ok.  i managed to install 0.98.5.x from source into my enthought  
python distribution.
after that, using path.simplify helped considerably.

as far as the pdf.compression not working, i was using rcParams in the  
script so i'm
almost certain the options were being loaded.

thanks mike,
drs

On 3 Mar 2009, at 08:11, Michael Droettboom wrote:

> path.simplify was added some time after 0.98.3.  You'll have to  
> upgrade to 0.98.5.x for that feature.
>
> pdf.compression should have some impact on file size, but I doubt it  
> will have much impact on display times, since it doesn't actually  
> remove any data.  I'm surprised this isn't having any effect --  
> perhaps the matplotlibrc file you're editing is not the one being  
> loaded?  You can see where the file is being loaded from with:
>
>  import matplotlib
>  matplotlib.get_configdir()
>
> agg.path.chunksize has no effect on PDF output.
>
> Is it possible you're using the Cairo backend, and not matplotlib's  
> own Python-based PDF backend?
>
> As a cheap workaround, you can also easily decimate your data using  
> Numpy with something like:
>
>  data = data[::skip]
>
> where 'skip' is the number of data points to skip.
>
> Cheers,
> Mike
>
> Daniel Soto wrote:
>> thanks for the suggestion.  i'm running 0.98.3 and have tried
>>
>> pdf.compression
>> path.simplify
>> agg.path.chunksize
>>
>> without any change in filesize (176KB) or time to open file (13 sec).
>>
>> are there any other options or backends that might help?
>>
>> drs
>>
>> On 3 Mar 2009, at 05:29, Michael Droettboom wrote:
>>
>>> With recent versions of matplotlib, you can set the  
>>> "path.simplify" rcParam to True, which should reduce the data so  
>>> that vertices that have no impact on the plot appearance (at the  
>>> given dpi) are removed.
>>>
>>> You can do either, in your script:
>>>
>>> from matplotlib import rcParam
>>> rcParam['path.simplify'] = True
>>>
>>> or in your matplotlibrc file:
>>>
>>> path.simplify: True
>>>
>>> Hope that helps.  The amount of reduction this produces is  
>>> somewhat data-dependent.
>>>
>>> Cheers,
>>> Mike
>>>
>>> Daniel Soto wrote:
>>>> hello,
>>>>
>>>> i'm using matplotlib on os x and am having issues with plots of  
>>>> large  data sets.  i have some plots which contain about ~1  
>>>> points and  the pdf files generated bring preview.app and  
>>>> quicklook to their knees  when they open the pdf files.
>>>>
>>>> here is a small file that reproduces my issues.  at 1000 points  
>>>> it is  snappy and at 1 it is a pig.
>>>>
>>>> is there a setting to downsample or otherwise compress?
>>>>
>>>> best,
>>>> drs
>>>>
>>>>
>>>>
>>>> import matplotlib.pyplot
>>>> import scipy
>>>>
>>>> x = scipy.rand(1)
>>>> matplotlib.pyplot.plot(x)
>>>> matplotlib.pyplot.savefig('rand.pdf')
>>>>
>>>> --
>>>> Open Source Business Conference (OSBC), March 24-25, 2009, San  
>>>> Francisco, CA
>>>> -OSBC tackles the biggest issue in open source: Open Sourcing the  
>>>> Enterprise
>>>> -Strategies to boost innovation and cut costs with open source  
>>>> participation
>>>> -Receive a $600 discount off the registration fee with the source  
>>>> code: SFAD
>>>> http://p.sf.net/sfu/XcvMzF8H
>>>> ___
>>>> Matplotlib-users mailing list
>>>> Matplotlib-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>
>>>
>>> -- 
>>> Michael Droettboom
>>> Science Software Branch
>>> Operations and Engineering Division
>>> Space Telescope Science Institute
>>> Operated by AURA for NASA
>>>
>>
>
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] error with ginput

2009-03-03 Thread Daniel Soto
hello,

ginput isn't working for me right now but was when i was using 0.98.3.
running the script below gives me the following traceback.
anyone know what is going on?

thx,
drs

 > python -c "import matplotlib;print matplotlib.__version__"
0.98.5.2

 > ./gaelInput.py
Please click
Traceback (most recent call last):
   File "./gaelInput.py", line 7, in 
 x = ginput(3)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/ 
python2.5/site-packages/matplotlib/pyplot.py", line 358, in ginput
 return gcf().ginput(*args, **kwargs)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/ 
python2.5/site-packages/matplotlib/figure.py", line 1073, in ginput
 show_clicks=show_clicks)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/ 
python2.5/site-packages/matplotlib/blocking_input.py", line 258, in  
__call__
 BlockingInput.__call__(self,n=n,timeout=timeout)
   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/ 
python2.5/site-packages/matplotlib/blocking_input.py", line 96, in  
__call__
 self.fig.show()
AttributeError: 'Figure' object has no attribute 'show'

# gaelInput.py
from pylab import arange, plot, sin, ginput, show
t = arange(10)
plot(t, sin(t))
print "Please click"
x = ginput(3)
print "clicked",x
show()

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error with ginput

2009-03-03 Thread Daniel Soto
>

this seems to be because the default backend was set to something  
without a gui.
i set backend to WXAgg and it works now.

> --
>
> Message: 7
> Date: Tue, 3 Mar 2009 16:44:41 -0800
> From: Daniel Soto 
> Subject: [Matplotlib-users] error with ginput
> To: matplotlib-users@lists.sourceforge.net
> Message-ID: <3396d4ef-d0d8-43c4-b81d-3b7b94f11...@gmail.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> hello,
>
> ginput isn't working for me right now but was when i was using 0.98.3.
> running the script below gives me the following traceback.
> anyone know what is going on?
>
> thx,
> drs
>
>> python -c "import matplotlib;print matplotlib.__version__"
> 0.98.5.2
>
>> ./gaelInput.py
> Please click
> Traceback (most recent call last):
>   File "./gaelInput.py", line 7, in 
> x = ginput(3)
>   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/
> python2.5/site-packages/matplotlib/pyplot.py", line 358, in ginput
> return gcf().ginput(*args, **kwargs)
>   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/
> python2.5/site-packages/matplotlib/figure.py", line 1073, in ginput
> show_clicks=show_clicks)
>   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/
> python2.5/site-packages/matplotlib/blocking_input.py", line 258, in
> __call__
> BlockingInput.__call__(self,n=n,timeout=timeout)
>   File "/Library/Frameworks/Python.framework/Versions/4.1.30101/lib/
> python2.5/site-packages/matplotlib/blocking_input.py", line 96, in
> __call__
> self.fig.show()
> AttributeError: 'Figure' object has no attribute 'show'
>
> # gaelInput.py
> from pylab import arange, plot, sin, ginput, show
> t = arange(10)
> plot(t, sin(t))
> print "Please click"
> x = ginput(3)
> print "clicked",x
> show()
>
>


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] xlabel getting chopped off

2009-03-05 Thread Daniel Soto
i'm having a problem with an xlabel getting chopped off at the bottom  
of a figure.
i've looked through the matplotlibrc parameters and can't find  
anything that addresses
this.  toying with the figure.subplot.* didn't seem to have an  
effect.  how can i prevent
this from happening?

thx,
drs



--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] xlabel getting chopped off

2009-03-05 Thread Daniel Soto
brilliant.  that worked nicely.

thanks ryan,
drs

On 5 Mar 2009, at 17:44, Ryan May wrote:

>
>
> On Thu, Mar 5, 2009 at 6:24 PM, Daniel Soto   
> wrote:
> i'm having a problem with an xlabel getting chopped off at the bottom
> of a figure.
> i've looked through the matplotlibrc parameters and can't find
> anything that addresses
> this.  toying with the figure.subplot.* didn't seem to have an
> effect.  how can i prevent
> this from happening?
>
> Try:
>
> figure.subplots_adjust(bottom=0.2)
>
> Ryan
>
> -- 
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] draggable annotation bug and fix

2011-09-15 Thread Daniel Hyams
There seems to be a problem with the draggable annotation code when
the annotation is just clicked, and not dragged.  If you run the
following code:

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ann = ax.annotate('local max', xy=(2, 1), xytext=(3,
1.5),arrowprops=dict(facecolor='black', shrink=0.05))
ann.draggable()
ax.set_ylim(-2,2)
ax.set_xlim(0,5)
plt.show()

And click (just a single click) the annotation (the words "local
max"), then resize your window a little to force a redraw.  The
annotation flips to the bottom left corner.

The fix is in offsetbox.py, DraggableAnnotation.save_offset.  If you
add a call to update_offset() as the last call of that routine,
everything is OK again.  I think that finalize_offset is assuming that
self.annotation.text is in pixels before it starts working with it,
but when update_offset fails to get called (as the case with a click),
self.annotation.xytext is still in axes fraction coordinates.

   def save_offset(self):
ann = self.annotation
x, y = ann.xytext
if isinstance(ann.textcoords, tuple):
xcoord, ycoord = ann.textcoords
x1, y1 = ann._get_xy(self.canvas.renderer, x, y, xcoord)
x2, y2 = ann._get_xy(self.canvas.renderer, x, y, ycoord)
ox0, oy0 = x1, y2
else:
ox0, oy0 = ann._get_xy(self.canvas.renderer, x, y, ann.textcoords)

self.ox, self.oy = ox0, oy0
self.annotation.textcoords = "figure pixels"
self.update_offset(0.0,0.0)  # <--- add this!


It might be sufficient to just set self.annotation.xytext to
self.ox,self.oy instead of calling update_offset like I did above.


-- 
Daniel Hyams
dhy...@gmail.com

--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] bug report and fix for bracket arrow (annotations)

2011-09-16 Thread Daniel Hyams
In  http://matplotlib.sourceforge.net/users/annotations_guide.html ,
about 1/3 of the way down, there is a little demonstrator for the
different arrowstyles ->, <-, ]-, etc.

Looking at the figure closely, there is no difference between the "-["
and "]-" styles.

The fix for this is in patches.py, around line 3276 (matplotlib
1.0.0).  Comments in that routine clipped out for brevity.

   class BracketA(_Bracket):
def __init__(self, widthA=1., lengthA=0.2, angleA=None):

super(ArrowStyle.BracketA, self).__init__(None,True,
 widthA=widthA, lengthA=lengthA, angleA=angleA )

If you flip the first two args of the __init__ call, that fixes it:

   class BracketA(_Bracket):
def __init__(self, widthA=1., lengthA=0.2, angleA=None):

super(ArrowStyle.BracketA, self).__init__(True,None,
## flip these arguments
 widthA=widthA, lengthA=lengthA, angleA=angleA )


-- 
Daniel Hyams
dhy...@gmail.com

--
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] XRC or Pythoncard

2011-09-20 Thread Daniel Hyams
I'm partial to wxFormBuilder myself, and the latest builds even have
AUI support.  There is no direct integration with matplotlib, though.
To place a plot, all I do is create a wx.Panel in wxFormBuilder, and
use that as a container for the plot (you would have a PlotPanel,
which you derive from wx.Panel).  You could also subclass that
container same panel if you wanted to (within wxFormBuilder), but I
don't see the need.

On Tue, Sep 20, 2011 at 7:23 AM, Martijn  wrote:
> Hi,
> I am about to start wring a small application that includes a graphical
> user interface written using wxPython and several matplotlib graphs.
> Since I want to separate application logic and GUI code as much as
> possible, I would like to use either XRC or Pythoncard.
> Pythoncard seems to be the most straightforward and has recently
> included a matplotlib widget. However, the website says that it requires
> some modifications to Matplotlib. I would like to have some feedback
> from people who have embedded Matplotlib into Pythoncard.
> Alternatively, I could use XRC. This seems to be more mature/actively
> developed but involves more GUI code (manually binding callbacks). What
> are your experiences with embedding graphs in GUIs created using wxGlade
> for wxFormBuilder?
>
> with kind regards,
>
> Martijn
>
>
> --
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] finding the bounding box of an arbitrary artist

2011-10-07 Thread Daniel Hyams
I'm wanting to highlight the artist under the cursor with a transparent
Rectangle patch.  To do this, I have very, roughly, in a mouse motion
handler,

under = self.figure.hitlist(ev)
if under:
   artist = under[0]
   bbox = artist.get_window_extent()
   highlight =
matplotlib.patches.Rectangle(xy=bbox.min,width=bbox.width,height=bbox.height,alpha=0.2,color='yellow')
   # further code to blit the last captured graph region with highlight
drawn on top

The main problem is that all artists don't implement get_window_extent(); a
Text object does, and a legend object does, but the Axis objects do not.

So is there a general way to get the bounding box of an artist?  I looked
through the API and didn't see anything there.  I thought this would be easy
to get to, since almost (every?) artist implements contains().  But it looks
like in the case of XAxis, anyway, that the "hitbox" is being calculated on
the fly in XAxis.contains().


-- 
Daniel Hyams
dhy...@gmail.com
--
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Small bug in XAxis.contains() and YAxis.contains()

2011-10-08 Thread Daniel Hyams
The pick radius for the X and Y axis artists are one-sided; is that
intentional?

Original (in class XAxis), file axis.py:

def contains(self,mouseevent):
"""Test whether the mouse event occured in the x axis.
"""
if callable(self._contains): return self._contains(self,mouseevent)

x,y = mouseevent.x,mouseevent.y
try:
trans = self.axes.transAxes.inverted()
xaxes,yaxes = trans.transform_point((x,y))
except ValueError:
return False, {}
l,b = self.axes.transAxes.transform_point((0,0))
r,t = self.axes.transAxes.transform_point((1,1))
inaxis = xaxes>=0 and xaxes<=1 and (
   (yb-self.pickradius) or
   (y>t and y=0 and xaxes<=1 and (
   (yb-self.pickradius) or   # <---
change on this line
   (y>t-self.pickradius and y--
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-19 Thread Daniel Hyams
Ah, thanks so much Michael!  That explanation helps a great deal; I
was always considering things in "straight alpha" format, not even
knowing that there was alternative.

I'll play with this tonight; I don't see any problem getting the thing
working, though, now that I know what agg expects to see...

And yes, alpha support in the image class would be very helpful ;)

On Wed, Oct 19, 2011 at 2:16 PM, Michael Droettboom  wrote:
> You are right that Agg is doing the resizing here.  Agg expects
> premultiplied alpha.  See [1] for information about what that means.
>
> [1] http://en.wikipedia.org/wiki/Alpha_compositing
>
> After Agg interpolates the pixel values, to prevent oversaturation it
> truncates all values to be less than alpha (which makes sense if everything
> is assumed to be premultiplied alpha).  Arguably, the bug here is that
> nearest neighbor (which doesn't have to do any blending) doesn't perform the
> truncation step -- then both would look "wrong".
>
> It happens in this code snippet in span_image_filter_rgba: (base_mask is
> 255)
>
>     if(fg[order_type::A] > base_mask) fg[order_type::A]
> = base_mask;
>     if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R]
> = fg[order_type::A];
>     if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G]
> = fg[order_type::A];
>     if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B]
> = fg[order_type::A];
>
> So, the solution to make a partially transparent image is to not do:
>
>     pix[:,:,3] = 127
>
> but instead, do
>
>     pix *= 0.5
>
> Of course, the real fix here is to support alpha blending properly in the
> image class, then the user wouldn't have to deal with such details.  A bug
> should probably be filed in the matplotlib issue tracker for this.
>
> Mike
>
> On 10/19/2011 12:23 PM, Daniel Hyams wrote:
>
> [Sorry, I keep getting tripped up with HTML mailresent in ascii,
> and resaved one of the attachment png's to make it smaller.]
>
>
> Example script attached (PIL required).  Basically, if I impose a
> specific value into an image's alpha channel and use any interpolation
> scheme other than 'nearest', there appears gray all where the figure
> didn't have any color to begin with.   I've also attached a screenshot
> of the output of the script on my machine.
>
> Hopefully I'm doing something wrongly?
>
> I chased the problem and managed to hack in a solution that fixes the
> problem, but it's extremely inefficient...basically, in matplotlib's
> image.py, routine BboxImage.make_image, you can create two images
> thereone with no alpha channel (call it imRGB) and one with (call
> it imRGBA).  Go through all of the routine, doing exactly the same
> things to both of the images *except* for the interpolation, which is
> set to 'nearest' for imRGBA.  Then, rip the colors out of imRGB, the
> alpha channel off of imRGBA, and put them togethergo through all
> of the routine again with this composited image, and it works.  I
> know...I told you it was bad ;)
>
> The problem seems to be in the "resize" call in that routine...resize,
> which calls into C code, does not appear to handle things correctly
> when the alpha is anything other than 255's across the board.  It
> might be a problem in the agg routines, but hopefully it is just maybe
> a misuse of the agg routines.
>
> The behavior seems to be backend independent as far as I could test (I
> tried with wxagg and tk backends).  I am using mpl 1.0.0 on Windows if
> it matters.
>
>
> --
> Daniel Hyams
> dhy...@gmail.com
>
> --
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2d-oct
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> --
> The demand for IT networking professionals continues to grow, and the
> demand for specialized networking skills is growing even more rapidly.
> Take a complimentary Learning@Ciosco Self-Assessment and learn
> about Cisco certifications, training, and career opportunities.
> http://p.sf.net/sfu/cisco-dev2dev
> __

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-20 Thread Daniel Hyams
I've looked all over the place through both the Python and C code, and
I don't see any premultiplication of alphas at any stage before the
pixels are passed off to agg, and neither can I find any place where
the alphas are "unmultiplied" on the way back from agg to the backend
for rendering.

It's very possible that I missed it, but I would have to miss it in
two places (premultiply and the unmultiply).  It looks to me like the
output from agg ends up getting passed on directly to the renderer,
which as far as I know, just uses straight alpha. The WxAgg renderer,
for example, just creates a wx.Bitmap out of the pixels and blits it.
Which means that any image going through agg's filters will not be
correct if it has any pixels with alpha != 0 or != 255.

[Using PIL images because they are simple to talk about...but the PIL
image could alternatively be an image.py image]

As far as I can tell, the image pixels current go through a pipeline
like the following:

[1] PIL Image -> _image image -> agg operations -> modified and/or
resized _image image -> renderer

If agg expects premultiplied alpha, the procedure should look something like:

[2] PIL Image -> _image image -> premultiply alphas ->agg options ->
unmultiply alphas -> modified and/or resized _image image -> renderer

I personally don't like pipeline [2] because picture detail is lost in
the "unmultiply alphas" stage.  Better to use straight alpha all the
way through.

So long as matplotlib is using only a subset of agg algorithms that
work no matter whether the alphas are premultiplied or not, I would
think that the most reasonable route was the one that I took; to
always pass straight alphas (sticking with pipeline [1]), and modify
the agg source slightly to fit matplotlib's approach (i.e., remove the
clipping there).

I hope that I'm not way off base (I have a sneaking feeling that I am
:O ), and hope this helps.  I've verified on both Linux and Windows
that removing the alpha-clip lines from agg_span_image_filter_rgba.h,
rebuilding matplotlib, and replacing _image.so/_image.pyd and
_backend_agg.so/_backend_agg.pyd does the trick (along with passing
straight alphas).  So far, I've seen no ill effects on any of my
plots, but I'm also not in a position to run the pixel-by-pixel
comparison matplotlib tests.


On Wed, Oct 19, 2011 at 7:26 PM, Daniel Hyams  wrote:
> There has to be something else in play here.  I'll try to keep this
> short, but the summary is this: I can get the transparency to look
> right, but only if 1) I put "straight" alpha in image, not
> premultiplied, and 2) I hack agg to remove specificially every
> instance of the lines of code that you refer to above.
>
> Why this is, I don't know.  Hopefully I'm still misusing something.
> However, it behaves as if the clipping of alpha in the agg library is
> corrupting the alpha channel.  I also submit that I could have broken
> some other transparency capabilities of matplotlib, because I don't
> know what other routines use what I hackedI did check a few
> transparent polygons and such though, and everything seemed to be
> fine.
>
> I know that the agg library has been around for quite a long time, so
> that also means that such a basic bug is unlikely.
>
> I've reattached the (slightly modified) script that reproduces the
> problem, along with a sample image that it uses.  The only change to
> the script is right at the top, where a different image is read, a
> quick statement is placed to add an alpha channel if there is not
> already one, and I'm attempting to use premultiplied alphas.  I've
> also attached a screenshot of the output.  Notice that in this case,
> both "transparent" images look wrong.
>
> Now, if I 1) hack agg to remove the alpha clipping, and 2) modify the
> one line in the attached python script so that I use straight alpha,
> everything looks right.  Specifically, I removed every instance of the
> code below from , rebuilt all of the matplotlib .so's, and
> specifically replaced _image.so and _backend_agg.so in my matplotlib
> distribution.
>
>           if(fg[order_type::A] > base_mask)         fg[order_type::A]
> = base_mask;
>                if(fg[order_type::R] > fg[order_type::A])
> fg[order_type::R] = fg[order_type::A];
>                if(fg[order_type::G] > fg[order_type::A])
> fg[order_type::G] = fg[order_type::A];
>                if(fg[order_type::B] > fg[order_type::A])
> fg[order_type::B] = fg[order_type::A];
>
>
>
>
> On Wed, Oct 19, 2011 at 2:34 PM, Daniel Hyams  wrote:
>>
>> Ah, thanks so much Michael!  That explanation helps a great deal; I
>> was always considering things in "straight alpha" format, not even
&

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-21 Thread Daniel Hyams
All sounds reasonable Mike; I do agree that patching the agg source
code is not that desirable; I was operating under the (incorrect)
assumption that most, if not all, backends used straight alpha.

I'll certainly test the patch tonight, but I can only test it under
wxAgg reasonably, which is one of the backends that expects straight
alpha as far as I know.

The "loss in picture detail" comment was just discomfort with the fact
that once the alphas are premultiplied in, there is not an exact
reverse transformation to get your original color back. In googling
around to better explain here, I found this, which is a much more in
depth and better explanation than what I would have come up with:

http://www.quasimondo.com/archives/000665.php

The crux is here:

>An example: when you set the alpha value of a pixel to 16 all color values 
>will be multiplied with
>a factor of 16/256 = 0.0625. So a gray pixel of 128 will become 128 * 0.0625 = 
>8, a darker pixel
>of 64 will become 64 * 0.0625 = 4. But a slightly lighter pixel of maybe 67 
>will become 67 *
> 0.0625 = 4.1875 - yet there are no decimals in integer pixels which means it 
> will also become
> 4. The effect that you will get posterization - setting your alpha channel to 
> 8 means that you
> also reduce your color channels to 8 levels, this means instead = 256*256*256 
> different colors
> you will end up with a maximum of 8*8*8 = 512 different colors.

One might argue that the loss of color information is not that
crucial, because for very low alpha (where the problem is most
pronounced), the image is almost invisible anyway... so it won't
matter. That's true, but what if I want to (for whatever reason) take
the image's pixels again, before draw, and boost the alpha up again?
What I'll get is a posterized mess.  So, I'm still of the opinion that
patching agg in this situation might be the best solution to this.
This way, straight alphas are used throughout, and for backends that
require premultiplied alpha, the alpha can be premultiplied in at the
latest possible moment.

Thanks for all of the help with this Mike,

Daniel

On Fri, Oct 21, 2011 at 9:31 AM, Michael Droettboom  wrote:
> Thanks for looking into this deeper.
>
> Agg requires image buffers to be premultiplied, as described in the third
> bullet point here.  (It's not exactly clear, to say the least, but that's
> what I take it to mean, and also from reading the code).
>
> http://www.antigrain.com/news/release_notes/v22.agdoc.html
>
> The bug is that in _image.cpp the input buffers are not declared as
> premultiplied in _image.cpp.  Arguably it is a bug that agg doesn't reject
> filtering unmultiplied images, since the note states that the assumption is
> that they are premultiplied by the time they get to the filters.
>
> I have attached a patch that fixes this.  Would you mind testing it and let
> me know how it works for you?
>
> On 10/20/2011 10:29 PM, Daniel Hyams wrote:
>>
>> I've looked all over the place through both the Python and C code, and
>> I don't see any premultiplication of alphas at any stage before the
>> pixels are passed off to agg, and neither can I find any place where
>> the alphas are "unmultiplied" on the way back from agg to the backend
>> for rendering.
>
> matplotlib's support for alpha blending of images is basically by accident,
> so it's not surprising the details aren't right.
>
> I think it is a bug that after reading images in we don't premultiply them
> before sending them to Agg.  That bug has existed for a long time in
> matplotlib because no one is really using alpha images a great deal.
>  (Masked images, yes, but that implies alpha is strictly 0 or 255 and thus
> these issues don't come into play.)
>
> Unmultiplying is not always necessary.  Many of the GUI backends also expect
> premultiplied alpha (Qt for example).  However, there is certainly a bug in
> writing PNG files (where the file format specifies unmultiplied).
>
>> It's very possible that I missed it, but I would have to miss it in
>> two places (premultiply and the unmultiply).  It looks to me like the
>> output from agg ends up getting passed on directly to the renderer,
>> which as far as I know, just uses straight alpha. The WxAgg renderer,
>> for example, just creates a wx.Bitmap out of the pixels and blits it.
>> Which means that any image going through agg's filters will not be
>> correct if it has any pixels with alpha != 0 or != 255.
>>
>> [Using PIL images because they are simple to talk about...but the PIL
>> image could alternatively be an image.py image]
>>
>> As far as I can tell, the image pixels current go through a pipeline
>&

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-21 Thread Daniel Hyams
> Thanks for clarifying.  I understand what you're saying now.  I think
> what we want to do is store the unmultiplied alpha as a "canonical"
> version of the image, and premultiply a copy (or use some C++ iterator
> magic to avoid the copy) right before sending it off to Agg.  Then the
> alpha can be fully "tweakable" at runtime.

Just for my understanding of the design approach of matplotlib in
general, is it implicitly assumed that once pixels have been passed to
agg, they are destined for the renderer?  No other possible use?  And
the life span is short?  I'm just not very familiar with where _image
is used throughout the rest of the code, if at all.

As far as the iterator magic, the kicker is that it would have to take
place inside of agg; it cannot be on the mpl side;

So if I'm understanding correctly,
  1) create a copy of the image within resize()
  2) premultiply the alpha on the copy
  3) let agg do its work, returning its result in a new pixmap
(resized) that is premultiplied.
  4) toss the extra copy made in (1)
  5) in each individual backend's renderer, right before the pixels
are rendered, unmultiply the alpha if necessary (as is the case with
wxagg).

I also remember you making mention of saving pngs above, I suppose
there would have to be an unmultiply there as well.

i've done some grepping through the code, and don't see that these
filter routines are used anywhere except specifically in this resize()
function.  I can fully understand the desire to comply with agg's
spec, but I'm still not convinced that a small patch to agg isn't
appropriate here.  It's a little odiferous, but won't be hard to
maintain given that agg is a very slowly changing library (last
release 2006?).  Or maybe treat patching agg as short term solution.

Looking through the filter algorithms too, it looks like exactly the
same ops are done to each channel (RGBA) separately.  So (it appears
as if, to my untrained eye) that the algorithms are applicable
regardless of whether or not the alphas are premultiplied.  Further,
removing the clip will have very minimal impact on "proper" usage of
agg (i.e. sending in premultiplied alpha).

> I'll try to tackle this problem, as well as the problem that set_alpha
> simply doesn't work, at the same time when I get a chance (or patches
> are always welcome, of course :).

I have a patch, but you don't like it :D

But seriously, I'll take a more careful look at what it would take to
implement items 1-5 above; it might not be so bad, but I'm
uncomfortable dealing with the "underbelly" of matplotlib, as I'm not
familiar with either mpl's design nor the general subject of graphics.

--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-22 Thread Daniel Hyams
Michael:

I commented on the patch here:

https://github.com/matplotlib/matplotlib/issues/545

In short...it works!

--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib.axes.Axes.arrow not producing nice arrows

2011-10-27 Thread Daniel Hyams
I think that the code that generated the screenshot needs to be
posted; otherwise no one knows what is being attempted

On Thu, Oct 27, 2011 at 10:50 AM, mogliii  wrote:
> Hi,
>
> I am trying to place some arrows using
> http://matplotlib.sourceforge.net/api/axes_api.html?highlight=arrow#matplotlib.axes.Axes.arrow
>
> And unfortunately the arrows are not nice (see attached screenshot). How
> can the line end be changed to "round" as, for example, with plot. Or
> anyone can give a solution?
>
> For very small print this might be acceptable, but not if the
> arrow/linewidth is larger.
>
>
> --
> The demand for IT networking professionals continues to grow, and the
> demand for specialized networking skills is growing even more rapidly.
> Take a complimentary Learning@Cisco Self-Assessment and learn
> about Cisco certifications, training, and career opportunities.
> http://p.sf.net/sfu/cisco-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>



-- 
Daniel Hyams
dhy...@gmail.com

--
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Updating/drawing all axes.

2011-10-30 Thread Daniel Welling
Greetings, MatPlotLibbers.

Since 1.1, pyplot.draw() in interactive mode only updates the current axis.
 If I want to update many axes, I need to use sca() and draw() for each
one.  Is there a way to update all axes?

Thanks.
-dw
--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cmap normalization question

2011-10-31 Thread Daniel Hyams
Try

nm = matplotlib.colors.Normalize(desired_min, desired_max)

plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat"),norm=nm)

You could just use the vmin/vmax keywords in the scatter() call, but
I've just always preferred using Normalize(); you have more control
over what happens that way (see docs for Normalize).

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

On Mon, Oct 31, 2011 at 12:02 PM, Tommy Grav  wrote:
> Hi,
>
>   I have been looking around but can't find what I want.
> I have two arrays, one with numbers from 0.02 to 0.20 and
> the other from 0.03 to 0.50. I am trying to plot them together
> with other arrays in a scatterplot where these two are the
> color term
>
> plt.scatter(x1,y1,c=myarr1,cmap=plt.get_cmap("gist_heat))
> plt.scatter(x2,y2,c=myarr2,cmap=plt.get_cmap("gist_heat))
>
> but it seems that each instance of the plot command rescales
> the array such that myarr1.max() and myarr2.max() are both with,
> which means that the two color scales are out of sync. Is there
> a way to force the two plots to respect the values in the array
> have the cmap go from 0 to 1, not from myarr1.min() to myarr1.max()?
>
> Cheers
>  Tommy
>
> --
> Get your Android app more play: Bring it to the BlackBerry PlayBook
> in minutes. BlackBerry App World™ now supports Android™ Apps
> for the BlackBerry® PlayBook™. Discover just how easy and simple
> it is! http://p.sf.net/sfu/android-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com

--
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Loading txt files

2011-11-01 Thread Daniel Hyams
One quick way of doing this is to use numpy:

import numpy

dataset = numpy.genfromtxt(fname='yourfilename',skip_header=1)

http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html

On Tue, Nov 1, 2011 at 8:50 AM, yelena  wrote:
>
> Hi!
> I'm new at Matplotlib, so I need a little help.
> I was trying to load data from txt files with no luck.
> I have 2 collumns in txt files and I need to plot a XY graph. Should I
> modify txt file to other format?
>
> Can someone give me a simple example for doing this?
>
> In txt file could be such information:
> Meters   Seconds
> 1            4
> 2            8
> 3            12
> 4            16
> 5            20
>
> Thanks in advance!
>
> --
> View this message in context: 
> http://old.nabble.com/Loading-txt-files-tp32758393p32758393.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> --
> RSA® Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com

--
RSA® Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Build MPL with VS 2008 problem

2011-11-02 Thread Daniel Hyams
I had to do this sort of thing recently, but I did have to resort to
some hackery to get it done (that I'm not proud of...I was in a bit of
a hurry).  Any corrections and or hand-slappings form the mpl-devs
are, I'm sure, well deserved.  AnywayI can only tell you what I
did to get it working, but cannot vouch for the correctness of the
procedure. I also cannot vouch for the correctness of my recollection
:/

First, I downloaded a few dependencies.  libpng, libfreetype, and
zlib. Installed them all, which put them in c:\program files
(x86)\gnuwin32.

http://gnuwin32.sourceforge.net/packages/libpng.htm
http://gnuwin32.sourceforge.net/packages/freetype.htm
http://gnuwin32.sourceforge.net/packages/zlib.htm

I might have had to download ActiveTcl and install that, too, for the
tk back end.

Now, you should have headers and libraries all in the gnuwin32
directory.  Download matplotlib-1.1.0.tar.gz, and untar it somewhere.
open a Visual C++ command prompt and navigate to the mpl directory.  I
assume that python is in your path, so now do the normal

python setup.py configure   (I know that configure doesn't exist, but
it gives the printout to tell me what is found and what is not).
python setup.py build
python setup.py install

It is likely during the build process that an include such as
ft2font.h might not be found.  I did not spend the time here to figure
out how properly to point matplotlib to the ft2font.h include file
(which is over in the gnuwin32/include dir), so I copied it to the mpl
directory (top level).  I think I ended up doing the same with png.h
and pngconf.h.  Then run python setup.py build again.

Ugly, but it did work.  At some point, I'll go figure out the proper procedure.


On Wed, Nov 2, 2011 at 4:11 PM, Mads Ipsen  wrote:
> On 11/02/2011 08:43 PM, Michael Droettboom wrote:
>
> On 11/02/2011 01:34 PM, Mads Ipsen wrote:
>
> On 11/02/2011 05:50 PM, Michael Droettboom wrote:
>
> On 11/02/2011 10:53 AM, Mads Ipsen wrote:
>
> Any clues to why ft2build.h cannot be located. The above docs says it should
> be part of the binary installer.
>
> The binary for freetype is included with the installer, but the headers
> (needed to build, but not to run) are not.  Do you need to build matplotlib
> from source, or just use it?
>
> Mike
>
> I need to built it from source.
>
> Mads
>
> In that case, you will need to install the development packages for
> freetype, libpng, libz, and numpy.
>
> I'm not a regular Windows user, so I don't know what the best practice is
> for that these days.  Some of the other members on this list can hopefully
> jump in.  There was also a thread on this list about "Building on Windows"
> from 08/18/2011 that might be helpful.
>
> Mike
>
> --
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> I can't seem to find this thread anywhere. It it really that difficult to
> build on Windows? It most be documented somewhere what the prereqs are?
>
> Best regards,
>
> Mads
>
> --
> +-+
> | Mads Ipsen  |
> +--+--+
> | Gåsebæksvej 7, 4. tv |  |
> | DK-2500 Valby| phone:  +45-29716388 |
> | Denmark  | email:  mads.ip...@gmail.com |
> +--+--+
>
>
> --
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>



-- 
Daniel Hyams
dhy...@gmail.com

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib 1.1.0 animation vs. contour plots

2011-11-13 Thread Daniel Hyams
This looks like a bug in matplotlib to me; I get the same thing.

The basic issue is that QuadContourSet is derived from an artist, and
so does not have all of the artist methods; the animation framework
depends on the things that it is animating being artists.

The following monkey patch fixes it in the example script (obviously,
it does not fix the underlying problem; for QuadContourSet to be
usable in this context, it needs to obey the artist interface).
Hopefully, it will be enough to get you up and running.  Just add the
four lines between contour call and the appending of the output of
contour() into the list "ims", and also put an "import types" at the
top.


#!/usr/bin/env python
"""
An animated image
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import types
fig = plt.figure()
def f(x, y):
    return np.sin(x) + np.cos(y)
x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
# ims is a list of lists, each row is a list of artists to draw in the
# current frame; here we are just animating one artist, the image, in
# each frame
ims = []
for i in range(60):
    x += np.pi / 15.
    y += np.pi / 20.
    im = plt.contour(f(x, y))
    def setvisible(self,vis):
       for c in self.collections: c.set_visible(vis)
    im.set_visible = types.MethodType(setvisible,im,None)
    im.axes = plt.gca()
    ims.append([im])
ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,
    repeat_delay=1000)
ani.save('dynamic_images.mp4')

plt.show()

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib 1.1.0 animation vs. contour plots

2011-11-13 Thread Daniel Hyams
Oops; my sentence should have read "is *not* derived from an artist".

On Sun, Nov 13, 2011 at 1:24 PM, Benjamin Root  wrote:
>
>
> On Sunday, November 13, 2011, Daniel Hyams  wrote:
>> This looks like a bug in matplotlib to me; I get the same thing.
>>
>> The basic issue is that QuadContourSet is derived from an artist, and
>> so does not have all of the artist methods; the animation framework
>> depends on the things that it is animating being artists.
>>
>> The following monkey patch fixes it in the example script (obviously,
>> it does not fix the underlying problem; for QuadContourSet to be
>> usable in this context, it needs to obey the artist interface).
>> Hopefully, it will be enough to get you up and running.  Just add the
>> four lines between contour call and the appending of the output of
>> contour() into the list "ims", and also put an "import types" at the
>> top.
>>
>>
>> #!/usr/bin/env python
>> """
>> An animated image
>> """
>> import numpy as np
>> import matplotlib.pyplot as plt
>> import matplotlib.animation as animation
>> import types
>> fig = plt.figure()
>> def f(x, y):
>>     return np.sin(x) + np.cos(y)
>> x = np.linspace(0, 2 * np.pi, 120)
>> y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
>> # ims is a list of lists, each row is a list of artists to draw in the
>> # current frame; here we are just animating one artist, the image, in
>> # each frame
>> ims = []
>> for i in range(60):
>>     x += np.pi / 15.
>>     y += np.pi / 20.
>>     im = plt.contour(f(x, y))
>>     def setvisible(self,vis):
>>        for c in self.collections: c.set_visible(vis)
>>     im.set_visible = types.MethodType(setvisible,im,None)
>>     im.axes = plt.gca()
>>     ims.append([im])
>> ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True,
>>     repeat_delay=1000)
>> ani.save('dynamic_images.mp4')
>>
>> plt.show()
>>
>
> Technically speaking, it is derived from ScalarMappable, not Artist. It is
> counter-intuitive, though.
>
> Ben Root



-- 
Daniel Hyams
dhy...@gmail.com

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Updating/drawing all axes.

2011-11-13 Thread Daniel Welling
Sorry for the very slow reponse time; it's a busy time of the year.
 Anyway, I've narrowed the problem quite a bit.
Here is the kind of situation that causes the issue:

import matplotlib.pyplot as plt
plt.ion()

f1=plt.figure()
a1=f1.add_subplot(111)

f2=plt.figure()
a2=f2.add_subplot(111)

a1.plot([0,1])
a2.plot([0,1])

plt.draw()

Here, f2 is drawn but f1 only draws the axis object without the line; you
must do something else to trigger f1 to draw (e.g. use one of the gui
features or make it the current axis, then draw.)  The key to recreating
this issue is to make the plots in "parallel", that is, make one fig, make
another, make one ax, make the other, plot one line, plot the other, etc.

This will narrow it down further: I can only recreate this issue on my OS X
system; my Ubuntu box does not have this issue.  Here's as much info as I
can drum up now; let me know what else would be helpful.

OS X 10.6.8, Python 2.6.7 (r267:88850, Oct 17 2011, 15:53:34); IPython
0.10.1 (all installed through MacPorts.)  MPL 1.1.0 obtained from the MPL
website and installed manually (e.g. not through macports); TkAgg backend.
 Because it's a macports install, it should be a mac Framework install of
python.

Again, this problem did not manifest until MPL 1.1.0.
Thanks for your help.
-dw

On Sun, Oct 30, 2011 at 10:06 AM, John Hunter  wrote:

> .draw()
>
> On Sun, Oct 30, 2011 at 10:51 AM, Daniel Welling 
> wrote:
> > Greetings, MatPlotLibbers.
> >
> > Since 1.1, pyplot.draw() in interactive mode only updates the current
> axis.
> >  If I want to update many axes, I need to use sca() and draw() for each
> one.
> >  Is there a way to update all axes?
>
> I'm not seeing this, and I'm not sure *why* it would be occurring for
> you.  plt.draw triggers a call to fig.canvas.draw which calls draw on
> all axes.  Here is some example code in ipython, which has 'ion".
>
>  In [2]: fig, axes = plt.subplots(2)
>
>  In [3]: axes[0].plot([1,2,3])
>  Out[3]: []
>
>  In [4]: axes[1].plot([1,2,3])
>  Out[4]: []
>
>  In [5]: plt.draw()
>
>
> The call to 'plt.draw' on line 5 triggers a draw to both axes.  Can
> you provide an example which exposes your problem?  Please also
> provide backend and OS information
>
>  In [6]: !uname -a
>  Linux pinchiepie 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25
> UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
>
>  In [7]: import matplotlib; print matplotlib.__version__
>  1.2.x
>
>  In [8]: matplotlib.rcParams['backend']
>  Out[8]: 'WXAgg'
>
>
> JDH
>
--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Triangulation objects

2011-11-13 Thread Daniel Welling
Greetings.

I am interested in accessing Triangulation objections that are created by
MPL for tricontour-type plots.  The docs for MPL routines that use
triangulation objects refer to documentation, but none exists in the MPL
online docs.  Does anyone have docs/info on using these objects?  Having
access to them would be great.

-dw
--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib 1.1.0 animation vs. contour plots

2011-11-13 Thread Daniel Hyams
>
> OK, types is a new part of the Python library for me, I'll have to go
> learn about it.  It looks like you basically just subclassed the
> QuadContourSet object through a back door, by giving it the missing
> method.

It's not a subclass, it's just a "monkey patch".  I personally like
"duck punching", because even just reading the term makes me laugh:
"If it walks like a duck and quacks like a duck, it's a duck; or if it
does not walk or talk like a duck, punch it until it does".  In this
case, we're punching the QuadContourSet until it behaves like an
Artist.  It's a useful technique for experimenting, and can be used as
a patching technique in the interim until it is fixed properly.  You
never want to write code like this on a regular basis, however.


> Your patch solves one of two animation problems, and I offer a
> suggestion about how to fix the second (with questions).
>
> The program gets as far as ani.save() on line 29 without generating any
> errors. An MP4 file showing animated contours is written to disk.  The
> origin of the contour plot is in the lower left, versus the upper left
> of the original imshow() call, but that's expected.
>
> When you get to plt.show() on line 31, however:
>
> Traceback (most recent call last):
>  File
> "/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_gtk.py", 
> line 127, in _on_timer
>    TimerBase._on_timer(self)
>  File
> "/usr/local/lib/python2.6/dist-packages/matplotlib/backend_bases.py",
> line 1091, in _on_timer
>    ret = func(*args, **kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/matplotlib/animation.py",
> line 317, in _step
>    still_going = Animation._step(self, *args)
>  File "/usr/local/lib/python2.6/dist-packages/matplotlib/animation.py",
> line 179, in _step
>    self._draw_next_frame(framedata, self._blit)
>  File "/usr/local/lib/python2.6/dist-packages/matplotlib/animation.py",
> line 199, in _draw_next_frame
>    self._post_draw(framedata, blit)
>  File "/usr/local/lib/python2.6/dist-packages/matplotlib/animation.py",
> line 222, in _post_draw
>    self._blit_draw(self._drawn_artists, self._blit_cache)
>  File "/usr/local/lib/python2.6/dist-packages/matplotlib/animation.py",
> line 236, in _blit_draw
>    bg_cache[a.axes] = a.figure.canvas.copy_from_bbox(a.axes.bbox)
> AttributeError: QuadContourSet instance has no attribute 'figure'

It looks like just one more duck punch is needed; just set

im.figure = fig

after the setting of im.axes.  QuadContourSet should really call
a.get_axes() and a.get_figure() instead of using the attributes
directly; doing so would allow any object that implements the proper
interfaces to work, artist or no.

> Is this error occurring because there is no bit-mapped representation of
> a contour object?

It's not really that, it's just that the animation class expects to be
given a list of Artists to work with (the original author can correct
me if I'm wrong), and that's not what it is being given, because a
QuadContourSet is not an Artist.  But you can duck punch it until it
acts like one :D

IMO, there are quite a few things in matplotlib that are a little
inconsistent in this way.

-- 
Daniel Hyams
dhy...@gmail.com

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib 1.1.0 animation vs. contour plots

2011-11-13 Thread Daniel Hyams
It's not "official", but just idiomatic, I suppose ;)

http://en.wikipedia.org/wiki/Monkey_patch

http://paulirish.com/2010/duck-punching-with-jquery/


>
> Is that an official term? I have done things like this before, but never had
> a word for it.
>
> Ben Root
>



-- 
Daniel Hyams
dhy...@gmail.com

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Triangulations and Polar Plots

2011-11-14 Thread Daniel Welling
Greetings.

I recently found myself in the position of needing to plot polar,
irregularly spaced data.  I've done similar using regularly spaced values
with no problem.  However, I've found that when the points become greatly
scattered, the triangulation does not translate from rectangular to polar
very well.  Below, find a code example that shows this; though it is much
"better" than my real-world case that uses simulation results.
 Essentially, in the translation from regular to polar axes, many of the
triangles overlap others, many features of the plot are lost, and the plot
looks mangled in certain regions, esp. across the theta=0 boundary.  While
subtle here (but MUCH worse in the results I'm trying to visualize), some
of the triangles lie outside of the triangulated region.  It isn't merely
that the polar plot is suffering from poor data coverage; the triangulation
is not working properly in polar coordinates and the results are
quantitatively different than the rectangular plot.

The obvious work-around for this problem illustrates the issue more
clearly.  If we convert rad, theta back to x, y and do a rectangular plot,
the triangulation is much better (not only is there no issue around
theta=0, but there are no overlapping triangles), all of the details of the
non-polar version are maintained, and the plot looks great.  This is not
the best solution, as polar plots in Matplotlib are quite elegant.

Any help here would be appreciated.  It could be that triangulations are
just not suited for polar plots; it could be that the theta=0 issue throws
things off, etc; I'm just not sure.  It would be perfect if I could use the
polar axes in the end.

Thanks.
-dw

#!/usr/bin/env python
'''
Demonstrate troubles with polar plots and triangulations.
'''
import numpy as np
import matplotlib.pyplot as plt

# Regular grid:
angle=np.linspace(0, 2*np.pi, 20)
x=np.tile(angle,20)
y=np.repeat(angle,20)
z=np.cos(x)*np.sin(y)

# Irregular grid:
x_ir=2*np.pi*np.random.random(400)
y_ir=2*np.pi*np.random.random(400)
z_ir=np.cos(x_ir)*np.sin(y_ir)

f=plt.figure()
a1=f.add_subplot(221)
a1.tricontourf(x,y,z); a1.plot(x,y, 'k+')
a2=f.add_subplot(222, polar=True)
a2.tricontourf(x,y,z); a2.plot(x,y, 'k+')
a2.triplot(x,y)

a3=f.add_subplot(223)
a3.tricontourf(x_ir,y_ir,z_ir); a3.plot(x_ir,y_ir, 'k+')
a4=f.add_subplot(224, polar=True)
a4.tricontourf(x_ir,y_ir,z_ir); a4.plot(x_ir,y_ir, 'k+')
a4.triplot(x_ir,y_ir)

# "Fix" back to rectangular.
x=y_ir*np.cos(x_ir)
y=y_ir*np.sin(x_ir)
f=plt.figure(); ax=f.add_subplot(111)
ax.tricontourf(x,y,z_ir)
ax.triplot(x,y)
--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [ploting data] Live data

2011-12-02 Thread Daniel Hyams
I don't have PyQt installed, so I couldn't test the code, but don't you
want to be using "extend" and not "append", if you are returning a list
from your two get_info() functions?

On Fri, Dec 2, 2011 at 8:13 AM, Fabien Lafont wrote:

> Hello everyone, I'm trying to plot live data extracting from remote
> devices (here it's simulated by get_info1 and 2 the result is always
> 0.8 or 0.9
>
> I can't understand why it doesnt plot the graph at the end of the
> while loop. Does somebody has an idea?
>
> #!/usr/bin/env python
>
> from visa import *
> from pylab import *
> import sys
> from PyQt4 import QtGui
> import numpy as np
> from matplotlib.figure import Figure
> from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
> FigureCanvas
> from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
> as NavigationToolbar
>
>
> #===
> #
>
> #===
>
> class CPUMonitor(FigureCanvas):
>"""Matplotlib Figure widget"""
>def __init__(self,parent):
>
># first image setup
>self.fig = Figure()
>self.ax = self.fig.add_subplot(111)
># initialization of the canvas
>FigureCanvas.__init__(self, self.fig)
># set specific limits for X and Y axes
>self.ax.set_xlim(0, 2)
>self.ax.set_ylim(0, 1.5)
>
>
># generates first "empty" plots
>self.user, self.nice = [], []
>self.l_user, = self.ax.plot([], self.user, label='Voltage')
>self.l_nice, = self.ax.plot([], self.nice, label='Voltage2')
>
>
>
>self.ax.legend()
>
># force a redraw of the Figure
>self.fig.canvas.draw()
>
>self.principal()
>
>
>
>
>def principal(self) :
>stop = 0
>while stop==0 :
>time.sleep(1)
>self.set_voltage()
>time.sleep(1)
>result1 = self.get_info()
>result2 = self.get_info2()
>
> #  append new data to the datasets
>self.user.append(result1)
>self.nice.append(result2)
>
>self.l_user.set_data(range(len(self.user)), self.user)
>self.l_nice.set_data(range(len(self.nice)), self.nice)
>
># force a redraw of the Figure
>
>self.fig.canvas.draw()
>FigureCanvas.updateGeometry(self)
>
>def get_info(self):
>return [0.8]
>
>def get_info2(self) :
>return [0.9]
>
>def set_voltage(self) :
>print "ok"
>
>
>
>
>
> #===
> #
>
> #===
>
>
>
> class ApplicationWindow(QtGui.QMainWindow):
>"""Example main window"""
>def __init__(self):
># initialization of Qt MainWindow widget
>QtGui.QMainWindow.__init__(self)
># set window title
>self.setWindowTitle("QHE manip")
># instantiate a widget, it will be the main one
>self.main_widget = QtGui.QWidget(self)
># create a vertical box layout widget
>vbl = QtGui.QVBoxLayout(self.main_widget)
># instantiate our Matplotlib canvas widget
>qmc = CPUMonitor(self.main_widget)
># instantiate the navigation toolbar
>ntb = NavigationToolbar(qmc, self.main_widget)
># pack these widget into the vertical box
>vbl.addWidget(qmc)
>vbl.addWidget(ntb)
>
># set the focus on the main widget
>self.main_widget.setFocus()
># set the central widget of MainWindow to main_widget
>self.setCentralWidget(self.main_widget)
>
> # create the GUI application
> qApp = QtGui.QApplication(sys.argv)
> # instantiate the ApplicationWindow widget
> aw = ApplicationWindow()
> # show the widget
> aw.show()
> # start the Qt main loop execution, exiting from this script
> # with the same return code of Qt application
> sys.exit(qApp.exec_())
>
>
> ------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _

[Matplotlib-users] collections?

2011-12-09 Thread Daniel Hyams
I can't tell if I'm misusing collections here, or if there is a bug.
 Anyway, what I'm trying to do is keep track of a group of rectangles
generated from a bar plot.  Instead of letting there be a large number of
artists added to the axes, I wanted to just group them into a collection
and add the collection instead.  As in the code below:

#!/usr/bin/env python
import numpy
import matplotlib.pyplot as plt
import matplotlib.collections

# just generate some data to plot
x = numpy.linspace(0.0,2.0*numpy.pi,10)
y = numpy.sin(x)

# plot
axes = plt.gca()
bars = plt.bar(x,y,color='red',width=0.1)

# strip out all of the newly inserted rectangles
for b in bars: b.remove()

# and create a collection for plotting the rectangles instead.
coll = matplotlib.collections.PatchCollection(bars)

axes.artists.append(coll)

plt.xlim(0.0,2.0*numpy.pi)
plt.grid(True)
plt.show()

This appears to work at first blush, but if you resize the plot, you can
tell that the rectangles are just fixed in their location now.  I tried
messing around with setting the transform for the new collection object
"coll" in different ways, to no avail.  Any suggestions welcome ;)

-- 
Daniel Hyams
dhy...@gmail.com
--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] collections?

2011-12-09 Thread Daniel Hyams
Tried, but unfortunately it did not make any difference :(

On Fri, Dec 9, 2011 at 2:22 PM, Tony Yu  wrote:

>
>
> On Fri, Dec 9, 2011 at 2:13 PM, Daniel Hyams  wrote:
>
>> I can't tell if I'm misusing collections here, or if there is a bug.
>>  Anyway, what I'm trying to do is keep track of a group of rectangles
>> generated from a bar plot.  Instead of letting there be a large number of
>> artists added to the axes, I wanted to just group them into a collection
>> and add the collection instead.  As in the code below:
>>
>> #!/usr/bin/env python
>> import numpy
>> import matplotlib.pyplot as plt
>> import matplotlib.collections
>>
>> # just generate some data to plot
>> x = numpy.linspace(0.0,2.0*numpy.pi,10)
>> y = numpy.sin(x)
>>
>> # plot
>> axes = plt.gca()
>> bars = plt.bar(x,y,color='red',width=0.1)
>>
>> # strip out all of the newly inserted rectangles
>>  for b in bars: b.remove()
>>
>> # and create a collection for plotting the rectangles instead.
>> coll = matplotlib.collections.PatchCollection(bars)
>>
>> axes.artists.append(coll)
>>
>> plt.xlim(0.0,2.0*numpy.pi)
>> plt.grid(True)
>> plt.show()
>>
>> This appears to work at first blush, but if you resize the plot, you can
>> tell that the rectangles are just fixed in their location now.  I tried
>> messing around with setting the transform for the new collection object
>> "coll" in different ways, to no avail.  Any suggestions welcome ;)
>>
>> --
>> Daniel Hyams
>> dhy...@gmail.com
>>
>> try transOffset:
>
> >>> coll = matplotlib.collections.PatchCollection(bars,
> transOffset=axes.transData)
>
> I've always found this a bit clumsy, but I think it's the standard way to
> do it.
>
> -Tony
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] collections?

2011-12-09 Thread Daniel Hyams
I'm sorry, I should have stated the version.  I'm using 1.0.0, which just
returns a list of rectangle artists.

On Fri, Dec 9, 2011 at 4:08 PM, Benjamin Root  wrote:

> On Fri, Dec 9, 2011 at 2:55 PM, Daniel Hyams  wrote:
>
>> Tried, but unfortunately it did not make any difference :(
>>
>>
> Just as an interesting point... don't know if it means anything.  In
> v1.1.x, we now return a "BarContainer" from the bar() function.  This
> container subclasses the tuple type, which is why you are still able to
> treat it like a list.  Anyway, this class does a bunch of things that I
> wonder if it could be interfering with what you are trying to do.  Probably
> not, but still...
>
> Ben Root
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] collections?

2011-12-11 Thread Daniel Hyams
Thanks so much Tony...that does indeed work.  I'm not sure if I understand
exactly why, but I'll continue to bang my head on it for a while ;)

The set_transform() call is needed if you throw the collection into the
axes.artists list, but not if axes.add_collection() is used to (ahem) add
the collection.

On Fri, Dec 9, 2011 at 5:27 PM, Tony Yu  wrote:

>
> On Fri, Dec 9, 2011 at 5:23 PM, Tony Yu  wrote:
>
>>
>>
>> On Fri, Dec 9, 2011 at 4:11 PM, Daniel Hyams  wrote:
>>
>>> I'm sorry, I should have stated the version.  I'm using 1.0.0, which
>>> just returns a list of rectangle artists.
>>>
>>>
>>> On Fri, Dec 9, 2011 at 4:08 PM, Benjamin Root  wrote:
>>>
>>>> On Fri, Dec 9, 2011 at 2:55 PM, Daniel Hyams  wrote:
>>>>
>>>>> Tried, but unfortunately it did not make any difference :(
>>>>>
>>>>>
>>>> Just as an interesting point... don't know if it means anything.  In
>>>> v1.1.x, we now return a "BarContainer" from the bar() function.  This
>>>> container subclasses the tuple type, which is why you are still able to
>>>> treat it like a list.  Anyway, this class does a bunch of things that I
>>>> wonder if it could be interfering with what you are trying to do.  Probably
>>>> not, but still...
>>>>
>>>> Ben Root
>>>>
>>>>
>>>
>>>
>>> --
>>> Daniel Hyams
>>> dhy...@gmail.com
>>>
>>
>> So I think the problem is that ``plt.bar`` assigns a transform to each
>> patch (as it should). But then when pass these patches to PatchCollection,
>> the collection applies it's own transform (but doesn't ignore the patch's
>> transform, apparently). The solution is to clear out the transform on each
>> patch---where "clearing" a transform translates to setting it to the
>> IdentityTransform.
>>
>> Below is code that works *on my system*. It sounds like it will work
>> slightly differently on your system:
>>
>>
>> #!/usr/bin/env python
>> import numpy
>> import matplotlib.pyplot as plt
>> import matplotlib.collections
>>  import matplotlib.transforms as transforms
>>
>>
>> # just generate some data to plot
>> x = numpy.linspace(0.0,2.0*numpy.pi,10)
>> y = numpy.sin(x)
>>
>> # plot
>> axes = plt.gca()
>> bars = plt.bar(x,y,color='red',width=0.1)
>>
>> axes.patches = []
>> for p in bars.patches:
>> p.set_transform(transforms.IdentityTransform())
>>
>> ## and create a collection for plotting the rectangles instead.
>> coll = matplotlib.collections.PatchCollection(bars.patches)
>>
>> coll.set_transform(axes.transData)
>> axes.add_collection(coll, autolim=True)
>>
>> plt.xlim(0.0,2.0*numpy.pi)
>> plt.grid(True)
>> plt.show()
>>
>>
>>
> P.S. you don't need the call to set_transform that I accidentally added.
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] cycling mechanism

2012-01-05 Thread Daniel Hyams
Right, __slots__ is definitely not a good idea to use except in very
specific situations.  I would strongly recommend against its usage here.

http://groups.google.com/group/comp.lang.python/msg/0f2e859b9c002b28



On Thu, Jan 5, 2012 at 3:50 PM, Eric Firing  wrote:

> On 01/05/2012 07:34 AM, Ryan May wrote:
> > On Thu, Jan 5, 2012 at 10:58 AM, Benjamin Root  wrote:
> >>
> >>
> >> On Thu, Jan 5, 2012 at 10:40 AM, Benjamin Root  wrote:
> >>>
> >>>
> >>>> At the very least, it would help in compartmentallizing all the
> possible
> >>>> drawing attributes that are common across all artists.  Currently, I
> am
> >>>> envisioning using a defaultdict object (which was introduced in
> python 2.5)
> >>>> or subclassing from it.  This might help in keeping compatibility with
> >>>> existing code.  Subclassing would allow for modifying __get__ and
> __set__ to
> >>>> treat some elements like 'c' and 'color', 'lw' and 'linewidth' and so
> on as
> >>>> the same.
> >>
> >>
> >> G, in defaultdict(), the default_factory is called without
> arguments, so
> >> a factory can't be made to produce a default value for a given key,
> unless I
> >> resort to more hackary...
> >
> > Might be better to explicitly use properties for this rather than
> > overriding dict:
> >
> > class Style(object):
> >  __slots__ = ('_lw')
> >
> >  def __init__(self, lw=None):
> >  self.lw = lw
> >
> >  def _set_linewidth(self, lw):
> >  self._lw = lw
> >
> >  def _get_linewidth(self):
> >  return self._lw
> >
> >  lw = property(_get_linewidth, _set_linewidth)
> >  linewidth = property(_get_linewidth, _set_linewidth)
> >
> > Declaring slots allows you to keep the available attributes to those
> > explicity listed. This way, you can't set a random (misspelled?)
> > attribute and wonder for hours why style.edgcolor = 'blue' doesn't
> > work.
>
> This seems useful, and may be OK for this application; but a little
> googling indicates that it is not really what __slots__ was intended
> for, it is at best controversial, and it should be used very sparingly
> and carefully.
>
> Eric
>
> >
> > Ryan
> >
>
>
>
> --
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to plot Chebyshev polynolmials

2012-01-10 Thread Daniel Hyams
I think that you're misusing Chebyshev (do you really only want to give "3"
as a coefficient..which is just the constant function 3), and you have to
evaluate it in order to give matplotlib some x and y data to plot.

from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(-1.0,1.0)
test = np.polynomial.Chebyshev((1,2,3))
y = test(x)
plt.plot(x,y)
plt.show()



On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont wrote:

> I'm trying to plot Chebyshev polynolmials using:
> numpy.polynomial.Chebyshev:
>
>
> import math
> from numpy import *
> from numpy import polynomial as pol
> from pylab import *
> from scipy import *
> from scipy import optimize
> import warnings
> warnings.simplefilter('ignore', np.RankWarning)
>
>
> test = pol.Chebyshev(3)
> print test
> plot (test)
>
>
> show()
> ===
>
> The print return:  cheb([ 3.])
>
> ===
> and plot :
>
>
> Traceback (most recent call last):
>  File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line
> 32, in 
>plot (test)
>  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458, in
> plot
>ret = ax.plot(*args, **kwargs)
>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in
> plot
>self.add_line(line)
>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443,
> in add_line
>self._update_line_limits(line)
>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451,
> in _update_line_limits
>p = line.get_path()
>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644,
> in get_path
>self.recache()
>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in
> recache
>y = np.asarray(yconv, np.float_)
>  File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line
> 235, in asarray
>return array(a, dtype, copy=False, order=order)
> TypeError: float() argument must be a string or a number
>
>
> --
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create
> new or port existing apps to sell to consumers worldwide. Explore the
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> http://p.sf.net/sfu/intel-appdev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to plot Chebyshev polynolmials

2012-01-10 Thread Daniel Hyams
Regardless of exactly which polynomial you are after, I've showed you how
to plot a cheb. poly.  Can you not work with the code given and plot the
exact variation of polynomial you want?



On Tue, Jan 10, 2012 at 9:46 AM, Fabien Lafont wrote:

> No I just want to plot the third Shebitchev polynomial.
>
> 2012/1/10 Daniel Hyams :
> > I think that you're misusing Chebyshev (do you really only want to give
> "3"
> > as a coefficient..which is just the constant function 3), and you have to
> > evaluate it in order to give matplotlib some x and y data to plot.
> >
> > from matplotlib import pyplot as plt
> > import numpy as np
> >
> > x = np.linspace(-1.0,1.0)
> > test = np.polynomial.Chebyshev((1,2,3))
> > y = test(x)
> > plt.plot(x,y)
> > plt.show()
> >
> >
> >
> > On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont 
> > wrote:
> >>
> >> I'm trying to plot Chebyshev polynolmials using:
> >> numpy.polynomial.Chebyshev:
> >>
> >>
> >> import math
> >> from numpy import *
> >> from numpy import polynomial as pol
> >> from pylab import *
> >> from scipy import *
> >> from scipy import optimize
> >> import warnings
> >> warnings.simplefilter('ignore', np.RankWarning)
> >>
> >>
> >> test = pol.Chebyshev(3)
> >> print test
> >> plot (test)
> >>
> >>
> >> show()
> >> ===
> >>
> >> The print return:  cheb([ 3.])
> >>
> >> ===
> >> and plot :
> >>
> >>
> >> Traceback (most recent call last):
> >>  File "T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py", line
> >> 32, in 
> >>plot (test)
> >>  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2458,
> in
> >> plot
> >>ret = ax.plot(*args, **kwargs)
> >>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3849, in
> >> plot
> >>self.add_line(line)
> >>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1443,
> >> in add_line
> >>self._update_line_limits(line)
> >>  File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 1451,
> >> in _update_line_limits
> >>p = line.get_path()
> >>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 644,
> >> in get_path
> >>self.recache()
> >>  File "C:\Python27\lib\site-packages\matplotlib\lines.py", line 401, in
> >> recache
> >>y = np.asarray(yconv, np.float_)
> >>  File "C:\Python27\lib\site-packages\numpy\core\numeric.py", line
> >> 235, in asarray
> >>return array(a, dtype, copy=False, order=order)
> >> TypeError: float() argument must be a string or a number
> >>
> >>
> >>
> --
> >> Write once. Port to many.
> >> Get the SDK and tools to simplify cross-platform app development. Create
> >> new or port existing apps to sell to consumers worldwide. Explore the
> >> Intel AppUpSM program developer opportunity.
> appdeveloper.intel.com/join
> >> http://p.sf.net/sfu/intel-appdev
> >> ___
> >> Matplotlib-users mailing list
> >> Matplotlib-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
> >
> >
> > --
> > Daniel Hyams
> > dhy...@gmail.com
> >
> >
> --
> > Write once. Port to many.
> > Get the SDK and tools to simplify cross-platform app development. Create
> > new or port existing apps to sell to consumers worldwide. Explore the
> > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> > http://p.sf.net/sfu/intel-appdev
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Selecting a color from a given color map.

2012-02-16 Thread Daniel Welling
Greetings.

I have a series of lines that I would like to plot on the same axis,
but I would like to set the color of each such that the range of
colors used progresses through a given color map (e.g. the default Jet
map.)  For example, if I have 7 lines, the first would use the first
most color from the Jet color map (blue.)  The next line would use the
color that is 1/7 the way up the map, e.g. green or so.  This would
continue until the last line was red.

How would I go about doing this (that is, loading a color map and
pulling a specific color from it that could be handed to plot as an
rgba tuple)?

Thanks!
-dw

--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] sample to contribute to mpl gallery

2012-03-20 Thread Daniel Hyams
Oops, one thing about the graph that I forgot to point out...does the
antialiasing look a little funny?  It seems a bit inconsistent, especially
as the line goes flat.  I increased the line width in an effort to make it
less obvious;  is there some other way to improve this behavior?
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plot line/Line2D with edgecolor

2012-06-27 Thread Daniel Platz
Hello,

I would like to plot a simple line using plt.plot(x, y, ‘w--’, lw=2)
or with the corresponding axes instance ax.plot(x, y, ‘w--’, lw=2).
However, I want the line to have a thin black edge like the edge of a
marker. Is this possible? I tried to find a property of the Line2D
object but I could not find anything. Has someone an idea?

Thanks in advance

Daniel

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Two panels (wxPython) containing separate figures

2012-07-11 Thread Daniel Hyams
To get rid of the networkx dependency, I just replaced my_plot() with this:

def my_plot(figure):
figure.clear()
axes = figure.add_subplot(1,1,1)
axes.plot([0,1,2],[2,3,4])

and also added "self.panel2.update_display()" in the constructor for
MyFrame, and everything worked fine.  Could it be networkx caching a
reference to a figure or axes that is really the problem?  Can you post the
full stack trace instead of just the last line?



On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler wrote:

> Hi all,
>
> I am currently trying to have two panels each with their own figure
> instance so they can have separate plots.
>
> I can successfully update a plot if there is only one panel. As soon as I
> add a second panel, I get the following error when I try to update (replot)
> a plot (Showing last message only):
>
> File
> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py",
> line 1374, in _sci
> "Argument must be an image, collection, or ContourSet in this Axes")
> ValueError: Argument must be an image, collection, or ContourSet in this
> Axes
>
> I looked online first and one site suggested it was because I was using
> matplotlib.Figure instead of pylab.Figure. I switched and the problem still
> occurs. I was curious to see if this problem had to do with how I set up my
> program, not with matplotlib, so I wrote a little test program. The exact
> same problem occurs. I have attached the test program. To see that it does
> work with just one panel comment out lines 39, 41, and 49. When put back
> in, I get the above error message.
>
> Any suggestions as to how to fix this?
>
> Thanks!
>
> Josh
>
>
>
>
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Two panels (wxPython) containing separate figures

2012-07-11 Thread Daniel Hyams
Just from morbid curiosity, I installed networkx to see if I could see what
is going on.  And the answer to your original question is that no,
matplotlib doesn't have problems with multiple wx panels; I do this all the
time.

Basically what is going on is that pylab is being used inside of networkx
to issue the plotting commands.  That's a bad idea in general, because of
just this type of situation.  Without getting in there and trying to fix
networkx, I can at least make your script work by inserting this line:

def my_plot(figure):
figure.clear()
plt.figure(figure.number) <---
G = nx.star_graph(15)
axes = figure.add_subplot(1,1,1)
nx.draw_networkx(G, ax=axes)

to make sure that before nx.draw_networkx is invoked, the correct figure is
current.  That's a kludge, but it does work.  The proper solution is to
modify networkx to use the api's properly.  In particular, the glaring one
is right at the top of

site-packages/networkx/drawing/nx_pylab.py, line 119; that

cf = pylab.gcf()

should at least be

if ax is None:
   cf = pylab.gcf()
else:
   cf = ax.get_figure()

[I think]

The above should be reported to the networkx authors.






On Wed, Jul 11, 2012 at 1:02 PM, Daniel Hyams  wrote:

> To get rid of the networkx dependency, I just replaced my_plot() with this:
>
> def my_plot(figure):
> figure.clear()
> axes = figure.add_subplot(1,1,1)
> axes.plot([0,1,2],[2,3,4])
>
> and also added "self.panel2.update_display()" in the constructor for
> MyFrame, and everything worked fine.  Could it be networkx caching a
> reference to a figure or axes that is really the problem?  Can you post the
> full stack trace instead of just the last line?
>
>
>
> On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler wrote:
>
>> Hi all,
>>
>> I am currently trying to have two panels each with their own figure
>> instance so they can have separate plots.
>>
>> I can successfully update a plot if there is only one panel. As soon as I
>> add a second panel, I get the following error when I try to update (replot)
>> a plot (Showing last message only):
>>
>> File
>> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py",
>> line 1374, in _sci
>> "Argument must be an image, collection, or ContourSet in this Axes")
>> ValueError: Argument must be an image, collection, or ContourSet in this
>> Axes
>>
>> I looked online first and one site suggested it was because I was using
>> matplotlib.Figure instead of pylab.Figure. I switched and the problem still
>> occurs. I was curious to see if this problem had to do with how I set up my
>> program, not with matplotlib, so I wrote a little test program. The exact
>> same problem occurs. I have attached the test program. To see that it does
>> work with just one panel comment out lines 39, 41, and 49. When put back
>> in, I get the above error message.
>>
>> Any suggestions as to how to fix this?
>>
>> Thanks!
>>
>> Josh
>>
>>
>>
>>
>>
>>
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> --
> Daniel Hyams
> dhy...@gmail.com
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Two panels (wxPython) containing separate figures

2012-07-11 Thread Daniel Hyams
Josh:

I'm assuming that you saw the workaround two messages up?

On Wed, Jul 11, 2012 at 1:41 PM, Joshua Koehler wrote:

> Here is the full traceback from the sample program:
>
> Traceback (most recent call last):
>   File "panel_test.py", line 54, in 
> frame = MyFrame(None)
>   File "panel_test.py", line 42, in __init__
> self.panel1.update_display()
>   File "panel_test.py", line 19, in update_display
> my_plot(self.figure)
>   File "panel_test.py", line 10, in my_plot
> nx.draw_networkx(G, ax=axes)
>   File
> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/networkx/drawing/nx_pylab.py",
> line 269, in draw_networkx
> node_collection=draw_networkx_nodes(G, pos, **kwds)
>   File
> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/networkx/drawing/nx_pylab.py",
> line 392, in draw_networkx_nodes
> pylab.sci(node_collection)
>   File
> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/pyplot.py",
> line 226, in sci
> gca()._sci(im)
>   File
> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py",
> line 1374, in _sci
> "Argument must be an image, collection, or ContourSet in this Axes")
> ValueError: Argument must be an image, collection, or ContourSet in this
> Axes
>
>
> Thanks guys!
>
> Josh
> On Jul 11, 2012, at 1:18 PM, Benjamin Root wrote:
>
>
>
> On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler wrote:
>
>> Hi all,
>>
>> I am currently trying to have two panels each with their own figure
>> instance so they can have separate plots.
>>
>> I can successfully update a plot if there is only one panel. As soon as I
>> add a second panel, I get the following error when I try to update (replot)
>> a plot (Showing last message only):
>>
>> File
>> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py",
>> line 1374, in _sci
>> "Argument must be an image, collection, or ContourSet in this Axes")
>> ValueError: Argument must be an image, collection, or ContourSet in this
>> Axes
>>
>> I looked online first and one site suggested it was because I was using
>> matplotlib.Figure instead of pylab.Figure. I switched and the problem still
>> occurs. I was curious to see if this problem had to do with how I set up my
>> program, not with matplotlib, so I wrote a little test program. The exact
>> same problem occurs. I have attached the test program. To see that it does
>> work with just one panel comment out lines 39, 41, and 49. When put back
>> in, I get the above error message.
>>
>> Any suggestions as to how to fix this?
>>
>> Thanks!
>>
>> Josh
>>
>>
> Josh,
>
> Can you please post the entire traceback?  My suspicion for what is
> happening is that both figures are sharing the same canvas, but I am not
> exactly sure.  Anyway, when you perform a plot on one panel, you are
> calling "clear()" for that figure, which may be having side-effects for the
> other figure since it is attached to the same Wx object.
>
> Actually, looking over your code again, I see a few things that may or may
> not be part of the problem, but should be addressed, nevertheless.  First,
> you are calling FigureCanvas and assigning it to self.canvas.  This canvas
> is different from the canvas that the figure will actually use, so I am not
> sure if this is being done correctly.  Second, your call to "plt.close()"
> assumes that the figure you want to close is the currently active figure.
> What you want to call is "plt.close(self.figure)" in order to make sure it
> closes the figure you intend to close.
>
> Ben Root
>
>
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to compile under windows?

2012-07-11 Thread Daniel Hyams
I looked around in the docs a bit but didn't find anything...is there a
guide / set of recommended practices when trying to build matplotlib from
source on Windows?

-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Two panels (wxPython) containing separate figures

2012-07-12 Thread Daniel Hyams
You can either send them the link to this discussion, or just the little
snippet concerning gcf() above; just taking care of that would be an
improvement.

On Thu, Jul 12, 2012 at 10:17 AM, Joshua Koehler wrote:

> That did the trick. I tried going through the source code but it just got
> too messy. How do I let the networkx developers know about this?
> On Jul 11, 2012, at 1:18 PM, Benjamin Root wrote:
>
>
>
> On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler wrote:
>
>> Hi all,
>>
>> I am currently trying to have two panels each with their own figure
>> instance so they can have separate plots.
>>
>> I can successfully update a plot if there is only one panel. As soon as I
>> add a second panel, I get the following error when I try to update (replot)
>> a plot (Showing last message only):
>>
>> File
>> "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py",
>> line 1374, in _sci
>> "Argument must be an image, collection, or ContourSet in this Axes")
>> ValueError: Argument must be an image, collection, or ContourSet in this
>> Axes
>>
>> I looked online first and one site suggested it was because I was using
>> matplotlib.Figure instead of pylab.Figure. I switched and the problem still
>> occurs. I was curious to see if this problem had to do with how I set up my
>> program, not with matplotlib, so I wrote a little test program. The exact
>> same problem occurs. I have attached the test program. To see that it does
>> work with just one panel comment out lines 39, 41, and 49. When put back
>> in, I get the above error message.
>>
>> Any suggestions as to how to fix this?
>>
>> Thanks!
>>
>> Josh
>>
>>
> Josh,
>
> Can you please post the entire traceback?  My suspicion for what is
> happening is that both figures are sharing the same canvas, but I am not
> exactly sure.  Anyway, when you perform a plot on one panel, you are
> calling "clear()" for that figure, which may be having side-effects for the
> other figure since it is attached to the same Wx object.
>
> Actually, looking over your code again, I see a few things that may or may
> not be part of the problem, but should be addressed, nevertheless.  First,
> you are calling FigureCanvas and assigning it to self.canvas.  This canvas
> is different from the canvas that the figure will actually use, so I am not
> sure if this is being done correctly.  Second, your call to "plt.close()"
> assumes that the figure you want to close is the currently active figure.
> What you want to call is "plt.close(self.figure)" in order to make sure it
> closes the figure you intend to close.
>
> Ben Root
>
>
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] FancyBBox set_width

2012-08-19 Thread Daniel Hyams
I had to deal with this lately, and there is no current way to do what you
want without patching the MPL source.  I have a patch for it, but it does
not behave well enough to use in the general senseand you have target
the correct code, the lack of flexibility lies in the Text._draw_bbox
function.

I'm afraid that you will have to create the FancyBboxPatch (the arrow)
directly, size it and place it, and then create some text (with no box) to
go inside.

On Sun, Aug 19, 2012 at 2:41 AM, Peter Combs  wrote:

> Hi all,
> I'm trying to have a Text object with a fancy box, as in this example:
> http://matplotlib.sourceforge.net/mpl_examples/pylab_examples/fancybox_demo2.py.
>   However, the key difference is that I want to have the box (in my case,
> I'm interested in an RArrow) be a specified width (in units of the plot),
> rather than just fitting it to the text I've given (crude ascii art
> below).  The following seems not to work:
>
>
> ax = gca()
> txtobj = ax.text(0, -.1 * yrange, 'text',
>  bbox=dict(boxstyle='rarrow'))
> txtobj.get_bbox_patch().set_
> width(SIZE_IM_INTERESTED_IN)
> draw_if_interactive()
>
> It seems like draw()ing the text object will reset the size of the BBox...
> Any idea how to fix this? At the moment, I'm experimenting with continually
> drawing, polling the get_width() method, and when it's too small, adding in
> spaces around the text field, but that seems both not to work reliably, and
> be an incredibly boneheaded way to go about it.
>
> I'm using matplotlib v. 1.1.0 if that makes a difference.
>
>
> --\
> |text  >
> --/
> not
> --\
> | text >
> --/
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] FancyBBox set_width

2012-08-19 Thread Daniel Hyams
Another, very hacky but quick way to do this, is to put spaces around your
text until the arrow is the size you desire:

" your text   "

and if you want the arrow to expand upward and downward, put in return
characters (I told you it was crude ;))

On Sun, Aug 19, 2012 at 2:41 AM, Peter Combs  wrote:

> Hi all,
> I'm trying to have a Text object with a fancy box, as in this example:
> http://matplotlib.sourceforge.net/mpl_examples/pylab_examples/fancybox_demo2.py.
>   However, the key difference is that I want to have the box (in my case,
> I'm interested in an RArrow) be a specified width (in units of the plot),
> rather than just fitting it to the text I've given (crude ascii art
> below).  The following seems not to work:
>
>
> ax = gca()
> txtobj = ax.text(0, -.1 * yrange, 'text',
>  bbox=dict(boxstyle='rarrow'))
> txtobj.get_bbox_patch().set_
> width(SIZE_IM_INTERESTED_IN)
> draw_if_interactive()
>
> It seems like draw()ing the text object will reset the size of the BBox...
> Any idea how to fix this? At the moment, I'm experimenting with continually
> drawing, polling the get_width() method, and when it's too small, adding in
> spaces around the text field, but that seems both not to work reliably, and
> be an incredibly boneheaded way to go about it.
>
> I'm using matplotlib v. 1.1.0 if that makes a difference.
>
>
> --\
> |text  >
> --/
> not
> --\
> | text >
> --/
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem with contains() on an arrow

2012-08-20 Thread Daniel Hyams
I've run into a strange problem with contains() on an arrow; there is a
large area to the left of the arrow that insists that it is contained
within the arrow.  Small runnable sample attached.

I've looked at the path for the arrow, and it looks fine to me.  I even
went so far as to hack a STOP onto the end of the path, but that resulted
in the same behavior.

Can anyone else confirm this behavior?  matplotlib 1.1.1 is what I'm using.
 Seen on both Windows, Linux, and OSX.

-- 
Daniel Hyams
dhy...@gmail.com


arrow_contains_test.py
Description: Binary data
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with contains() on an arrow

2012-08-20 Thread Daniel Hyams
Hmm, I just found out that if I change path.Path.contains_point to use
"point_on_path" instead of "point_in_path", the containment tests work
properly.  I'm not that familiar with the path code...is the difference
that one is testing for polygonal insideness, and one is testing for
literally being on the "stroke"?  If so, do we have to make sure that the
proper one is called if there are no polygons involved in the path?

On Mon, Aug 20, 2012 at 9:28 PM, Daniel Hyams  wrote:

> I've run into a strange problem with contains() on an arrow; there is a
> large area to the left of the arrow that insists that it is contained
> within the arrow.  Small runnable sample attached.
>
> I've looked at the path for the arrow, and it looks fine to me.  I even
> went so far as to hack a STOP onto the end of the path, but that resulted
> in the same behavior.
>
> Can anyone else confirm this behavior?  matplotlib 1.1.1 is what I'm
> using.  Seen on both Windows, Linux, and OSX.
>
> --
> Daniel Hyams
> dhy...@gmail.com
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] sharex with different tick labels

2012-09-13 Thread Daniel Welling
Greetings, all.

I have an issue: I have several axes stacked in a column with a common time
vector on each x-axis.  Each plot is a contour, so overplotting is not an
option.  In a perfect world, I want the following:
1) The subplots are tightly spaced such that with ax.grid() activated, the
grid lines appear continuous.  This makes comparing simultaneous
characteristics between subplots very easy.
2) The subplots are linked via the "sharex" keyword so I can move them all
in unison.
3) Only the bottommost subplot has x tick labels; on other plots, the long
time-formatted labels stick out of the left and right of the plots.

Items 2 and 3 are contradictory: if I turn off tick labels (e.g.
ax.set_xticklabels('')) on one axes, the others turn off as well, including
the bottom axes.  That is bad.
Does anyone know of a good workaround for this?

Thanks for your help.

-dw
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with contains() on an arrow

2012-09-15 Thread Daniel Hyams
Bump for this topic; I'd still love to know what the right thing is to do
here.

On Mon, Aug 20, 2012 at 10:08 PM, Daniel Hyams  wrote:

> Hmm, I just found out that if I change path.Path.contains_point to use
> "point_on_path" instead of "point_in_path", the containment tests work
> properly.  I'm not that familiar with the path code...is the difference
> that one is testing for polygonal insideness, and one is testing for
> literally being on the "stroke"?  If so, do we have to make sure that the
> proper one is called if there are no polygons involved in the path?
>
>
> On Mon, Aug 20, 2012 at 9:28 PM, Daniel Hyams  wrote:
>
>> I've run into a strange problem with contains() on an arrow; there is a
>> large area to the left of the arrow that insists that it is contained
>> within the arrow.  Small runnable sample attached.
>>
>> I've looked at the path for the arrow, and it looks fine to me.  I even
>> went so far as to hack a STOP onto the end of the path, but that resulted
>> in the same behavior.
>>
>> Can anyone else confirm this behavior?  matplotlib 1.1.1 is what I'm
>> using.  Seen on both Windows, Linux, and OSX.
>>
>> --
>> Daniel Hyams
>> dhy...@gmail.com
>>
>
>
>
> --
> Daniel Hyams
> dhy...@gmail.com
>



-- 
Daniel Hyams
dhy...@gmail.com
--
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] uniqueness of polar coordinates (meaningfulness of r<0)

2012-12-17 Thread Daniel Hyams
Maybe I'm just not seeing it; I don't see how the definition on wikipedia,
your definition, and matplotlib behavior differ.

import numpy as np
import matplotlib
matplotlib.use('WxAgg')
import matplotlib.pyplot as plt

t = np.linspace(0.0,2.0*np.pi, 50)
r = np.linspace(0.0,2.0*np.pi, 50)

plt.polar(t,r,color='blue')
plt.polar(t,-r,color='red')
plt.polar(-t,r,color='green')
plt.polar(-t,-r,color='yellow')
plt.show()

Comparing blue and red, you can see how mpl handles a negative r; each
point is 'opposite' just as described.
Comparing blue and green, you can see how mpl handles a negative angle.
 green curve increases in as you go clockwise, which is correct.




On Mon, Dec 17, 2012 at 6:54 PM, Andre' Walker-Loud wrote:

> >
> http://en.wikipedia.org/wiki/Polar_coordinate_system#Uniqueness_of_polar_coordinates
>
> quoting from the site
>
> '''
> Where a unique representation is needed for any point, it is usual to
> limit r to non-negative numbers (r ≥ 0) and θ to the interval [0, 360°) or
> (−180°, 180°] (in radians, [0, 2π) or (−π, π]).[12] One must also choose a
> unique azimuth for the pole, e.g., θ = 0.
> '''
>
> Of course I don't have anything close to a scientific study of the
> following statement, but I suspect in practice (ie as polar coordinates are
> used in practice by working scientists), they expect to find values of "r"
> consistent with the above definition of unique - however, still wanting
> theta to not be bounded.
>
> Taking another quote form the site
>
> '''
> Also, a negative radial coordinate is best interpreted as the
> corresponding positive distance measured in the opposite direction.
> '''
>
> How does one define opposite in polar coordinates?  The natural definition
> for "opposite" direction is presumably theta --> theta + pi, as that
> definition would correspond to the same notion of "opposite" in Cartesian
> coordinates (take whatever direction you were drawing a line, and go in "-"
> that direction.  If we agree that this is the sensible definition of
> opposite, then pyplot.polar is not representing this definition of opposite.
>
> Attached are two plots.  The first uses
>
> ''' as matplotlib is - neg_r.png '''
> import numpy as np
> import matplotlib.pyplot as plt
>
> t = np.linspace(-np.pi, np.pi, 60)
> r = t
> plt.polar(t,r)
>
> The second produces a curve which I say represents the natural definition
> of "opposite".  Note, the tangents of the curves are also opposite as well
>
> ''' as matplotlib "should be" - neg_r_opposite.png '''
> import numpy as np
> import matplotlib.pyplot as plt
>
> t = np.linspace(0, np.pi, 30)
> r = t
> plt.polar(t,r)
> t_opp = np.linspace(np.pi,2*np.pi,30)
> r_opp = t_opp - np.pi
> plt.polar(t_opp,r_opp)
>
>
> I have three points to make with these plots:
> 1) my definition of opposite makes more sense than the default behavior of
> matplotlib
> 2) other people may have different ideas about what is best
> 3) matplotlib should at least raise a NOISY warning about what it is doing.
>
>
> Andre
>
>
>
>
>
>
>
>
>
>
> --
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] finding the bounding box of an arbitrary artist

2013-01-01 Thread Daniel Hyams
No, I didn't... I believe that in this specific case, I just manually drew
a decently sized box around the axis spine and implemented my own contains
method to match.

It would be nice for every artist to be consistent in this area though.
Maybe a MEP is in order to make every artist have a consistent interface as
defined by the base class?
 On Dec 30, 2012 1:00 AM, "Michael McNeil Forbes" <
michael.forbes+pyt...@gmail.com> wrote:

> On 7 Oct 2011, at 4:56 PM, Daniel Hyams wrote:
>
>  I'm wanting to highlight the artist under the cursor with a transparent
>> Rectangle patch.  To do this, I have very, roughly, in a mouse motion
>> handler,
>>
>> under = self.figure.hitlist(ev)
>> if under:
>>artist = under[0]
>>bbox = artist.get_window_extent()
>>highlight = matplotlib.patches.Rectangle(**
>> xy=bbox.min,width=bbox.width,**height=bbox.height,alpha=0.2,**
>> color='yellow')
>># further code to blit the last captured graph region with highlight
>> drawn on top
>>
>> The main problem is that all artists don't implement get_window_extent();
>> a Text object does, and a legend object does, but the Axis objects do not.
>>
>> So is there a general way to get the bounding box of an artist?
>>
>
> Did you ever find a way to get the bounding box of an artist?  I could use
> this too.
>
> Michael.
>
--
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] mathtext and fonts under Windows 8

2013-01-12 Thread Daniel Hyams
For what it's worth, I checked this out on my Windows 8 machine and
didn't have any problems.

On Thu, Jan 10, 2013 at 8:35 AM, Michael Droettboom  wrote:
> Since this is specific to Windows 8, I wonder if the Arial font has been
> updated in that version.  If it's a newer OTF font, rather than a TTF font,
> it's possible matplotlib can't read it correctly.
>
> You can see what font file is on each platform by starting up a Python
> prompt and doing:
>
>   >>> from matplotlib import font_manager
>   >>> font_manager.findfont("Arial")
>
> It should display the path to the font.  From that, you should be able to
> get the Arial file on each of your platforms and see if they are different.
> To get more details, you could open them up in the open source "fontforge"
> tool.  Sorry I can't do this myself, as I don't have access to anything past
> XP.
>
> If the fonts turn out to be different, as a workaround, you could try
> backing up and then replacing the Arial font on your Windows 8 machine with
> the one on your Windows 7 machine.
>
> Cheers,
> Mike
>
> On 01/09/2013 11:59 PM, Paul Hobson wrote:
>
> Sounds like it might have something to do with your Latex installation (if
> any) or the barebones Latex-rendering done by MPL alone. Namely, they simply
> don't have the characters for mathematical Arial available.
>
> Not too sure though. Hopefully someone more knowledgeable responds.
> -paul
>
>
> On Tue, Jan 8, 2013 at 9:31 PM, CAB  wrote:
>>
>> Hi, All,
>>
>> I am encountering a thorny problem when trying to run matplotlib under
>> Windows 8.  If I label an axis using a command like
>>
>> ax.set_ylabel(r'time (s)', name='Arial'),
>>
>> all is well.  But if  try to add mathtext to that, as in
>>
>> ax.set_ylabel(r'time ($s$)', name='Arial'),
>>
>> mathtext.py throws an error (a very long stream) ending in "RuntimeError:
>> Face has no glyph names".  If I remove the "name='Arial'" above and let the
>> program default to Bitstream Vera Sans, the mathtext works.
>>
>> This problem does not occur under Windows 7 or XP; only under two
>> different Windows 8 installations.  Any ideas what's going on?
>>
>> Chad
>>
>>
>> --
>> Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
>> and much more. Keep your Java skills current with LearnJavaNow -
>> 200+ hours of step-by-step video tutorials by Java experts.
>> SALE $49.99 this month only -- learn more at:
>> http://p.sf.net/sfu/learnmore_122612
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
>
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
>
>
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] mathtext and fonts under Windows 8

2013-01-17 Thread Daniel Hyams
>
>
> But the thing that bothers me about this error is that it only occurs if I
> try to mix mathtext and non-matplotlib font.  So matplotlib finds Arial
> just fine.  And it finds the mathtext font fine.  Only the mixture is
> fatal.  It's as if the parser loses track of the Arial font, or it looks
> for a mathtext glyph in Arial.  Very strange that it occurs only in Windows
> 8.
>
> Regarding Paul's response, I don't have LaTeX on the W8 computer, and my
> impression is that mathtext doesn't look for "mathematical Arial", instead
> there are some packaged fonts that it uses for this purpose, like Computer
> Modern and STIX.
>

I can confirm this behavior on my Windows 8 box as well.  Everything is
fine until you try to mix mathtext and Arial (and a bunch of other fonts
too, but Arial is the easiest one to test).I also do not have latex on
the Windows 8 computer.  Identical code works on a Windows 7 machine.
--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] full grid for 2nd y-axis wit twinx() ?

2013-06-13 Thread Daniel Mader
Hi,

I need a twinx() plot with horizontal and vertical grid lines for the
second axis, just like the usual grid for the first axis. I don't need or
want to specify the ticks manually, though!

My example code just produces horizontal lines:

import pylab


datax = pylab.arange(50)

data1 = pylab.sin(datax)*1.5

data2 = datax**2


pylab.close('all')


fig = pylab.figure()

ax1 = fig.add_subplot(111)

ax2 = ax1.twinx()


ax1.plot(datax, data1, 'x')

ax2.plot(datax, data2, '--')


#ax1.grid()

ax2.grid()


fig.show()


Thanks in advance!
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] full grid for 2nd y-axis wit twinx() ?

2013-06-13 Thread Daniel Mader
Hi Paul,

I've modified your suggestion a little, since I don't want a grid for the
primary axis at all -- unfortunately to no avail, i.e. no grid line at all:

import numpy

import matplotlib

matplotlib.use('agg')

import matplotlib.pyplot as plt


datax = numpy.arange(50)

data1 = numpy.sin(datax)*1.5

data2 = datax**2


plt.close('all')


fig = plt.figure()

ax1 = fig.add_subplot(111)

ax2 = ax1.twinx()


ax1.plot(datax, data1, 'x')

ax2.plot(datax, data2, '--')


#for ax in [ax1, ax2]:

# ax.xaxis.grid(True, which='both') # `which` can be 'minor', 'major', or
'both'

# ax.yaxis.grid(True, which='both')


ax2.xaxis.grid(True, which='both')

ax2.yaxis.grid(True, which='both')


fig.savefig('twinxgrid.png')

#fig.show()
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] full grid for 2nd y-axis wit twinx() ?

2013-06-14 Thread Daniel Mader
Hi Paul,

thanks for your efforts, I've figured it out by myself by now, with you
pieces of code:

ax1.grid()
ax2.grid()
ax1.xaxis.grid(False)

does the trick :)
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] full grid for 2nd y-axis wit twinx() ?

2013-06-14 Thread Daniel Mader
ah, should have been:
ax1.grid()
ax2.grid()
ax1.yaxis.grid(False)
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Mac backend problems for nearly all backends.

2010-05-26 Thread Daniel Welling
A quick update on Mac backends:
1) Two others in my office use macports, python 2.6, mpl 99.1, and
snowleopard.  They have none of the issues I have with the GUI stuff.  Most
notably, their MacOSX backends work properly in both X11 and native Mac
terminal.
2) I cannot follow up on WxPython or Qt4 for my PPC machine; installs failed
for both.  I'm working on it some more but have limited time to play around.
3) A recompile of python through fink using updated gcc/g++ (from 4.0 to
4.2) had no effect.

While I don't want to drag this thread on forever, I feel like some of this
info is useful for the Mac/MPL community.  I would love to hear from anyone
else who has the OSX backend problem; it seems to be isolated to Fink.

It seems like the bottom line is that depending on your install, some
experimentation is required to determine which GUI backends work well or at
all.

On Tue, May 25, 2010 at 10:51 PM, Daniel Welling wrote:

> 2) In which case, it's not a framework install.  Fink puts everything into
> /sw/; there's nothing to do with pyton in /Library/Frameworks.
> Thanks for the clarification; I'm tempted to get Python from source and try
> this...
>
> -dw
>
> On Tue, May 25, 2010 at 10:41 PM, Michiel de Hoon wrote:
>
>>
>> > 1)The problem does manifest in the same manner through the normal python
>> prompt.
>>
>> OK that is good to know.
>>
>>
>> > 2) I'm not sure what is meant by a "framework install."  Everything
>> (except MPL 99.1.1)
>> > was installed through fink.
>>
>> This is important. Check where python is installed. If 'which python'
>> shows /Library/Frameworks/Python.framework/Versions/2.6/bin/python or
>> something similar, you have a framework version. If on the other hand it
>> shows /usr/bin/python, /usr/local/bin/python, or something similar, you
>> don't have a framework version. I don't know what fink installs by default.
>> If you don't have Python installed as a framework, some backends (including
>> the MacOSX backend) will not interact properly with the window manager. This
>> is a Mac peculiarity. If you build Python from source, you can specify to
>> install a framework version by passing the --enable-framework option to the
>> configure script.
>>
>>
>> > 6) Although I use x11 and not the native Mac terminal, I'm not sure if
>> this requires me to > install different packages for the gui stuff.  Could
>> you guys expand on this, please?
>>
>> Some backends go make use of X11 (e.g., the gtkcairo backend), others do
>> not (e.g., the MacOSX backend). The MacOSX backend should work with both the
>> native Mac terminal and with an X11 terminal.
>>
>> --Michiel.
>>
>>
>
--

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


[Matplotlib-users] displaying multiple images in series

2010-06-14 Thread Daniel Jones
Hi matplotlib users,

I'm trying to write a script to loop through a bunch of tiff files,
display each image, and choose to accept or reject each image.
Something like:

for f in files:
   im = imread(f)
   imshow(im)
   # Accept keyboard input to accept or reject image
   # Close the image


The problem is that I can't figure out how to show multiple images in
series. I can't use matplotlib.pyplot.show() because that can only be
used once at the very end of a script, and I don't want to show all
the images at once. matplotlib.pyplot.draw() seemed like a promising
candidate, but it only seems to work if I've already used show() once
in the script. It seems like there should be a simple way to do this,
but I can't quite seem to find it.

Thanks,
Daniel

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] displaying multiple images in series

2010-06-20 Thread Daniel Jones
Hi Matthias,
Thanks for the script! Now I would like to try to understand why it
works :) . In both of the scripts you sent me, plt.draw() is called
inside the loop to display each image file, and plt.show() is called
outside the loop at the end of the script. I guess what I find
confusing is, how is it that the images are displayed on screen,
inside the loop, *before* plt.show() is called? I would have expected
only the very last image inside the loop to be displayed, using this
program structure. So apparently there is something here I do not
understand...

-Daniel

On Tue, Jun 15, 2010 at 3:26 AM, Matthias Michler
 wrote:
> On Monday, June 14, 2010 10:32:48 pm Daniel Jones wrote:
>> Hi matplotlib users,
>>
>> I'm trying to write a script to loop through a bunch of tiff files,
>> display each image, and choose to accept or reject each image.
>> Something like:
>>
>> for f in files:
>>    im = imread(f)
>>    imshow(im)
>>    # Accept keyboard input to accept or reject image
>>    # Close the image
>>
>>
>> The problem is that I can't figure out how to show multiple images in
>> series. I can't use matplotlib.pyplot.show() because that can only be
>> used once at the very end of a script, and I don't want to show all
>> the images at once. matplotlib.pyplot.draw() seemed like a promising
>> candidate, but it only seems to work if I've already used show() once
>> in the script. It seems like there should be a simple way to do this,
>> but I can't quite seem to find it.
>>
>> Thanks,
>> Daniel
>
> Hi Daniel,
>
> in the attached script I propose two solutions for your problem (just
> uncomment first region and comment second to test the first proposal). The 
> first
> uses plt.waitforbuttonpress and the second key-press-events.
>
> Kind regards,
> Matthias
>
> --
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pcolorfast and log axes.

2010-07-14 Thread Daniel Welling
Greetings.

I've recently found that when I replace pcolor with pcolorfast, the image
will not scale correctly when placed on an axis with a logarithmic scale.
 It will remain linear, thus not matching the axis range whatsoever.  The
pcolor plot will still fit nicely in the axis object, but the ticks and
labels clearly do not match the data.  I've tried several things, from
changing the axis from linear to log before and after using pcolorfast, etc,
but pcolorfast artist objects do not seem to respond to this.  Again, pcolor
acts as one would expect.

Complicating this is that I have made two changes at once: upgrading from
MPL 99 to 1.0 and switching from pcolor to pcolorfast.  As such, I do not
know if this a new or old issue (or if it is an issue at- perhaps this
behavior is on purpose.)

If anyone could shed some light on this, that would be great.  Pcolorfast is
preferable over pcolor because of the complexity of my plots and the speed
up gained by using pcolorfast.

Thanks!
-dw
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Axes3D and tricontours.

2010-07-19 Thread Daniel Welling
Greetings, MPL Users.

I have been experimenting with Axes3D with the hopes that I could create
some 3d lines and then project some contours on different planes in the 3D
axes object, much like the contour3d_demo3.py example (but with lines
instead of the 3d wireframe.)  The catch, however, is creating the contour
objects using tricontour instead of a regular contour.  Being that I
typically use irregular grids for my research, the triangulate module has
been a tremendous feature, but it doesn't seem to work with Axes3D objects.

For example, this quick script:
import matplotlib.pyplot as plt
#import matplotlib.tri as tri
import numpy as np
from numpy.random import uniform, seed
from mpl_toolkits.mplot3d import Axes3D

seed(0)
npts = 200
ngridx = 100
ngridy = 200
x = uniform(-2,2,npts)
y = uniform(-2,2,npts)
z = x*np.exp(-x**2-y**2)

# tricontour.
fig = plt.figure()
ax = Axes3D(fig)
ax.tricontour(x, y, z, 15, zdir=x, offset=-2)

plt.show()

creates a huge traceback, listed below.
Is it possible to combine tricontour with Axes3D?  It would appear that they
are just incompatible, but perhaps there is a way to force it to work?
Thanks for your help.

tricont3d.py in ()
 20 ax.tricontour(x, y, z, 15, zdir=x, offset=-2)
 21
---> 22 plt.show()
 23
 24

python2.6/site-packages/matplotlib/backends/backend_qt4.pyc in show()
 69 figManager =  Gcf.get_active()
 70 if figManager != None:
---> 71 figManager.canvas.draw()
 72
 73 if _create_qApp.qAppCreatedHere:

python2.6/site-packages/matplotlib/backends/backend_qt4agg.pyc in draw(self)
128 if DEBUG: print "FigureCanvasQtAgg.draw", self
129 self.replot = True
--> 130 FigureCanvasAgg.draw(self)
131 self.update()
132
site-packages/matplotlib/backends/backend_agg.pyc in draw(self)
392
393 self.renderer = self.get_renderer()
--> 394 self.figure.draw(self.renderer)
395
396 def get_renderer(self):

python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist,
renderer, *args, **kwargs)
 53 def draw_wrapper(artist, renderer, *args, **kwargs):
 54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
 56 after(artist, renderer)
 57

python2.6/site-packages/matplotlib/figure.pyc in draw(self, renderer)
796 dsu.sort(key=itemgetter(0))
797 for zorder, func, args in dsu:
--> 798 func(*args)
799
800 renderer.close_group('figure')

python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.pyc in draw(self,
renderer)
152 # Calculate projection of collections and zorder them

153 zlist = [(col.do_3d_projection(renderer), col) \
--> 154  for col in self.collections]
155 zlist.sort()
156 zlist.reverse()

AttributeError: 'LineCollection' object has no attribute 'do_3d_projection'
WARNING: Failure executing file: 
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Mapping fonts properly

2010-08-22 Thread Daniel Hyams
I am searching for advice on how to handle selecting a specific font, and
using that in a matplotlib figure.  As a background, the font will be picked
through the wx.FontDialog (common font dialog) provided by wxPython.  So,
what I will have is the font face (Arial, Times New Roman, Algerian, etc.
etc.), the weight, the style (italic, normal) and the point size.  All I
want to do is create a matplotlib font that matches this, and use it in the
plot.  My first try was this:

import matplotlib.pyplot as plt
import matplotlib.font_manager as fm

# this does not work.  The title font is wrong.
the_font = 'Century Schoolbook'
fp = fm.FontProperties()
fp.set_name(the_font)
fp.set_size(24)
plt.title('The Title that should be in Century
Schoolbook',fontproperties=fp)
print fp
plt.show()

But that didn't work.  I know that "Century Schoolbook" is not really a font
family, but in the docs it says that you can list a font there.

The following does work, if I manually set the TrueType file explicitly:

fp = fm.FontProperties()
fp.set_file('c:\\Windows\Fonts\CENSCBK.TTF')
fp.set_size(24)
print fp
plt.title('The Title that is in Century Schoolbook',fontproperties=fp)
plt.show()

So I guess the question ishow does one accomplish this, portably?  I
don't quite understand the ins and outs of fonts.


p.s.
I did take a stab at creating a mapping between the font names / weights /
styles like this:

all_fontfiles = fm.win32InstalledFonts()
allfonts = fm.createFontList(all_fontfiles)
fontdict = {}
for f in allfonts:
fontdict[(f.name,f.style,f.weight)] = f.fname

And I think I can get this to work, because this maps me to a TTF file for
any name, style, and weight combination.  But this seemed awfully hacky, and
I don't know what problems I'll run into on other platforms (obviously, I
would have get all_fontfiles above differently on each platform).  If this
is the only way to do it, I guess that's OK, but I thought that surely there
was a better way.


Thanks,

-- 
Daniel Hyams
dhy...@gmail.com
--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Mapping fonts properly

2010-08-23 Thread Daniel Hyams
Thanks for your response Michael!

Deleting the fontList.cache indeed solved the problem.  The first sample
that I gave below now works fine under both Windows and Linux; whew...I
would have never known about that cache file without your help.

So, should the fontList.cache file be deleted each time my app runs, in case
new fonts have been installed since the last invocation?  How do we keep
that cache up to date?



On Mon, Aug 23, 2010 at 10:12 AM, Michael Droettboom wrote:

>  On 08/22/2010 10:00 PM, Daniel Hyams wrote:
>
> I am searching for advice on how to handle selecting a specific font, and
> using that in a matplotlib figure.  As a background, the font will be picked
> through the wx.FontDialog (common font dialog) provided by wxPython.  So,
> what I will have is the font face (Arial, Times New Roman, Algerian, etc.
> etc.), the weight, the style (italic, normal) and the point size.  All I
> want to do is create a matplotlib font that matches this, and use it in the
> plot.  My first try was this:
>
> import matplotlib.pyplot as plt
> import matplotlib.font_manager as fm
>
> # this does not work.  The title font is wrong.
> the_font = 'Century Schoolbook'
> fp = fm.FontProperties()
> fp.set_name(the_font)
> fp.set_size(24)
> plt.title('The Title that should be in Century
> Schoolbook',fontproperties=fp)
> print fp
> plt.show()
>
> But that didn't work.  I know that "Century Schoolbook" is not really a
> font family, but in the docs it says that you can list a font there.
>
> On my RHEL5 system (at least), the full name of that font is "Century
> Schoolbook L".  You do, of course, have to match the font name exactly.
>
> You may want to experiment with using wx.Font.GetFaceName vs.
> wx.Font.GetFamilyString from the font chooser dialog and see if either
> returns the correct result.
>
> You can see the list of fonts that matplotlib found on your system by
> doing:
>
> from matplotlib import font_manager
> font_manager.fontManager.ttflist
>
> (This is not a public API -- but may help with debugging the issue here).
>
> Is the font you are hoping to match with in that list?
>
> Another thing you may want to try is deleting matplotlib's font cache, in
> case this font was installed after matplotlib was first run on your system.
> It is is in a file "fontList.cache" and lives in the user data area (can't
> remember the exact location of this on Windows off hand).
>
>
> The following does work, if I manually set the TrueType file explicitly:
>
> fp = fm.FontProperties()
> fp.set_file('c:\\Windows\Fonts\CENSCBK.TTF')
> fp.set_size(24)
> print fp
> plt.title('The Title that is in Century Schoolbook',fontproperties=fp)
> plt.show()
>
> So I guess the question ishow does one accomplish this, portably?  I
> don't quite understand the ins and outs of fonts.
>
>
> p.s.
> I did take a stab at creating a mapping between the font names / weights /
> styles like this:
>
> all_fontfiles = fm.win32InstalledFonts()
> allfonts = fm.createFontList(all_fontfiles)
> fontdict = {}
> for f in allfonts:
> fontdict[(f.name,f.style,f.weight)] = f.fname
>
> And I think I can get this to work, because this maps me to a TTF file for
> any name, style, and weight combination.  But this seemed awfully hacky, and
> I don't know what problems I'll run into on other platforms (obviously, I
> would have get all_fontfiles above differently on each platform).  If this
> is the only way to do it, I guess that's OK, but I thought that surely there
> was a better way.
>
> That's basically a stricter way of doing what the matplotlib code already
> does.  The matplotlib lookup is actually smarter because it handles
> approximate "nearest neighbor" matches.  I think the problem is more likely
> one of the above (an inexact name match or an out-of-date font cache).
>
> Mike
>
> --
> Michael Droettboom
> Science Software Branch
> Space Telescope Science Institute
> Baltimore, Maryland, USA
>
>
>
> --
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>


-- 
Daniel Hyams
dhy...@gmail.com
--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] legend and bbox_to_anchor, and draggable()

2010-09-24 Thread Daniel Hyams
I was playing around with draggable legends, and some strange things started
happening (exception down in the depths of beckend_agg.py, accompanied by a
long stack trace).  To make a long story short, I can reproduce this in the
draggable_legend.py example on the matplotlib website.  All you have to do
is change line 7 from

l = ax.legend()

to

l = ax.legend(bbox_to_anchor=(.1,.1))

Fire this up, and move the legend box with your mouse.  It works.  Move
again, exception raised.

I'm sure that I'm not understanding the proper usage of bbox_to_anchor.  I
thought that i could use it to place the legend initially, and then let the
user drag the legend around if the placement wasn't satisfactory.

-- 
Daniel Hyams
dhy...@gmail.com
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] bug: axes.hitlist() ?

2010-10-05 Thread Daniel Hyams
I've run across a strange problem and perhaps I'm misusing something.  I was
trying to set up picking so that I can interact with plotted objects, and I
get alot of error spew that looks like this:

while checking 
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 241, in
hitlist
hascursor,info = self.contains(event)
  File "C:\Python26\lib\site-packages\matplotlib\lines.py", line 286, in
contains
path, affine = self._transformed_path.get_transformed_path_and_affine()
AttributeError: 'NoneType' object has no attribute
'get_transformed_path_and_affine'

This can be reproduced by the following code, even though there is no
picking involved...just mouse motion.  Is there possibly a workaround for
this, or am I doing something wrong?

import sys
from pylab import *

ax = subplot(111)
ax.plot([0,1,2,3])

def on_move(event):
if event.inaxes:
lst = ax.hitlist(event)
print lst

binding_id = connect('motion_notify_event', on_move)


show()


-- 
Daniel Hyams
dhy...@gmail.com
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] basemap toolkit: project graphics file given in lon-lat

2010-10-15 Thread Daniel Fulger
Dear all,

I would like to project a graphics file of some colour coded geo data  
that is already given in lat-lon with corners
specified in lat-lon onto a map. The projection of the result should  
be flexible. In the end the resulting
plot shows a section of the earth, either from a satallite  
perspective (ortho) or some convenient projection.

All examples I found seem to be doing different things or special  
cases that I have trouble to generalize or modify.
These examples transform the data from some (often unpecified) system  
to a coordinate system that
suites the chosen projection.
But the fact that the geo data file is given in lat-lon with corners  
must simplify everything and should make the chosen
projection arbitrary. The resolution of the data file must also be  
arbitrary and should not appear in the code.
I do not see why the final projection should require beforehand a  
change of the geo-data coordinate
system *by hand* i.e. typing in the transform formulas and extracting  
pixel sizes.
I would have thought that to avoid this is the whole point of using  
map toolkits.

I imagine a function that takes the parameters
- datafile, alternatively an array with a colour value or RGB for  
each lon-lat coordinate
- its lon-lat corners,
- a basemap map-object i want the data projected onto
- and the projection specifier (possibly with desired corners if  
different from the maps corners)
   that determines how i want to see the the resulting piece of the  
globe.


Could someone explain to me (a python newbie)  what the sequence of  
steps/functions would have to be or which
predefined methods are doing this.

Regards
Daniel



--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3d plot without marker edge

2010-10-15 Thread Daniel Hyams
Since you are talking about markers, I assume that you made the plot with
the scatter() function.

The scatter() function creates the appropriate collection of patches
(polygon, circle, etc.)  depending on what the marker style was passed to
it.  As such, the normal 'marker*' properties do not work, as there is just
a collection patches that is being drawn.  So the properties that you are
looking for in your situation are here:

http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.PatchCollection

I believe that the property you are looking for is 'edgewidth'.  E.g. (and I
think this is right, but not where I can test right now):

the_artist.set_edgewidth(0.0)

Which I believe will work, or you may have to do

the_artist.set_edgewidths((0.0,))

But anyway, hopefully this is enough to set you on your way.


On Fri, Oct 15, 2010 at 4:10 AM, Robert Fenwick <
robert.fenw...@irbbarcelona.org> wrote:

>
> Hi,
>
> I have a 3d plot that I am trying to plot and I can not get rid of the
> marker edge. an example would help
>
> Bryn
>
>
>
>
>
>
>
> --
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3d plot without marker edge

2010-10-15 Thread Daniel Hyams
Ugh, if I could only undo an email send 20 seconds after I hit go ;)

If setting 'edgewidths' to 0 doesn't work, try setting 'edgecolors' to
'None' as per JDH's suggestion above, which is the same suggestion as mine
except for the "marker" part of the property is removed.

On Fri, Oct 15, 2010 at 10:32 AM, Daniel Hyams  wrote:

> Since you are talking about markers, I assume that you made the plot with
> the scatter() function.
>
> The scatter() function creates the appropriate collection of patches
> (polygon, circle, etc.)  depending on what the marker style was passed to
> it.  As such, the normal 'marker*' properties do not work, as there is just
> a collection patches that is being drawn.  So the properties that you are
> looking for in your situation are here:
>
>
> http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.PatchCollection
>
> I believe that the property you are looking for is 'edgewidth'.  E.g. (and
> I think this is right, but not where I can test right now):
>
> the_artist.set_edgewidth(0.0)
>
> Which I believe will work, or you may have to do
>
> the_artist.set_edgewidths((0.0,))
>
> But anyway, hopefully this is enough to set you on your way.
>
>
> On Fri, Oct 15, 2010 at 4:10 AM, Robert Fenwick <
> robert.fenw...@irbbarcelona.org> wrote:
>
>>
>> Hi,
>>
>> I have a 3d plot that I am trying to plot and I can not get rid of the
>> marker edge. an example would help
>>
>> Bryn
>>
>>
>>
>>
>>
>>
>>
>> --
>> Download new Adobe(R) Flash(R) Builder(TM) 4
>> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> Flex(R) Builder(TM)) enable the development of rich applications that run
>> across multiple browsers and platforms. Download your free trials today!
>> http://p.sf.net/sfu/adobe-dev2dev
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
>
> --
> Daniel Hyams
> dhy...@gmail.com
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Marker types in 3d plots

2010-10-15 Thread Daniel Hyams
Right, there is only a subset of marker styles supported in the scatter
function, both 2D and 3D.  This is because, behind the scenes, it's drawing
all of the symbols as patches.  See

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



On Fri, Oct 15, 2010 at 10:43 AM, R. Bryn Fenwick <
robert.fenw...@irbbarcelona.org> wrote:

>
> Marker types in 3d plots
>
> Hi,
>
> A few problems with marker types in 3D plots. I can use "o" and "^"
> and "+". However I can not use "." or "," it seems a bit odd to me
> however I get the below error. It should be possible to repeat this
> with the following input
>
> Traceback (most recent call last):
>   File "test.py", line 16, in 
> ax.scatter(xs, ys, zs, c=c, marker=m)
>   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1019, in
> scatter
> patches = Axes.scatter(self, xs, ys, *args, **kwargs)
>   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/site-packages/matplotlib/axes.py", line 5719, in scatter
> raise ValueError('Unknown marker symbol to scatter')
> ValueError: Unknown marker symbol to scatter
>
> 
> import numpy as np
> from mpl_toolkits.mplot3d import axes3d
> import matplotlib.pyplot as plt
>
> def randrange(n, vmin, vmax):
> return (vmax-vmin)*np.random.rand(n) + vmin
>
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> n = 100
> #for c, m, zl, zh in [('r', '+', -50, -25), ('b', '^', -30, -5)]:
> for c, m, zl, zh in [('r', '+', -50, -25), ('b', '.', -30, -5)]:
> xs = randrange(n, 23, 32)
> ys = randrange(n, 0, 100)
> zs = randrange(n, zl, zh)
> ax.scatter(xs, ys, zs, c=c, marker=m)
>
> ax.set_xlabel('X Label')
> ax.set_ylabel('Y Label')
> ax.set_zlabel('Z Label')
>
> plt.show()
>
>
>
> --
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-devel] Release schedule for version 1.0.1?

2010-10-25 Thread Daniel Hyams
Oops, yes!  The spirit is willing but the (my) brain is weak.

On Mon, Oct 25, 2010 at 5:13 PM, John Hunter  wrote:

> On Mon, Oct 25, 2010 at 4:09 PM, Daniel Hyams  wrote:
> > Right, I was referring specifically to MATPLOTLIBDIR ;)
> >
> > I was just pleased as punch to find it in the source code, documented or
> no
> > :)
>
>
> I'm guessing you mean MATPLOTLIBDATA ?  And you're right, it isn't
> documented (yet)...
>
> JDH
>



-- 
Daniel Hyams
dhy...@gmail.com
--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to get the legend size?

2010-10-29 Thread Daniel Hyams
Going a little crosseyed here...how might I get the size of the legend in
axes coordinates?  Or any coordinates?

-- 
Daniel Hyams
dhy...@gmail.com
--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to get legend size, try #2.

2010-10-29 Thread Daniel Hyams
I realized after sending that off that I need to provide more
contextsorry about that.

What I'm trying to do can be boiled down to the following:  I'm trying to
place a legend precisely, using the top left corner of legend as the
"sticky" point.  In other words, if I want to place the legend here:

+-+---+
| |   |
| |  legend   |

|   The plot...   |---+

| |
| |
| |
| |
| |
| |
+-+

I would have thought that I would set bbox_to_anchor = (0,0,1,1), and loc =
(1,1).  I found out quickly, though, that this places the legend like this:
  +---+
  |   |
  |  legend   |
+-+---+
| |
| |

|   The plot...   |

| |
| |
| |
| |
| |
| |
+-+

Which makes perfect sense from matplotlib's perspective.  So all I need to
do is figure out how tall the legend is, and subtract that off the y
coordinate before passing 'loc' off to matplotlib's legend.  I just can't
seem to figure out how to get that number.  I tried
self.ax.get_legend().get_frame().get_height(), but that just returns 1 all
the time.

Ascii art is fun! :)



-- 
Daniel Hyams
dhy...@gmail.com
--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to get legend size, try #2.

2010-10-30 Thread Daniel Hyams
With Paul's suggestions (greatly appreciated!) I almost have this
thing workingthere is still something strange going on in that
when I call get_window_extent() on the legend, I always get ones and
zeros no matter where it is...but that's for another post on another
day.

This one, I hope, is an easy one.  The last thing I need to do is
position the legend precisely.  For example, the code below doesn't
quite position the top left corner of the legend at the top left
corner in the plot:

import pylab,matplotlib

pylab.plot([1,2,3,4,5],[1,2,3,4,5],"bo",label="data")
ax  = pylab.gca()

pylab.legend(bbox_to_anchor=(0,1),loc=2)

# draw an X to make sure of coordinates.
ax.lines.append(matplotlib.lines.Line2D((0,1),(0,1),transform=ax.transAxes,color='blue'))
ax.lines.append(matplotlib.lines.Line2D((0,1),(1,0),transform=ax.transAxes,color='red'))

pylab.show()


It's close, but not there.so the question becomes, how do I place
a legend exactly at the coordinates that I want?



On Sat, Oct 30, 2010 at 1:16 AM, Paul Ivanov  wrote:
> Daniel Hyams, on 2010-10-29 23:48,  wrote:
>> Thanks Paul!  Your suggestion got me part of the way, but I've run
>> into another problem...I'm using draggable legends, I'm also wanting
>> to fetch the current position of the legend after a drag.  The
>> draggable legend always updates 'loc', and not 'bbox_to_anchor', so
>> I'm afraid that I'm stuck manipulating 'loc' for my purposes and not
>> the bbox_to_anchor property.
>>
>> Is there really no way to get the dimensions of a legend? It has to be
>> there somewhere, otherwise the legend wouldn't know where to draw
>> itself ;)
>
> Hi Daniel,
>
> I'm replying to the list, so that someone correct me if I'm
> wrong, or point out a better way of doing this.
>
> there totally is a way to get the dimensions of a legend.
>
> You can get it in pixel coordinates using
>
>  l = plt.legend()
>  bbox = l.get_window_extent()
>  bbox.width,bbox.height
>
> or in axes coordinates using something like
>
>  bbox2 = bbox.transformed(l.axes.transAxes.inverted())
>  bbox2.width,bbox2.height
>
> The bboxes have other handy attributes like p0,p1,x0,x1,y0,y1
> etc, as well as methods like bbox.padded(), etc.
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists,  off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>
> --
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Daniel Hyams
dhy...@gmail.com

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] my duel with the legend is over. I won. :)

2010-10-30 Thread Daniel Hyams
lol.

Finally found the magic parameter.  borderaxespad.

import pylab,matplotlib

pylab.plot([1,2,3,4,5],[1,2,3,4,5],"bo",label="data")
ax  = pylab.gca()

pylab.legend(bbox_to_anchor=(0,1),loc=2,borderaxespad=0)

# draw an X to make sure of coordinates.
ax.lines.append(matplotlib.lines.Line2D((0,1),(0,1),transform=ax.transAxes,color='blue'))
ax.lines.append(matplotlib.lines.Line2D((0,1),(1,0),transform=ax.transAxes,color='red'))

pylab.show()

I don't know how I missed that parameter after reading the docs 100 times. :(

Sorry for bothering the list with something so trivial.  I had a major
"can't see the forest through the trees" moment.


-- 
Daniel Hyams
dhy...@gmail.com

--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Two sets of ticks on a colorbar?

2010-11-12 Thread Daniel Welling
Greetings.

I am making some contour plots and in my field for this particular value,
there are two widely used units.  As such, it is very useful to have both
units listed on the colorbar.  To clarify: the colorbar's normal ticks would
be facing to the right and labeled with Unit Type 1, which was the units
that the data were in when they were plotted.  Unit Type 2 is simply a
factor of X different than unit type two.  It would be nice if I could add a
second set of ticks to the color bar using a different locator and have them
face left.  Is this possible? Is there another way to display two values for
each tick such that the colorbar shows both units?

Thanks.
-dw
--
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Two sets of ticks on a single colorbar?

2010-11-15 Thread Daniel Welling
Greetings.

I am making some contour plots and in my field for this particular value,
there are two widely used units.  As such, it is very useful to have both
units listed on the colorbar.  To clarify: the colorbar's normal ticks would
be facing to the right and labeled with Unit Type 1, which was the units
that the data were in when they were plotted.  Unit Type 2 is simply a
factor of X different than unit type two.  It would be nice if I could add a
second set of ticks to the color bar using a different locator and have them
face left.  Is this possible? Is there another way to display two values for
each tick such that the colorbar shows both units?

Thanks.
-dw
--
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] callbacks / custom nav toolbar

2010-11-21 Thread Daniel Hyams
I was trying to implement my own nav toolbar, and everything works great
except an exception that gets thrown intermittently when in zoom
rubberbanding operation, from this bit of code in CallbackRegistry
(cbook.py):


def process(self, s, *args, **kwargs):
"""
process signal *s*.  All of the functions registered to receive
callbacks on *s* will be called with *\*args* and *\*\*kwargs*
"""
self._check_signal(s)
for cid, proxy in self.callbacks[s].items():
# Clean out dead references
if proxy.inst is not None and proxy.inst() is None:
del self.callbacks[s][cid]  #<--- the cid key
doesn't exist.
else:
proxy(*args, **kwargs)


is it OK to eat and ignore this exception?  Everything seems to work just
fine.

I know that this is probably one of those weak-reference callbacks getting
dropped, but I don't make any connections to 'button_release_event'
 anywhere in my code, and that's what 's' is in the above code when the
dictionary key is missing. In other areas of my code where I am making
connections, I did make sure that I'm saving a reference to them myself.




-- 
Daniel Hyams
dhy...@gmail.com
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] small bugfix in font_manager.py

2010-11-24 Thread Daniel Hyams
MPL 1.0.0, OSX

If USE_FONTCONFIG is turned on, the function
FontProperties.get_size_in_points will sometimes fail, because it is wanting
to use "fontManager", which is still 'None' if USE_FONTCONFIG is on.  I'm
not sure if it's the proper way to fix it, but here is a small patch that
works (meaning that at least the code doesn't die; I can't vouch for much
else):

ORIGINAL:

def get_size_in_points(self):
if self._size is not None:
try:
return float(self._size)
except ValueError:
pass
default_size = fontManager.get_default_size()
return default_size * font_scalings.get(self._size)

NEW:

def get_size_in_points(self):
if self._size is not None:
try:
return float(self._size)
except ValueError:
pass
if fontManager:
   default_size = fontManager.get_default_size()
else:
   default_size = rcParams['font.size']
return default_size * font_scalings.get(self._size)


-- 
Daniel Hyams
dhy...@gmail.com
--
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] small bugfix in font_manager.py

2010-11-29 Thread Daniel Hyams
Just out of curiosity, is anyone using the fontconfig way of mapping fonts?
 I turned it on one day, but the immediate problem was that no mathtext
worked any more; so I turned it back off.  Any mathtext in titles, labels,
etc. just rendered as a much of seemingly random letters.

And I'll tack a second question in here as well; the reason that I was
playing with fontconfig is that the font cache takes a really long time to
build in certain circumstances (I'm having trouble identifying exactly
when)so I guess the question is...has anyone else seen this?  For
example, on my (2008 vintage) mac mini, a complete rebuild of the font cache
takes around 3 seconds, which is fine.  On a macbook pro (tested on three
different machines so far), it takes 30 seconds.  This makes no sense at all
to me, so any insights welcome :)

I initially thought that perhaps the other users had a ton more fonts than
I, but I don't think so...if I remember correctly, their font cache on the
macbook pro ended up being smaller than mine on the mini.


On Mon, Nov 29, 2010 at 10:10 AM, Michael Droettboom wrote:

> The fontManager is essentially a replacement for what fontconfig
> provides on many platforms -- so it's intended that the fontManager
> doesn't exist if the user opts to use fontconfig.  However, that's still
> an "experimental" option because it hasn't been formally tested on many
> platforms, and, as you point out, there may still be code paths that
> aren't coded correctly for that option.
>
> Mike
>
> On 11/25/2010 10:34 AM, Benjamin Root wrote:
> > On Wednesday, November 24, 2010, Daniel Hyams  wrote:
> >> MPL 1.0.0, OSX
> >> If USE_FONTCONFIG is turned on, the function
> FontProperties.get_size_in_points will sometimes fail, because it is wanting
> to use "fontManager", which is still 'None' if USE_FONTCONFIG is on.  I'm
> not sure if it's the proper way to fix it, but here is a small patch that
> works (meaning that at least the code doesn't die; I can't vouch for much
> else):
> >>
> >>
> >> ORIGINAL:
> >>  def get_size_in_points(self):if self._size is not None:
>try:return float(self._size)
> >>
> >>  except ValueError:passdefault_size
> = fontManager.get_default_size()return default_size *
> font_scalings.get(self._size)
> >>
> >>
> >> NEW:
> >>  def get_size_in_points(self):if self._size is not None:
>try:return float(self._size)except
> ValueError:
> >>
> >>  passif fontManager:default_size =
> fontManager.get_default_size()else:   default_size =
> rcParams['font.size']
> >>
> >>  return default_size * font_scalings.get(self._size)
> >>
> >> --
> >> Daniel Hyams
> >> dhy...@gmail.com
> >>
> >>
> > I personally think that this is reasonable, as it guarantees a size
> > value to come from somewhere.  However, I am concerned about
> > fontManager being None. If it isn't a bug for it to be None at this
> > point, then I have to wonder where-else in the code needs a check for
> > None?  If it is a bug, then what should it be when USE_FONTCONFIG is
> > true?
> >
> > Good catch Daniel.
> >
> > Ben Root
> >
> >
> --
> > Increase Visibility of Your 3D Game App&  Earn a Chance To Win $500!
> > Tap into the largest installed PC base&  get more eyes on your game by
> > optimizing for Intel(R) Graphics Technology. Get started today with the
> > Intel(R) Software Partner Program. Five $500 cash prizes are up for
> grabs.
> > http://p.sf.net/sfu/intelisp-dev2dev
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sour

  1   2   3   >