[Matplotlib-users] Another Gnuplot style question

2009-04-29 Thread Joseph Smidt
Okay, I am another gnuplot user trying to migrate over to matplotlib.
I like what I see, but there are a couple things that are very easy to
do in Gnuplot that I can't figure out how to do with matplotlib.

I have a file with 3 columns of data called data.txt that looks like:

0.  1. 1.0
0.0634  1.0655  1.1353
0.1269  1.1353  1.28899916094
0.1903  1.2097  1.46345358199
0.2538  1.2889 1.6615188369
0.3173  1.3734 1.88639043926
...

I can plot this data, 2 versus 1 and 3 versus 1, very easily on the
same plot, with a legend, with log y values, and only for the xrange
between 2 and 3 with gnuplot:

set log y
set xrange[2:3]
plot 'data.txt' u 1:2 w l t 'apples', 'data.txt' u 1:3 w l t 'oranges'

Now, how do I do that same thing with matplotlob?  Ie:

1. Both graphs overlayed on the same plot.
2. Semilogy. (log y values),
3. Only ploy for x in the range 2-3.
4. Legend for the two graphs on same plot.

I have spent time looking through the documentation but I can't find
anyway to do this is any straightforward way.  plotfile() looks
promising, but I can't seem to make it do the above.  Thanks in
advance.

 Joseph Smidt

-- 

Joseph Smidt josephsm...@gmail.com

Physics and Astronomy
4129 Frederick Reines Hall
Irvine, CA 92697-4575
Office: 949-824-3269

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Another Gnuplot style question

2009-04-29 Thread Sandro Tosi
On Wed, Apr 29, 2009 at 08:20, Joseph Smidt josephsm...@gmail.com wrote:
 1. Both graphs overlayed on the same plot.
 2. Semilogy. (log y values),
 3. Only ploy for x in the range 2-3.
 4. Legend for the two graphs on same plot.

a simple example:

In [2]: import numpy as np

In [3]: import matplotlib.pyplot as plt

In [16]: data = np.random.rand(10,3)

In [17]: data
Out[17]:
array([[ 0.00669083,  0.4421283 ,  0.46697081],
   [ 0.18093819,  0.11669917,  0.70887601],
   [ 0.11659791,  0.96514955,  0.07389404],
   [ 0.95616662,  0.30350482,  0.10036185],
   [ 0.14197553,  0.10560376,  0.2964961 ],
   [ 0.74705585,  0.21806946,  0.37095176],
   [ 0.1551145 ,  0.76093425,  0.878701  ],
   [ 0.44315466,  0.3625146 ,  0.06750168],
   [ 0.96109656,  0.88401174,  0.59215722],
   [ 0.46190334,  0.39079641,  0.5958516 ]])

In [28]: plt.semilogy(data[:,0], data[:,1], label='first dataset')
Out[28]: [matplotlib.lines.Line2D object at 0xa7698ac]

In [29]: plt.semilogy(data[:,0], data[:,2], label='second dataset')
Out[29]: [matplotlib.lines.Line2D object at 0xa8049ac]

In [30]: plt.xlim([0.2, 0.8]) # limit x to 0.2..0.8
Out[30]: (0.20001, 0.80004)

In [31]: plt.legend()
Out[31]: matplotlib.legend.Legend object at 0xa80d04c

In [32]: plt.show()

 I have spent time looking through the documentation but I can't find
 anyway to do this is any straightforward way.  plotfile() looks
 promising, but I can't seem to make it do the above.  Thanks in
 advance.

to load data from file you can try

matplotlib.mlab.csv2rec

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

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Another Gnuplot style question

2009-04-29 Thread Eric Firing
Joseph Smidt wrote:
 Okay, I am another gnuplot user trying to migrate over to matplotlib.
 I like what I see, but there are a couple things that are very easy to
 do in Gnuplot that I can't figure out how to do with matplotlib.
 
 I have a file with 3 columns of data called data.txt that looks like:
 
 0.  1. 1.0
 0.0634  1.0655  1.1353
 0.1269  1.1353  1.28899916094
 0.1903  1.2097  1.46345358199
 0.2538  1.2889 1.6615188369
 0.3173  1.3734 1.88639043926
 ...
 
 I can plot this data, 2 versus 1 and 3 versus 1, very easily on the
 same plot, with a legend, with log y values, and only for the xrange
 between 2 and 3 with gnuplot:
 
 set log y
 set xrange[2:3]
 plot 'data.txt' u 1:2 w l t 'apples', 'data.txt' u 1:3 w l t 'oranges'
 
 Now, how do I do that same thing with matplotlob?  Ie:
 
 1. Both graphs overlayed on the same plot.
 2. Semilogy. (log y values),
 3. Only ploy for x in the range 2-3.
 4. Legend for the two graphs on same plot.

Something like this:

import numpy as np
import matplotlib.pyplot as plt

x, apples, oranges = np.loadtxt('data.txt', unpack=True)
plt.semilogy(x, apples, label='apples')
plt.semilogy(x, oranges, label='oranges')
plt.legend()
plt.gca().set_xlim(2, 3)
plt.show()

There are many possible variations and styles.  The basic point is to 
separate reading in the data from plotting it.  Plotfile won't do what 
you want because it is designed to make separate subplots instead of 
plotting multiple lines on a single axes.  Maybe doing the latter would 
be at least as useful, if not more, and could be enabled as an option 
with one more kwarg.

Eric

 
 I have spent time looking through the documentation but I can't find
 anyway to do this is any straightforward way.  plotfile() looks
 promising, but I can't seem to make it do the above.  Thanks in
 advance.
 
  Joseph Smidt
 


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib documentation

2009-04-29 Thread Gökhan SEVER
Hello,

About two months ago I was asking how to implement the following
functionality for matplotlib documentation. Well today I figured it
out :) I was busy with some other school work not been thinking for
over twom months :P

Is there a way to get functions separately listed under each bookmark
listing in the pdf file? For example if I go IV Matplotlib API section
from the bookmarks menu and click the matplotlib.pyplot seb-menu I
would like to see the function names listed. In addition to module
indexing (where keywords highlighted back to original names) this
would be a nice feature to add the pdf documentation.

Enough said, here is what I did. (Thanks to Georg Brandl of Sphinx)
(As of now the latest svn checkout 0.98.6svn_rev__7068 although
__revision__ says: 6887, and with Sphinx 0.6.1)

I have modified the pyplot_api.rst as follows:


.. automodule:: matplotlib.pyplot
   :undoc-members:
   :show-inheritance:


acorr
=
.. autofunction:: acorr

annotate

.. autofunction:: annotate

and other 121 manual entries. (The new PDF file is 12 pages more than
original file.) While I was adding the function names I thought of
myself that these could be done via a little program. I mean before
Sphinx visit --in this case pyplot.py function names might read into a
list and following this an appropriate rst file could be created (and
this is also apply for the other api documentation as well). Or
another way, these could be added to Sphinx as a feature, that is to
say read function names and read docstrings, create figures etc.. and
make a subsection for each item via a special syntax.

The first method eliminates having a pre-written pyplot_api.rst file
since this could be created via a short python script.

I would like discuss these point before start working on other api
functions and classes. Also need some explanation about them, since
pyplot is composed of functions but some other api's are mixed with
classes and functions.

Please, contact me of the list so I can send the modified pyploy_rst.api.

Gökhan

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Another Gnuplot style question

2009-04-29 Thread Joseph Smidt
Thanks everyone, this is exactly what I wanted.


-- 

Joseph Smidt josephsm...@gmail.com

Physics and Astronomy
4129 Frederick Reines Hall
Irvine, CA 92697-4575
Office: 949-824-3269

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Another Gnuplot style question

2009-04-29 Thread Matthias Michler
Hello Eric, Hello list,

a year ago I also encountered the problem of one file - one figure of the 
plotfile function. I would like to propose an addional functionality of using 
one figure and several files in plotfile, because sometimes I don't want to 
read data myself. I added a patch including the following changes:
- added a new keywordargument to plotfile 'use_cf': If use_cf isTrue plotfile 
uses fig = gcf() instead of fig = figure() to suppress opening of a new 
figure and therewith allowing to use the user preferred figure
- added a further new keyword argument 'names' to set x/ylabels in the case 
there are no names in the csv-file

Furthermore I attached the modified plotfile_demo.py 
(examples/pylab_examples/plotfile_demo.py) and some new data 
(examples/data/data_x_x2_x3.csv).

Could this be useful?

Thanks in advance for any comments.

best regards
Matthias

On Wednesday 29 April 2009 09:20:17 Eric Firing wrote:
 Joseph Smidt wrote:
  Okay, I am another gnuplot user trying to migrate over to matplotlib.
  I like what I see, but there are a couple things that are very easy to
  do in Gnuplot that I can't figure out how to do with matplotlib.
 
  I have a file with 3 columns of data called data.txt that looks like:
 
  0.  1. 1.0
  0.0634  1.0655  1.1353
  0.1269  1.1353  1.28899916094
  0.1903  1.2097  1.46345358199
  0.2538  1.2889 1.6615188369
  0.3173  1.3734 1.88639043926
  ...
 
  I can plot this data, 2 versus 1 and 3 versus 1, very easily on the
  same plot, with a legend, with log y values, and only for the xrange
  between 2 and 3 with gnuplot:
 
  set log y
  set xrange[2:3]
  plot 'data.txt' u 1:2 w l t 'apples', 'data.txt' u 1:3 w l t 'oranges'
 
  Now, how do I do that same thing with matplotlob?  Ie:
 
  1. Both graphs overlayed on the same plot.
  2. Semilogy. (log y values),
  3. Only ploy for x in the range 2-3.
  4. Legend for the two graphs on same plot.

 Something like this:

 import numpy as np
 import matplotlib.pyplot as plt

 x, apples, oranges = np.loadtxt('data.txt', unpack=True)
 plt.semilogy(x, apples, label='apples')
 plt.semilogy(x, oranges, label='oranges')
 plt.legend()
 plt.gca().set_xlim(2, 3)
 plt.show()

 There are many possible variations and styles.  The basic point is to
 separate reading in the data from plotting it.  Plotfile won't do what
 you want because it is designed to make separate subplots instead of
 plotting multiple lines on a single axes.  Maybe doing the latter would
 be at least as useful, if not more, and could be enabled as an option
 with one more kwarg.

 Eric

  I have spent time looking through the documentation but I can't find
  anyway to do this is any straightforward way.  plotfile() looks
  promising, but I can't seem to make it do the above.  Thanks in
  advance.
 
   Joseph Smidt

 ---
--- Register Now  Save for Velocity, the Web Performance  Operations
 Conference from O'Reilly Media. Velocity features a full day of
 expert-led, hands-on workshops and two days of sessions from industry
 leaders in dedicated Performance  Operations tracks. Use code vel09scf
 and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Index: lib/matplotlib/pyplot.py
===
--- lib/matplotlib/pyplot.py	(revision 7068)
+++ lib/matplotlib/pyplot.py	(working copy)
@@ -1447,8 +1447,8 @@
 draw_if_interactive()
 return ret
 
-def plotfile(fname, cols=(0,), plotfuncs=None,
- comments='#', skiprows=0, checkrows=5, delimiter=',',
+def plotfile(fname, cols=(0,), plotfuncs=None, use_cf=False,
+ comments='#', skiprows=0, checkrows=5, delimiter=',', names=None,
  **kwargs):
 
 Plot the data in *fname*
@@ -1473,9 +1473,12 @@
 vector as you use in the *plotfuncs* dictionary, eg., integer
 column numbers in both or column names in both.
 
-*comments*, *skiprows*, *checkrows*, and *delimiter* are all passed on to
-:func:`matplotlib.pylab.csv2rec` to load the data into a record array.
+*use_cf* : use current figure instead of a new figure for plotting
 
+*comments*, *skiprows*, *checkrows*, *delimiter*, and *names* are all
+passed on to :func:`matplotlib.pylab.csv2rec` to load the data into a
+record array. 
+
 kwargs are passed on to plotting functions.
 
 Example usage::
@@ -1484,17 +1487,21 @@
   plotfile(fname, (0,1,3))
 
   # plot using column names; specify an alternate plot type for volume
-  plotfile(fname, ('date', 'volume', 'adj_close'), plotfuncs={'volume': 'semilogy'})
+  plotfile(fname, ('date', 'volume', 'adj_close'),
+   

Re: [Matplotlib-users] Matplotlib documentation

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 2:55 AM, Gökhan SEVER gokhanse...@gmail.com wrote:


 I would like discuss these point before start working on other api
 functions and classes. Also need some explanation about them, since
 pyplot is composed of functions but some other api's are mixed with
 classes and functions.

 Please, contact me of the list so I can send the modified pyploy_rst.api.


Hey Gökhan -- thanks for working on this.  We are very happy to have
documentation contributions.  I don't feel strongly about how the pyplot rst
file is generated, whether by extending Sphinx, using a script, or simply
hand editing it.  I'm actually incline toward the latter, because it would
probably be nice to have some simple description in the section header, eg::

  acorr - autocorrelation plots
  =

as we do on the main page.  Part of the sphinx philosophy is that hand
edited documentation cannot be fully replaced by autogenerated
documentaiton, and this may be a reasonable place to do some hand editing.

If you go this route, update the pyplot module, the developer's guide and
the boilerplate.py script (it lives besides setup.py and is a script to
generate part of pyplot) so that when developers add a new function to
pyplot they know to update the api docs as well.

You may want to move further discussion over to the developers list.  Any
changes you want to make should be posted as an svn diff to the developers
list.  If you don't get immediate attention, also post it as a patch to the
sourceforge site, and reply to the developers list with a link to the patch
-- see

  http://matplotlib.sourceforge.net/faq/howto_faq.html#contributing-howto

Thanks!
JDH
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Interactive backends very (suprisingly?) slow for multiple subplots

2009-04-29 Thread keflavich

Since there don't seem to be any forthcoming answers, I have a somewhat
different question.  In the matplotlib FAQ, it states that using 'show()'
puts you in the GUI mainloop
(http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show).  However,
using plot commands on the ipython command line does not shut down the
command line generally.  I gathered from some googling that this is because
ipython starts up the matplotlib graphics in a different 'thread', but I
don't understand how this is done and most of what I've seen says it is bad.

So, my question now: How can I exit the GUI mainloop without closing the
graphics windows?

Thanks,
Adam
-- 
View this message in context: 
http://www.nabble.com/Interactive-backends-very-%28suprisingly-%29-slow-for-multiple-subplots-tp23261074p23295883.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Interactive backends very (suprisingly?) slow for multiple subplots

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 9:07 AM, keflavich keflav...@gmail.com wrote:


 Since there don't seem to be any forthcoming answers, I have a somewhat
 different question.  In the matplotlib FAQ, it states that using 'show()'
 puts you in the GUI mainloop
 (http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show).  However,
 using plot commands on the ipython command line does not shut down the
 command line generally.  I gathered from some googling that this is because
 ipython starts up the matplotlib graphics in a different 'thread', but I
 don't understand how this is done and most of what I've seen says it is
 bad.


most GUI mainloops are blocking, so after you start them you cannot issue
more commands from an interactive shell.  Either you need to run a GUI
shell, or in the case of ipython run the GUI in a separate thread.  One
exception to this is tkinter (tkagg), which plays nicely with a standard
python shell.  I understand that recent versions of pygtk work also w/o
running the mainloop in a separate thread, but I haven't dug into the
details.



 So, my question now: How can I exit the GUI mainloop without closing the
 graphics windows?


This question doesn't really make sense to me.  Perhaps you can clearly
describe your use case (what you need to do) rather than the proposed
solutions.

JDH
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Interactive backends very (suprisingly?) slow for multiple subplots

2009-04-29 Thread Adam
On Wed, Apr 29, 2009 at 8:29 AM, John Hunter jdh2...@gmail.com wrote:


 On Wed, Apr 29, 2009 at 9:07 AM, keflavich keflav...@gmail.com wrote:

 Since there don't seem to be any forthcoming answers, I have a somewhat
 different question.  In the matplotlib FAQ, it states that using 'show()'
 puts you in the GUI mainloop
 (http://matplotlib.sourceforge.net/faq/howto_faq.html#use-show).  However,
 using plot commands on the ipython command line does not shut down the
 command line generally.  I gathered from some googling that this is
 because
 ipython starts up the matplotlib graphics in a different 'thread', but I
 don't understand how this is done and most of what I've seen says it is
 bad.

 most GUI mainloops are blocking, so after you start them you cannot issue
 more commands from an interactive shell.  Either you need to run a GUI
 shell, or in the case of ipython run the GUI in a separate thread.  One
 exception to this is tkinter (tkagg), which plays nicely with a standard
 python shell.  I understand that recent versions of pygtk work also w/o
 running the mainloop in a separate thread, but I haven't dug into the
 details.

OK, that's very helpful.

 So, my question now: How can I exit the GUI mainloop without closing the
 graphics windows?

 This question doesn't really make sense to me.  Perhaps you can clearly
 describe your use case (what you need to do) rather than the proposed
 solutions.

I would like to have access to the command line while simultaneously
being able to interact with and/or display plots.  I think this is
what ipython does by default when you pass it a thread keyword
(-pylab, -qt4thread, etc.).  I had some trouble getting ipython to
work correctly, but I think that had to do with passing the thread
keyword before/after some other keywords.

Part of my question that I hope makes sense: Is there a way to unblock
the command line without closing the plot window when using an
interactive backend?

Thanks, and sorry about the misunderstandings / lack of clarity,
Adam

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Histogram of 2D Data

2009-04-29 Thread marcog

Hi

I have a set of 2 dimensional data that I would like to form a histogram of.
Each data point is defined by an x and y variable. So essentially what I
would like to obtain is a row of histograms as produced by the plot.hist
function, stacking them next to one another in a single 3D plot. For
example, something like [1], but I don't need it to be interpolated.

[1] http://www.mathworks.com/matlabcentral/fx_files/14205/1/hist.jpg

Thanks!
Marco
-- 
View this message in context: 
http://www.nabble.com/Histogram-of-2D-Data-tp23296104p23296104.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Font size and savefig

2009-04-29 Thread John Hunter
On Tue, Apr 28, 2009 at 11:24 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:

 On Tue, Apr 28, 2009 at 11:09 PM, John Hunter jdh2...@gmail.com wrote:
  If you want the relative fontsizes in the figure window and saved figure
 to
  agree, pass the same dpi to the figure command and savefig command.

 John,
 I thought the font size (which is specified in points) is independent
 of dpi, i.e., font size in pixel actually scales with the dpi. I
 think it should be filed as a bug if the relative font size depends on
 the dpi.

 Anyhow, I just did a quick test and the (relative) font size does not
 seem to vary with dpi.


Hmm, I must have been confused.  In older versions of mpl, as you increased
the dpi the fonts looked larger in relation to the rest of the figure, and
that is what I was remembering.  I just ran a few tests and they do scale as
expected, so sorry for the noise
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Histogram of 2D Data

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 9:59 AM, marcog ma...@gallotta.co.za wrote:


 Hi

 I have a set of 2 dimensional data that I would like to form a histogram
 of.
 Each data point is defined by an x and y variable. So essentially what I
 would like to obtain is a row of histograms as produced by the plot.hist
 function, stacking them next to one another in a single 3D plot. For
 example, something like [1], but I don't need it to be interpolated.

 [1] http://www.mathworks.com/matlabcentral/fx_files/14205/1/hist.jpg




hexbin may be what you are looking for, which does a 2D colormapped
histogram, with an optional reduce function so you can specify the intensity
function over the bins


http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.hexbin
  http://matplotlib.sourceforge.net/examples/pylab_examples/hexbin_demo.html

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

JDH
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Interactive backends very (suprisingly?) slow for multiple subplots

2009-04-29 Thread Adam
On Wed, Apr 29, 2009 at 9:22 AM, John Hunter jdh2...@gmail.com wrote:


 On Wed, Apr 29, 2009 at 9:50 AM, Adam keflav...@gmail.com wrote:

 I would like to have access to the command line while simultaneously
 being able to interact with and/or display plots.  I think this is
 what ipython does by default when you pass it a thread keyword
 (-pylab, -qt4thread, etc.).  I had some trouble getting ipython to
 work correctly, but I think that had to do with passing the thread
 keyword before/after some other keywords.

 From your previous posts, I think you may have been be using ipython
 incorrectly, ie mixing ipython -pylab with the matplotlib use directive.
 Start with a canconical simple script, eg::

     import matplotlib.pyplot as plt

     plt.figure(1)
     plt.plot([1,2,3])

     plt.figure(2)
     plt.plot([4,5,6])

     plt.show()

 and set your matplotlibrc to backend to TkAgg.  Start ipython with::

    ipython -pylab

 and run your test script with::

   In [61]: run test.py

 If that works, close everything down and set your backend to QtAgg and try
 running it again in the same way and let us know what happens.  It should
 just work.  I'm suspecting in that as you were testing and trying a lot of
 things, you got yourself into a situation where multiple GUIs were competing
 for attention.

 Part of my question that I hope makes sense: Is there a way to unblock
 the command line without closing the plot window when using an
 interactive backend?

 Yes, that makes sense, and basically you need to either use TkAgg from a
 regular python shell, use ipython in pylab mode with any supported backend,
 or use a GUI shell.  ipython also has support for embedding in GUI shells.
 See also

   http://matplotlib.sourceforge.net/users/shell.html

 JDH

Thanks John.  I think you answered my questions completely now.

FWIW, I was not using matplotlib.use() with ipython, I was using it
when calling 'python test.py' on the command line.  My mistake with
ipython was using an import command before -pylab, i.e.:
ipython -i -c import pyfits,matplotlib -pylab

which does not work, whereas
ipython -pylab -i -c import pyfits,matplotlib

does.


Thanks for the help!

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fill_between and masked array

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 6:40 AM, Andres Luhamaa andres.luha...@ut.eewrote:

 Hello,
 I try to do fill_between two arrays, that have missing value (masked
 arrays). Following code shows behaviour that seems not correct. Images what
 I expect the result to be (by omitting the missing value) and what I get by
 plotting the whole arrays.

 import pylab
 import numpy as np
 edatmax=np.array([10,4,6,9,np.nan,9,10])
 edatmax=np.ma.masked_array(edatmax,np.isnan(edatmax))
 edatmin=np.array([8,4,5,1,np.nan,8,5])
 edatmin=np.ma.masked_array(edatmin,np.isnan(edatmin))
 xtelg=np.arange(edatmax.size)
 xtelg=np.ma.masked_array(xtelg,np.isnan(edatmin))
 pylab.plot(edatmax,gx)
 pylab.plot(edatmin,r+)
 # comment out to see better
 pylab.fill_between(xtelg,edatmax,edatmin,facecolor='green',alpha='0.3')
 # comment in to see better

 #pylab.fill_between(xtelg[:4],edatmax[:4],edatmin[:4],facecolor='green',alpha='0.3')

 #pylab.fill_between(xtelg[5:],edatmax[5:],edatmin[5:],facecolor='green',alpha='0.3')
 pylab.show()

 Version of matplotlib is current cvs.



fill_between does not currently support masked arrays, but I think we could
easily extend it to support the mask using the existing support for the
where kwarg.  For now, does this behave like you expect?

  valid = ~(edatmax.mask  edatmax.mask )
  pylab.fill_between(xtelg,edatmax,edatmin,facecolor='green',alpha='0.3',
where=valid)

JDH
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fill_between and masked array

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 10:54 AM, John Hunter jdh2...@gmail.com wrote:



 fill_between does not currently support masked arrays, but I think we could
 easily extend it to support the mask using the existing support for the
 where kwarg.  For now, does this behave like you expect?

   valid = ~(edatmax.mask  edatmax.mask )
   pylab.fill_between(xtelg,edatmax,edatmin,facecolor='green',alpha='0.3',
 where=valid)



Oops -- meant

 valid = ~(edatmin.mask  edatmax.mask )

JDH
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fill_between and masked array

2009-04-29 Thread Michael Droettboom
I don't believe fill_between directly supports missing values -- but it 
does have the where parameter for this purpose.

We could also be smarter about how where is generated when none is 
provided:

if where is None:
where = (~np.ma.getmaskarray(x)  ~np.ma.getmaskarray(y1) 
 ~np.ma.getmaskarray(y2))

...but I'd like more feedback from the author or users of fill_between 
before committing that change.  (That, and Eric Firing can probably find 
a much more efficient way to do the masked array manipulation... ;)

Mike

Andres Luhamaa wrote:
 Hello,
 I try to do fill_between two arrays, that have missing value (masked 
 arrays). Following code shows behaviour that seems not correct. Images 
 what I expect the result to be (by omitting the missing value) and 
 what I get by plotting the whole arrays.

 import pylab
 import numpy as np
 edatmax=np.array([10,4,6,9,np.nan,9,10])
 edatmax=np.ma.masked_array(edatmax,np.isnan(edatmax))
 edatmin=np.array([8,4,5,1,np.nan,8,5])
 edatmin=np.ma.masked_array(edatmin,np.isnan(edatmin))
 xtelg=np.arange(edatmax.size)
 xtelg=np.ma.masked_array(xtelg,np.isnan(edatmin))
 pylab.plot(edatmax,gx)
 pylab.plot(edatmin,r+)
 # comment out to see better
 pylab.fill_between(xtelg,edatmax,edatmin,facecolor='green',alpha='0.3')
 # comment in to see better
 #pylab.fill_between(xtelg[:4],edatmax[:4],edatmin[:4],facecolor='green',alpha='0.3')
  

 #pylab.fill_between(xtelg[5:],edatmax[5:],edatmin[5:],facecolor='green',alpha='0.3')
  

 pylab.show()

 Version of matplotlib is current cvs.

 Best regards,
 Andres

 


 

 

 --
 Register Now  Save for Velocity, the Web Performance  Operations 
 Conference from O'Reilly Media. Velocity features a full day of 
 expert-led, hands-on workshops and two days of sessions from industry 
 leaders in dedicated Performance  Operations tracks. Use code vel09scf 
 and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
 

 ___
 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


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fill_between and masked array

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 10:56 AM, Michael Droettboom md...@stsci.eduwrote:

 I don't believe fill_between directly supports missing values -- but it
 does have the where parameter for this purpose.

 We could also be smarter about how where is generated when none is
 provided:

if where is None:
where = (~np.ma.getmaskarray(x)  ~np.ma.getmaskarray(y1) 
 ~np.ma.getmaskarray(y2))

 ...but I'd like more feedback from the author or users of fill_between
 before committing that change.  (That, and Eric Firing can probably find
 a much more efficient way to do the masked array manipulation... ;)


I'm working on a patch for this nowbut I would also like Eric to take a
look when I am done since I am a masked array dummy

JDH
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fill_between and masked array

2009-04-29 Thread John Hunter
On Wed, Apr 29, 2009 at 11:03 AM, John Hunter jdh2...@gmail.com wrote:


 ...but I'd like more feedback from the author or users of fill_between
 before committing that change.  (That, and Eric Firing can probably find
 a much more efficient way to do the masked array manipulation... ;)


 I'm working on a patch for this nowbut I would also like Eric to take a
 look when I am done since I am a masked array dummy



Here's the diff I just committed::
Index: lib/matplotlib/axes.py
===
--- lib/matplotlib/axes.py  (revision 7069)
+++ lib/matplotlib/axes.py  (working copy)
@@ -5832,6 +5832,26 @@
 self._process_unit_info(xdata=x, ydata=y1, kwargs=kwargs)
 self._process_unit_info(ydata=y2)

+if where is None:
+where = np.ones(len(x), np.bool)
+else:
+where = np.asarray(where)
+
+maskedx = isinstance(x, np.ma.MaskedArray)
+maskedy1 = isinstance(y1, np.ma.MaskedArray)
+maskedy2 = isinstance(y2, np.ma.MaskedArray)
+
+if (maskedx or maskedy1 or maskedy2):
+if maskedx:
+where = where  (~x.mask)
+
+if maskedy1:
+where = where  (~y1.mask)
+
+if maskedy2:
+where = where  (~y2.mask)
+
+
 # Convert the arrays so we can work with them
 x = np.asarray(self.convert_xunits(x))
 y1 = np.asarray(self.convert_yunits(y1))
@@ -5843,10 +5863,7 @@
 if not cbook.iterable(y2):
 y2 = np.ones_like(x)*y2

-if where is None:
-where = np.ones(len(x), np.bool)

-where = np.asarray(where)
 assert( (len(x)==len(y1)) and (len(x)==len(y2)) and
len(x)==len(where))

 polys = []
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Integrating matplotlib into a GUI

2009-04-29 Thread Gary Pajer
On Sun, Apr 26, 2009 at 6:41 PM, Gökhan SEVER gokhanse...@gmail.com wrote:
 Hello,

 Thanks for the pointer Bryan. I also seen Gael's tutorial
 (http://gael-varoquaux.info/computers/traits_tutorial/index.html)

 To me, it seems much easier to use Traits, instead of learning WX or QT.

It is.  I had spent hours learning Tk, Wx, and Qt looking for a
practical gui solution ... but then I found Traits and I haven't
looked back.

 They are still confusing to me, and seemingly Traits is there to help me
 implement what I have had in my mind for a while.

 Gökhan


 On Sun, Apr 26, 2009 at 2:52 AM, Bryan Cole br...@cole.uklinux.net wrote:

  I know wxPython or PyQt seems way to go on this issue. But (there is
  always this but :) there is Chaco on the Enthought side and with
  nicely and simply integration with Traits and Traits UI.
 
  Are there anybody in the group that design a similar tool for their
  scientific data analysis needs? Could I get some insight into this?
  Any recommendations or pointers? Why's and why not's?

 You can integrate matplotlib plots into a Traits app. I wrote this
 recipe:

 http://www.scipy.org/Cookbook/EmbeddingInTraitsGUI

 Both Chaco and Matplotlib are excellent. If you want multiple
 interactive elements in your plot (drag-able labels, cursors etc.),
 Chaco is probably the best bet. However, for quick data-exploration
 apps, I find matplotlib quicker to set up (it's defaults just work,
 whereas Chaco takes a bit more preparation).

 Either way, Traits is indispensable.

 BC

 
  Thank you
 
  Gökhan
 
  --
  Crystal Reports #45; New Free Runtime and 30 Day Trial
  Check out the new simplified licensign option that enables unlimited
  royalty#45;free distribution of the report engine for externally facing
  server and web deployment.
  http://p.sf.net/sfu/businessobjects
  ___ Matplotlib-users mailing
  list Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users




 --
 Crystal Reports #45; New Free Runtime and 30 Day Trial
 Check out the new simplified licensign option that enables unlimited
 royalty#45;free distribution of the report engine for externally facing
 server and web deployment.
 http://p.sf.net/sfu/businessobjects
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


 --
 Crystal Reports #45; New Free Runtime and 30 Day Trial
 Check out the new simplified licensign option that enables unlimited
 royalty#45;free distribution of the report engine for externally facing
 server and web deployment.
 http://p.sf.net/sfu/businessobjects
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] last tick label not showing up

2009-04-29 Thread Matthias Michler
Hello Erik,

I can reproduce your problem (mpl 0.98.6svn) with the following little 
example:

import matplotlib.pyplot as plt
ax = plt.axes()
ax.set_xlim((0.0, .))
print ax.xaxis.get_majorticklocs()
plt.show()

where the last tick is out of the xlimits. Could this be the case for your 
example, too?
Nevertheless the question still would be: Is this a bug in the handling of 
xticks and their corresponding labels?

best regards Matthias

On Wednesday 29 April 2009 18:07:17 Erik Thompson wrote:
 How do I get the final 180 tick label to show up on my plots on the far
 right of my x axis (or top of the y axis).

 When I do: print ax.xaxis.get_majorticklocs() it returns:
 [   0.   20.   40.   60.   80.  100.  120.]

 and I have a label for each of those locations:
 ax.xaxis.set_ticklabels([-180, -120, -60, 0, 60, 120, 180])

 For some reason the final 180 tick label doesn't display.

 Thanks,
 Erik Thompson



--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] last tick label not showing up

2009-04-29 Thread Jae-Joon Lee
On Wed, Apr 29, 2009 at 12:21 PM, Matthias Michler
matthiasmich...@gmx.net wrote:
 where the last tick is out of the xlimits. Could this be the case for your
 example, too?
 Nevertheless the question still would be: Is this a bug in the handling of
 xticks and their corresponding labels?


get_majorticklocs (and similar methods) does not return the locations
of the ticks that will be plotted. It simply returns the tick values
generated by the locator instance. And among them, only those within
the axis limits will be drawn. My guess is that this was a design
decision, not a bug.

The following is a related post which includes some code snippets that
can be used to retrieve tick locations inside the axis limits.

http://www.nabble.com/eliminating-the-top-tick-on-an-axis-to19446256.html#a19446256

Regards,

-JJ

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] last tick label not showing up

2009-04-29 Thread Erik Thompson
Matthias,

Thanks for your help.  When I did ax.set_xlim((0.0, 120.0)) the 180 tick
showed up although ugly on some plots because there was missing data at the
180 degrees mark.

I then copied all the datapoints from the -180 degrees into new 180 degree
data points (they are the supposed to be the same) and everything works well
now.

Erik Thompson
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fill_between and masked array

2009-04-29 Thread Eric Firing
John Hunter wrote:
 
 
 On Wed, Apr 29, 2009 at 11:03 AM, John Hunter jdh2...@gmail.com 
 mailto:jdh2...@gmail.com wrote:
 
 
 ...but I'd like more feedback from the author or users of
 fill_between
 before committing that change.  (That, and Eric Firing can
 probably find
 a much more efficient way to do the masked array manipulation... ;)
 
 
 I'm working on a patch for this nowbut I would also like Eric to
 take a look when I am done since I am a masked array dummy
 

John,

The way you did it looked OK; but since I was looking at it, I went 
ahead and did some rearranging and condensation to try to make the whole 
thing (not just the mask handling) read better. I doubt there are any 
significant performance differences, but I did not test that. I also 
added a subplot to the fill_between.py demo to illustrate the mask 
handling.  Then I noticed a flaw in the demo plots, and added a note 
about it.  See revision 7071.

Eric

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pixel Position of X/Y Axis

2009-04-29 Thread Mark Larsen
It's been a while, please allow me to bump this...

 Sorry.  I use matplotlib to create PNGs graphics for display on a
 web-page.  I want to make the plots zoom-able.  I'll use javascript to
 capture the pixel positions of the user's selected zoom region on the
 PNG plot.  I'll then translate this into the coordinate system on the
 plot and redraw it with a new x, y range.  I'm having trouble
 translating the initial axises into the pixel positions (essentially
 where they are on the PNG image).

 For example, I use the following code to map point positions from the
 coordinate system to pixel positions.  I use an img map MAP to
 provide interaction with the actual lines.

 [CODE]

 lineObj = plt.plot(Xs,Ys,marker='o')[0]
 path, affine = lineObj._transformed_path.get_transformed_points_and_affine()
 path = affine.transform_path(path)
 for real,pixel in zip(lineObj.get_xydata(),path.vertices):
  ## write AREA tag  for each point

 [/CODE]

 I'd like to get information similar to this for the axis of the plot.

 Thanks.


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib for Python 2.6

2009-04-29 Thread R. Padraic Springuel
Is there a Windows installer file for matplotlib for Python 2.6?  I 
couldn't find one on the download page, but have to admit to being in 
something of a hurry and so didn't look too hard.

--

R. Padraic Springuel
Research Assistant
Department of Physics and Astronomy
University of Maine
Bennett 309
Office Hours: By appointment only


smime.p7s
Description: S/MIME Cryptographic Signature
--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Integrating matplotlib into a GUI

2009-04-29 Thread Gökhan SEVER
Hi Gary,

Could you please give some information on how Traits compare to Wx or
Qt? What are Traits' limits? I haven't started writing anything on GUI
level yet, but spending time to understand the Traits way.

Thank you.

Gökhan



On Wed, Apr 29, 2009 at 11:10 AM, Gary Pajer gary.pa...@gmail.com wrote:
 On Sun, Apr 26, 2009 at 6:41 PM, Gökhan SEVER gokhanse...@gmail.com wrote:
 Hello,

 Thanks for the pointer Bryan. I also seen Gael's tutorial
 (http://gael-varoquaux.info/computers/traits_tutorial/index.html)

 To me, it seems much easier to use Traits, instead of learning WX or QT.

 It is.  I had spent hours learning Tk, Wx, and Qt looking for a
 practical gui solution ... but then I found Traits and I haven't
 looked back.

 They are still confusing to me, and seemingly Traits is there to help me
 implement what I have had in my mind for a while.

 Gökhan


 On Sun, Apr 26, 2009 at 2:52 AM, Bryan Cole br...@cole.uklinux.net wrote:

  I know wxPython or PyQt seems way to go on this issue. But (there is
  always this but :) there is Chaco on the Enthought side and with
  nicely and simply integration with Traits and Traits UI.
 
  Are there anybody in the group that design a similar tool for their
  scientific data analysis needs? Could I get some insight into this?
  Any recommendations or pointers? Why's and why not's?

 You can integrate matplotlib plots into a Traits app. I wrote this
 recipe:

 http://www.scipy.org/Cookbook/EmbeddingInTraitsGUI

 Both Chaco and Matplotlib are excellent. If you want multiple
 interactive elements in your plot (drag-able labels, cursors etc.),
 Chaco is probably the best bet. However, for quick data-exploration
 apps, I find matplotlib quicker to set up (it's defaults just work,
 whereas Chaco takes a bit more preparation).

 Either way, Traits is indispensable.

 BC

 
  Thank you
 
  Gökhan
 
  --
  Crystal Reports #45; New Free Runtime and 30 Day Trial
  Check out the new simplified licensign option that enables unlimited
  royalty#45;free distribution of the report engine for externally facing
  server and web deployment.
  http://p.sf.net/sfu/businessobjects
  ___ Matplotlib-users mailing
  list Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users




 --
 Crystal Reports #45; New Free Runtime and 30 Day Trial
 Check out the new simplified licensign option that enables unlimited
 royalty#45;free distribution of the report engine for externally facing
 server and web deployment.
 http://p.sf.net/sfu/businessobjects
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


 --
 Crystal Reports #45; New Free Runtime and 30 Day Trial
 Check out the new simplified licensign option that enables unlimited
 royalty#45;free distribution of the report engine for externally facing
 server and web deployment.
 http://p.sf.net/sfu/businessobjects
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Fixed patch relative to axes

2009-04-29 Thread Eric Firing
Thomas Robitaille wrote:
 Hi,
 
 Is there an easy way to draw a patch or a patchcollection such that it  
 always stays at the same relative position in a set of axes, rather  
 than at the same pixel position? So for example, I would want to plot  
 it at (0.1,0.1) relative to the axes, and if I zoom in I would still  
 want it to stay at (0.1,0.1)

With ipython -pylab:

ax = gca()
ax.fill([0.1, 0.2, 0.15], [0.1, 0.1, 0.15], transform=ax.transAxes)
draw()

then pan, zoom at will.

Eric


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Fixed patch relative to axes

2009-04-29 Thread Thomas Robitaille
Thanks!

Is there an easy way to keep a reference to patches? I notice that for  
example

p = ax.add_patch(Circle((0.5,0.5),radius=0.5))

does not work (p is not a reference to the patch). Is there a way to  
keep a reference so I can update the properties of the patch at a  
later time?

Cheers,

Thomas

On 29 Apr 2009, at 21:13, Eric Firing wrote:

 Thomas Robitaille wrote:
 Hi,
 Is there an easy way to draw a patch or a patchcollection such that  
 it  always stays at the same relative position in a set of axes,  
 rather  than at the same pixel position? So for example, I would  
 want to plot  it at (0.1,0.1) relative to the axes, and if I zoom  
 in I would still  want it to stay at (0.1,0.1)

 With ipython -pylab:

 ax = gca()
 ax.fill([0.1, 0.2, 0.15], [0.1, 0.1, 0.15], transform=ax.transAxes)
 draw()

 then pan, zoom at will.

 Eric



--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Fixed patch relative to axes

2009-04-29 Thread Eric Firing
Thomas Robitaille wrote:
 Thanks!
 
 Is there an easy way to keep a reference to patches? I notice that for 
 example
 
 p = ax.add_patch(Circle((0.5,0.5),radius=0.5))
 
 does not work (p is not a reference to the patch). Is there a way to 
 keep a reference so I can update the properties of the patch at a later 
 time?

Split the command up:
p = Circle(...)
ax.add_patch(p, ...)

(add_* could be modified to return the reference; maybe this would be 
worthwhile.)


Eric

 
 Cheers,
 
 Thomas
 
 On 29 Apr 2009, at 21:13, Eric Firing wrote:
 
 Thomas Robitaille wrote:
 Hi,
 Is there an easy way to draw a patch or a patchcollection such that 
 it  always stays at the same relative position in a set of axes, 
 rather  than at the same pixel position? So for example, I would want 
 to plot  it at (0.1,0.1) relative to the axes, and if I zoom in I 
 would still  want it to stay at (0.1,0.1)

 With ipython -pylab:

 ax = gca()
 ax.fill([0.1, 0.2, 0.15], [0.1, 0.1, 0.15], transform=ax.transAxes)
 draw()

 then pan, zoom at will.

 Eric

 


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Pixel Position of X/Y Axis

2009-04-29 Thread Jae-Joon Lee
You may use the bbox attribute of the axes.
For example,  ax.bbox.extents gives you the x,y coordinates of the
lowerleft and topright corners.

-JJ

On Wed, Apr 29, 2009 at 4:06 PM, Mark Larsen larsen...@gmail.com wrote:
 It's been a while, please allow me to bump this...

 Sorry.  I use matplotlib to create PNGs graphics for display on a
 web-page.  I want to make the plots zoom-able.  I'll use javascript to
 capture the pixel positions of the user's selected zoom region on the
 PNG plot.  I'll then translate this into the coordinate system on the
 plot and redraw it with a new x, y range.  I'm having trouble
 translating the initial axises into the pixel positions (essentially
 where they are on the PNG image).

 For example, I use the following code to map point positions from the
 coordinate system to pixel positions.  I use an img map MAP to
 provide interaction with the actual lines.

 [CODE]

 lineObj = plt.plot(Xs,Ys,marker='o')[0]
 path, affine = lineObj._transformed_path.get_transformed_points_and_affine()
 path = affine.transform_path(path)
 for real,pixel in zip(lineObj.get_xydata(),path.vertices):
  ## write AREA tag  for each point

 [/CODE]

 I'd like to get information similar to this for the axis of the plot.

 Thanks.


 --
 Register Now  Save for Velocity, the Web Performance  Operations
 Conference from O'Reilly Media. Velocity features a full day of
 expert-led, hands-on workshops and two days of sessions from industry
 leaders in dedicated Performance  Operations tracks. Use code vel09scf
 and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Font size and savefig

2009-04-29 Thread Thomas Robitaille

Hi Jae-Jong and John,

Thanks for your replies! While experimenting with this to send  
screenshots, I realized that my default backend was set to MacOSX, not  
WXAgg. The WXAgg output to the screen actually agrees with the PNG  
output in terms of font sizes. But the font sizes differ between the  
MacOSX and WXAgg backends. Attached are screenshots using the MacOSX  
and WXAgg backends. You can see the font size is different. Is this a  
bug?


Thanks,

Thomas


inline: wxagg.pnginline: macosx.png

On 29 Apr 2009, at 00:24, Jae-Joon Lee wrote:

On Tue, Apr 28, 2009 at 11:09 PM, John Hunter jdh2...@gmail.com  
wrote:
If you want the relative fontsizes in the figure window and saved  
figure to

agree, pass the same dpi to the figure command and savefig command.


John,
I thought the font size (which is specified in points) is independent
of dpi, i.e., font size in pixel actually scales with the dpi. I
think it should be filed as a bug if the relative font size depends on
the dpi.

Anyhow, I just did a quick test and the (relative) font size does not
seem to vary with dpi.

Thomas,
What version of mpl are you using?
With the mpl from the svn trunk, I don't see any significant change as
you described.
The WxAgg figure and the png output are actually drawn by an identical
backend, so there should be no significant difference. There can be
some subtle difference due to different dpi, but I don't see a
difference as large as 30%. Can you post a some sample images? i.e., a
screenshot of WxAgg figure and the png output.

I can see that the text in pdf output occupies a bit larger area than
png (when usetex=False), but, to me, this seems to be due to different
amount of kernings (it seems that no kerning is applied for pdf text)
instead of different font size.

So, can you first check if the difference goes away when you use same
dpi as John suggested? And if that is the case, can you try the latest
svn and check if the relative font size still depends on the dpi?

Regards,

-JJ


--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] two scales in the same plot

2009-04-29 Thread Ondrej Certik
On Fri, Apr 24, 2009 at 1:10 PM, Sandro Tosi mo...@debian.org wrote:
 Hi Ondrej,
 nice to see you here :)

Nice to see you too! :)


 On Fri, Apr 24, 2009 at 22:02, Ondrej Certik ond...@certik.cz wrote:
 Hi,

 is there a way to have one plot with two functions, one using some
 scale, the other one a different scale and show for example one scale
 on the left, the other scale on the right?

 sure, twinx() is what you're looking for; here is a simple example:

 import matplotlib.pyplot as plt
 import numpy as np
 x = np.arange(0., np.e, 0.01)
 y1 = np.exp(-x)
 y2 = np.log(x)
 fig = plt.figure()
 ax1 = fig.add_subplot(111)
 ax1.plot(x, y1)
 ax1.set_ylabel('Y values for exp(-x)')
 ax2 = ax1.twinx()
 ax2.plot(x, y2, 'r')
 ax2.set_xlim([0,np.e])
 ax2.set_ylabel('Y values for ln(x)')
 ax2.set_xlabel('Same X for both exp(-x) and ln(x)')

 The values on X has to be of the same scale, tough, else the graph
 would look really weird.

Thanks a lot for the code. That worked. I was meeting some deadline,
so I forgot to reply that it worked.

Thanks Ryan and Jouni as well!

Ondrej

--
Register Now  Save for Velocity, the Web Performance  Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance  Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users