Re: [Matplotlib-users] multi colored text

2013-10-30 Thread Paul Ivanov
Hi Neal,

Neal Becker, on 2013-10-30 10:14,  wrote:
> I have a blue line plot and a green line plot.  I'd like to add some figtext 
> at 
> the bottom, and I'd like the text colors to match the plot colors.  So I'd 
> have 
> some text in blue and some in green.
> 
> figtext only allows one color
> 
> I could use 2 figtext, but then I have to manually find coordinate positions 
> for 
> the text.  That's ugly.
> 
> It would be nice if we had a TeX-like approach, where I could create a green 
> text object and a blue text object, then assemble them by stacking boxes.

You should be able to follow the approach I've taken here in
stacking the text bounding boxes together:

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

best,

-- 
   _
  / \
A*   \^   -
 ,./   _.`\\ / \
/ ,--.S\/   \
   /  `"~,_ \\
 __o   ?
   _ \<,_ /:\
--(_)/-(_).../ | \
--...J
Paul Ivanov
http://pirsquared.org

--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to undo "Zoom to Rectangle"?

2014-04-28 Thread Paul Ivanov
hopfrog, on 2014-04-28 16:12,  wrote:
> After I've used the "Zoom to Rectangle" control (next to Pan) to expand the
> view of a selected rectangle, what do I do to undo the zoom and restore the
> full view? 

You can restore the original "Home" view by pressing "h". Use 'c'
and 'v' keys to go back and forth between views (in case you do
several operations).

best,
-- 
   _
  / \
A*   \^   -
 ,./   _.`\\ / \
/ ,--.S\/   \
   /  `"~,_ \\
 __o   ?
   _ \<,_ /:\
--(_)/-(_).../ | \
--...J
Paul Ivanov
http://pirsquared.org

--
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to undo Zoom to Rectangle?

2014-04-28 Thread Paul Ivanov
Peter Shenkin, on 2014-04-28 19:17,  wrote:
> I am using the Zoom button that appears next to the Pan button.

Click the House/Home button that is all the way to the left of
the toolbar.

best,
-- 
   _
  / \
A*   \^   -
 ,./   _.`\\ / \
/ ,--.S\/   \
   /  `"~,_ \\
 __o   ?
   _ \<,_ /:\
--(_)/-(_).../ | \
--...J
Paul Ivanov
http://pirsquared.org

--
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplot crases because of XDG_CONFIG_HOME variable

2014-05-15 Thread Paul Ivanov
Hi Paul and Paul,

I thought I'd pile onto this Paul Pile...

Paul Tremblay, on 2014-05-15 16:33,  wrote:
> However, this really is a bug. I have spent about two hours trying to get
> this to work on EC.
> 
> Where to I file bugs?

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

Here's a recent issue which may be related to yours, 
https://github.com/matplotlib/matplotlib/issues/3062

but if that doesn't capture the problem you are seeing, and you
don't find an issue open for the behavior you're seeing,  please
open a new one.

best,
-- 
   _
  / \
A*   \^   -
 ,./   _.`\\ / \
/ ,--.S\/   \
   /  `"~,_ \\
 __o   ?
   _ \<,_ /:\
--(_)/-(_)----.../ | \
--...J
Paul Ivanov
http://pirsquared.org

--
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ImportError: No module named _backend_gdk

2014-08-05 Thread Paul Ivanov
discolemonade, on 2014-08-05 21:29,  wrote:
> Hi,
> 
> I'm using the GTKAgg backend and when I run "import matplotlib.pyplot as
> plt" in the Python shell, I get the   _backend_gdk error. I checked all the
> files in my backend and there is no _backend_gdk.py. In fact, there are no
> python modules that start with an underscore.

As a rule of thumb, modules that start with an underscore come
from a compiled C or C++ extension. In this case, the source
file in question lives in src/_backend_gdk.c of the matplotlib
directory.

> It seems that some files were not installed. Is there some kind
> of a gtk dependancy I need to install before installing
> matplotlib? If so, where can I get it? My matplot version is
> 1.3.1. 

Yes, you'll need GTK and its headers installed, something like 

  sudo apt-get install libgtk2.0-dev python-gtk2-dev 

should work on a Debian system, though you should probably just 

  sudo apt-get build-dep python-matplotlib

best,
-- 
   _
  / \
A*   \^   -
 ,./   _.`\\ / \
/ ,--.S\/   \
   /  `"~,_ \\
 __o   ?
   _ \<,_     /:\
--(_)/-(_).../ | \
--...J
Paul Ivanov
ipython and matplotlib core developer
http://pirsquared.org

--
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to generate one plot per key press?

2009-08-23 Thread Paul Ivanov
Try something like this:


from os import sys
from matplotlib import *
from numpy.random import rand

fig= pyplot.figure(figsize=(8,8), dpi=120)
pyplot.show()
while True:
z= rand(20,20)
pyplot.imshow(z)
pyplot.draw()

chr= sys.stdin.read(1)
if chr=='q': 
break

pyplot.close('all')


cheers,
Paul

Dr. Phillip M. Feldman, on 2009-08-22 23:19,  wrote:
> 
> The following trivial program is supposed to generate one plot per key press
> until the user presses 'q'.  Instead, nothing is displayed until the user
> presses 'q'.  Any suggestions will be appreciated.
> 
> from os import sys
> from matplotlib import *
> from numpy.random import rand
> 
> while True:
> 
>z= rand(20,20)
>fig= pyplot.figure(figsize=(8,8), dpi=120)
>pyplot.imshow(z)
>pyplot.show()
> 
>chr= sys.stdin.read(1)
>if chr=='q': sys.exit(0)
> -- 
> View this message in context: 
> http://www.nabble.com/how-to-generate-one-plot-per-key-press--tp25100658p25100658.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
> 
> 
> --
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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


Re: [Matplotlib-users] how to generate one plot per key press?

2009-08-23 Thread Paul Ivanov
appologies - sys.stdin.read(1) blocks until you give it a new line
() that' s probably what you were having problems with.
   
Paul Ivanov, on 2009-08-23 01:14,  wrote:
> Try something like this:
> 
> 
> from os import sys
> from matplotlib import *
> from numpy.random import rand
> 
> fig= pyplot.figure(figsize=(8,8), dpi=120)
> pyplot.show()
> while True:
> z= rand(20,20)
> pyplot.imshow(z)
> pyplot.draw()
> 
> chr= sys.stdin.read(1)
> if chr=='q': 
> break
> 
> pyplot.close('all')
> 
> 
> cheers,
> Paul
> 
> Dr. Phillip M. Feldman, on 2009-08-22 23:19,  wrote:
> > 
> > The following trivial program is supposed to generate one plot per key press
> > until the user presses 'q'.  Instead, nothing is displayed until the user
> > presses 'q'.  Any suggestions will be appreciated.
> > 
> > from os import sys
> > from matplotlib import *
> > from numpy.random import rand
> > 
> > while True:
> > 
> >z= rand(20,20)
> >fig= pyplot.figure(figsize=(8,8), dpi=120)
> >pyplot.imshow(z)
> >pyplot.show()
> > 
> >chr= sys.stdin.read(1)
> >if chr=='q': sys.exit(0)
> > -- 
> > View this message in context: 
> > http://www.nabble.com/how-to-generate-one-plot-per-key-press--tp25100658p25100658.html
> > Sent from the matplotlib - users mailing list archive at Nabble.com.
> > 
> > 
> > --
> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> > trial. Simplify your report design, integration and deployment - and focus 
> > on 
> > what you do best, core application coding. Discover what's new with 
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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


Re: [Matplotlib-users] create ListedColormap with different alpha values

2008-11-23 Thread Paul Ivanov
I took a stab at it, how does this look?

I also took the liberty of adding alpha to LinearSegmentedColormap and
updated its docstring changing two somewhat ambiguous uses of the word
'entry' with 'key' and 'value'.

tested with

In [1]: import matplotlib; import numpy as np
In [2]: my_rgba_array= np.array( [[ 1.,  1.,  1.,  0.65],
[ 1., 0.,  0.,  0.79]])
In [3]: myColormap = matplotlib.colors.ListedColormap(my_rgba_array)

In [4]: myColormap.__call__(.1)
Out[4]: (1.0, 1.0, 1.0, 0.65002)

In [5]: myColormap.__call__(.9)
Out[5]: (1.0, 0.0, 0.0, 0.790

In [6]: my_rgba_array= np.array( [ [ 1.  ,  1.  ,  1. ],
   [ 1.  ,  0.  ,  0.  ]])

In [7]: myColormap = matplotlib.colors.ListedColormap(my_rgba_array)

In [8]: myColormap.__call__(.1)
Out[8]: (1.0, 1.0, 1.0, 1.0)

In [9]: myColormap.__call__(.9)
Out[9]: (1.0, 0.0, 0.0, 1.0)


cheers,
Paul Ivanov

John Hunter, on 2008-11-21 05:52, wrote:
> On Fri, Nov 21, 2008 at 2:45 AM, Simon Kammerer <[EMAIL PROTECTED]> wrote:
> 
>> After looking at the source of matplotlib.colors, it seems to me that
>> different alpha values are something Colormap is not designed for.
> 
> Yes, it looks like the colormap only holds the RGB channels, but it
> also looks fairly straightforward to patch the code to support the
> fourth channel.  Is this something you'd like to tackle?
> 
> JDH
> 
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Index: lib/matplotlib/colors.py
===
--- lib/matplotlib/colors.py	(revision 6431)
+++ lib/matplotlib/colors.py	(working copy)
@@ -452,7 +452,7 @@
 self._isinit = False
 
 
-def __call__(self, X, alpha=1.0, bytes=False):
+def __call__(self, X, alpha=None, bytes=False):
 """
 *X* is either a scalar or an array (of any dimension).
 If scalar, a tuple of rgba values is returned, otherwise
@@ -466,9 +466,10 @@
 """
 
 if not self._isinit: self._init()
-alpha = min(alpha, 1.0) # alpha must be between 0 and 1
-alpha = max(alpha, 0.0)
-self._lut[:-3, -1] = alpha
+if alpha:
+alpha = min(alpha, 1.0) # alpha must be between 0 and 1
+alpha = max(alpha, 0.0)
+self._lut[:-3, -1] = alpha
 mask_bad = None
 if not cbook.iterable(X):
 vtype = 'scalar'
@@ -558,9 +559,10 @@
 def __init__(self, name, segmentdata, N=256):
 """Create color map from linear mapping segments
 
-segmentdata argument is a dictionary with a red, green and blue
-entries. Each entry should be a list of *x*, *y0*, *y1* tuples,
-forming rows in a table.
+segmentdata argument is a dictionary with red, green and blue
+keys. An optional alpha key is also supported. Each value
+should be a list of *x*, *y0*, *y1* tuples, forming rows in a
+table. 
 
 Example: suppose you want red to increase from 0 to 1 over
 the bottom half, green to do the same over the middle half,
@@ -606,6 +608,8 @@
 self._lut[:-3, 0] = makeMappingArray(self.N, self._segmentdata['red'])
 self._lut[:-3, 1] = makeMappingArray(self.N, self._segmentdata['green'])
 self._lut[:-3, 2] = makeMappingArray(self.N, self._segmentdata['blue'])
+if self._segmentdata.has_key('alpha'):
+self._lut[:-3, 3] = makeMappingArray(self.N, self._segmentdata['blue'])
 self._isinit = True
 self._set_extremes()
 
@@ -664,11 +668,10 @@
 
 
 def _init(self):
-rgb = np.array([colorConverter.to_rgb(c)
+rgba = np.array([colorConverter.to_rgba(c)
 for c in self.colors], np.float)
 self._lut = np.zeros((self.N + 3, 4), np.float)
-self._lut[:-3, :-1] = rgb
-self._lut[:-3, -1] = 1
+self._lut[:-3] = rgba
 self._isinit = True
 self._set_extremes()
 
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] create ListedColormap with different alpha values

2008-11-25 Thread Paul Ivanov
Hey John and the rest of the MPL gang:

I've made the changes you suggested, but the problem is looking to be
deeper than it seemed. I'm also moving this conversation to
matplotlib-devel, since that's probably the more appropriate place for
it.

This updated patch allows for the creation of colormaps with various
alphas, but there is likely more work to be done so that  mpl can
consistently make use of it (because it seems like all built-in cmaps
are RGB, not RGBA).

In trying to come up with an example that exercises the new
capabilities, I found out that methods like scatter and countourf modify
the colormap you give them and reset all of the alpha values to 1.

I think this is because inside collections, we pass self._alpha, which
is the Artist._alpha, and 1.0 by default, when making calls such
as:
_colors.colorConverter.to_rgba_array(c, self._alpha)

...Thus resetting  all of alpha values.

I was able to get around this by allowing collections to take on an
alpha value of None, and then passing alpha=None to scatter and
countourf, for example. There are probably other places where such a
change should be done, unless someone has a better idea for how do do
this. I updated examples/pylab/plot_scatter.py to show off the new
capability.

Another thing that I was unable to get around is that if you now make a
plot using the same colormap but omit the alpha=None parameter, or set
it to something other than None, it will reset the alpha values on the
previous plot:

figure(2)
c = scatter(theta, r, c=colors, s=area,cmap=myColormap,alpha=None)

will do the right thing, but calling scatter without alpha=None

figure(3)
d = scatter(theta, r, c=colors, s=area,cmap=myColormap)
or
d = scatter(theta, r, c=colors, s=area,cmap=myColormap, alpha=.5)

will reset all of the alpha values in myColormap to 1 or .5.
You can do c.cmap._init() to reset its original alpha values, and if you
force a redraw on figure(2) (by panning or zooming on it, for example),
it will look right again. However, if you go and fiddle with figure(3)
(pan/zoom), and come back to figure(2), panning or zooming will
cause all of the alpha values will be reset again.

I'm not sure if it would be worth it to make a copy of the colormap to
prevent this from happening. Anyone have thoughts on this?

(the full example of this is commented with FIXME: in polar_scatter.py)

best,
Paul Ivanov


John Hunter, on 2008-11-23 07:36, wrote:
> On Sun, Nov 23, 2008 at 2:01 AM, Paul Ivanov <[EMAIL PROTECTED]> wrote:
>> I took a stab at it, how does this look?
>>
>> I also took the liberty of adding alpha to LinearSegmentedColormap and
>> updated its docstring changing two somewhat ambiguous uses of the word
>> 'entry' with 'key' and 'value'.
> 
> Hey Paul,
> 
> Thanks for taking this on.  I haven't tested this but I read the patch
> and have some inline comments below.  Some additional comments:
> 
>   * the patch should include a section in the CHANGELOG and
> API_CHANGES letting people know what is different.
> 
>   * you should run examples/tests/backend_driver.py and make sure all
> the examples still run, checking the output of some of the mappable
> types (images, scaltter, pcolor...)
> 
>   * it would be nice to have an example in the examples dir which
> exercises the new capabilities.
> 
> See also, in case you haven't,
> http://matplotlib.sourceforge.net/devel/coding_guide.html, which
> covers some of this in more detail.
> 
> Thanks again!  Comments below:
> 
> Index: lib/matplotlib/colors.py
> ===
> --- lib/matplotlib/colors.py  (revision 6431)
> +++ lib/matplotlib/colors.py  (working copy)
> @@ -452,7 +452,7 @@
>  self._isinit = False
> 
> 
> -def __call__(self, X, alpha=1.0, bytes=False):
> +def __call__(self, X, alpha=None, bytes=False):
>  """
>  *X* is either a scalar or an array (of any dimension).
>  If scalar, a tuple of rgba values is returned, otherwise
> @@ -466,9 +466,10 @@
>  """
> You need to document what alpha can be here: what does None mean, can
> it be an array, scalar, etc...
> 
>  if not self._isinit: self._init()
> -alpha = min(alpha, 1.0) # alpha must be between 0 and 1
> -alpha = max(alpha, 0.0)
> -self._lut[:-3, -1] = alpha
> +if alpha:
> 
> I prefer to explicitly use "if alpha is None", since there are other
> things that would test False (0, [], '') that you probably don't mean.
> 
> +alpha = min(alpha, 1.0) # alpha must be between 0 and 1
> + 

Re: [Matplotlib-users] Matplotlib or numpy bug?

2008-11-27 Thread Paul Ivanov
Hi Jesper,

confirming the problem over here, as well. both numpy and mpl from svn
(also on an Ubuntu 8.04 machine).

good luck,
Paul


Jesper Larsen, on 2008-11-27 02:10, wrote:
> Hi Eric and Mauro,
> 
> Thanks for your answers.
> 
> 2008/11/27 Eric Firing <[EMAIL PROTECTED]>:
>> It looks OK to me with mpl and numpy from svn.
> 
> I tried upgrading to numpy from svn as well. Unfortunately the problem
> persists (I have attached a plot). I have seen the problem on two of
> my Ubuntu machines. Maybe it is caused by my specific setup and
> supporting libraries.
> 
> Since I have a working solution and it does not seem to affect others
> (based on a survey of two:-) let us just leave the problem for now. If
> someone else encounter it please let me know and I will try to dive a
> bit into the issue. If the problem turns up again when I have a need
> to upgrade numpy (which is probably when matplotlib requires me to) I
> will also look into it.
> 
> Best regards,
> Jesper
> 
> 
> 
> 
> 
> 
> 
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> 
> 
> 
> 
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib or numpy bug?

2008-11-28 Thread Paul Ivanov
Eric Firing, on 2008-11-28 17:55, wrote:
> Paul Ivanov wrote:
>> Hi Jesper,
>>
>> confirming the problem over here, as well. both numpy and mpl from svn
>> (also on an Ubuntu 8.04 machine).
> 
> Just checking: did you do a clean build of numpy (deleting any old build
> directory) and then a clean build of mpl?  Distutils is not very smart
> about dependencies.
> 
> Eric

Yeah, just checked again against numpy 1.3.0.dev6118 and mpl r6456 after
clearing everything.

Paul

> 
>>
>> good luck,
>> Paul
>>
>>
>> Jesper Larsen, on 2008-11-27 02:10, wrote:
>>> Hi Eric and Mauro,
>>>
>>> Thanks for your answers.
>>>
>>> 2008/11/27 Eric Firing <[EMAIL PROTECTED]>:
>>>> It looks OK to me with mpl and numpy from svn.
>>> I tried upgrading to numpy from svn as well. Unfortunately the problem
>>> persists (I have attached a plot). I have seen the problem on two of
>>> my Ubuntu machines. Maybe it is caused by my specific setup and
>>> supporting libraries.
>>>
>>> Since I have a working solution and it does not seem to affect others
>>> (based on a survey of two:-) let us just leave the problem for now. If
>>> someone else encounter it please let me know and I will try to dive a
>>> bit into the issue. If the problem turns up again when I have a need
>>> to upgrade numpy (which is probably when matplotlib requires me to) I
>>> will also look into it.
>>>
>>> Best regards,
>>> Jesper
>>>
>>>
>>> 
>>>
>>>
>>> 
>>>
>>> -
>>>
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>>> challenge
>>> Build the coolest Linux based applications with Moblin SDK & win
>>> great prizes
>>> Grand prize is a trip for two to an Open Source event anywhere in the
>>> world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>>
>>>
>>> 
>>>
>>> ___
>>> Matplotlib-users mailing list
>>> Matplotlib-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>> -
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pylab, twinx, and displayed coordinates

2011-09-23 Thread Paul Ivanov
Hi Andreas,

On Fri, Sep 23, 2011 at 2:08 PM, Andreas Matthias
 wrote:
> In the following example the coordinates of the mouse
> cursor displayed in the pylab window belong to the
> second y-axis. But I would prefer to have the coordinates
> of the first y-axis to be displayed. Is this possible?

yes it is.

> import pylab as mpl
>
> mpl.plot([1,3,2])
> mpl.twinx()
> mpl.plot([400,50,100])
> mpl.show()

# get the current figure
f = mpl.gcf()

# Hide the "background" for the first axes, otherwise it will block
the second one when we swap
f.axes[0].set_frame_on(False)

# Swap the axes
f.axes.reverse()

# Turn on the "background" for the *new* first axes (the one that was
created second)
f.axes[0].set_frame_on(False)

you can also achieve the same effect by changing the zorder of axes -
provided that you remember to have turn the frame on for the one that
is the furthest back, and turn it off for all others lying on top of
it. You can see what happens if you don't do this by omitting the
calls to set_frame_on, and then verifying that the second line does
not show up (because the original axes' frame patch is blocking it.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] Error when zooming manually with the mouse outside of the axes

2011-09-24 Thread Paul Ivanov
Hi Eric,

On Wed, Sep 21, 2011 at 9:11 AM, Eric O LEBIGOT (EOL)
 wrote:
> With the Mac OS X backend (at least…), error messages are repeatedly printed
> when the mouse leaves the axes rectangle:
>
>  File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py",
> line 420, in draw_rubberband
>    self.canvas.set_rubberband(x0, y0, x1, y1)
> TypeError: integer argument expected, got float
>
> This problem is annoying because the error messages clutter the terminal,
> and useful printed information leaves the screen. :)

This problem was fixed by 2c924046 (Jim Radford 2011-03-08 15:07:23 -0800 459)
and now reads:

self.canvas.set_rubberband(int(x0), int(y0), int(x1), int(y1))

Please update either that line alone, or checkout the latest
matplotlib sources from GitHub.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] pylab, twinx, and displayed coordinates

2011-09-24 Thread Paul Ivanov
On Sat, Sep 24, 2011 at 3:59 AM, Andreas Matthias
 wrote:
> Hmm. I do not get a reversed list of axes. This is the output of
> the example code below:
>
> [,  object at 0x8f633ec>]
> [,  object at 0x8f633ec>]

This doesn't seem right - for me that code results in:
[,
]
[,
]

can you try explicitly swapping your axes? f.axes =
[f.axes[1],f.axes[0]] instead of the call to reverse?

> BTW, what's matplotlib.axes.AxesSubplot? I couldn't find this class.

see  SubplotBase class and subplot_class_factory function in matplotlib/axes.py

best,
--
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-21 Thread Paul Ivanov
Hi Rich,

On Mon, Oct 17, 2011 at 10:57 AM, Rich Shepard  wrote:
>   After a long hiatus I'm again working on an application and just upgraded
> matplotlib from 0.98.5.2 to 0.99.1.2.

Is there a particular reason you just upgraded to a version of
matplotlib that is almost 2 years old now? Matplotlib 1.1.0 was
released a few weeks ago, so it's strange that you did not upgrade to
it, or at least to 1.0.1, which came out in January. I'm not certain
that the issue you're running into has been fixed, but there have
certainly been lots of changes. I also want to make sure that there
isn't some stale pointer to an old version of matplotlib out there -
so can you let us know what procedure you used to do the upgrade?

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-21 Thread Paul Ivanov
On Mon, Oct 17, 2011 at 3:59 PM, Rich Shepard  wrote:
> On Mon, 17 Oct 2011, Benjamin Root wrote:
>
>> I only need the last line printed by that print statement.  I want to see
>> how the parsing failed.
>
> Ben,
>
>   Here are the last 3:
>
> Line: C 125 ; WX 273 ; N braceright ; B 55 -68 244 707 ;
> Line: C 126 ; WX 586 ; N asciitilde ; B 39 219 531 408 ;
> Line: C 127 ; WX 262 ; N  ; B 64 506 246 730 ;
>
>   I see there's no character in the last line. Isn't that interesting!

What's weirder, is that 127 is a control character (Delete), and not
meant to be a printable character.

Maybe you already figured this out in following up with Ben, but if
not, can you 'print fh.name' before the while 1: in
_parse_char_metrics so we find out which .afm file is the culrpit

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-23 Thread Paul Ivanov
On Sat, Oct 22, 2011 at 7:54 AM, Rich Shepard  wrote:
> On Fri, 21 Oct 2011, Paul Ivanov wrote:
>   I will certainly add diagnostic code requested by you, Ben, and anyone
> else and report the results when trying to run the model. I do need to fix
> this and have no idea what's behind the problem.

The traceback is due to a nonprinting character being included in one
of the fonts on your system - we just need to figure out which one.
Change my request to add 'sys.stderr.write(fh.name)' before the 'while
1:' in
_parse_char_metrics  - just so we don't have any buffering issues. The
last file you see printed there will be the one that's causing the
issue. You can then try removing it, or sending it back to the list
(or both) so we can see what happened.

The other issue you're seeing ("unknown keyword in AFM header") is
also likely caused by bad font files.
>From your error log that Ben forwarded to the list - I'm a bit
suspicious that two of the errors came from an afm file that ships
with matplotlib, in particular matplotlib-error-trace.txt starts off
with:

  FILENAME:
  /usr/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/afm/pagko8a.afm
  Found an unknown keyword in AFM header (was Underline)
  Found an unknown keyword in AFM header (was Underline)

This shouldn't be the case, as I can verify that the keywords aren't
just Underline - they are as follows:

  $ grep Under matplotlib/mpl-data/fonts/afm/pagko8a.afm
  UnderlinePosition -100
  UnderlineThickness 50

and that particular file has not been change in matplotlib since
February of 2007

So my wild guess is that something changed your afm files. Can you
check that your pagko8a.afm matches the one in
https://raw.github.com/matplotlib/matplotlib/master/lib/matplotlib/mpl-data/fonts/afm/pagko8a.afm
- and if they don't match, check that using the original pagko8a.afm
makes at least that error go away?

As another possible solution (maybe this is already done, but worth a
potshot), you could try switching USE_FONTCONFIG to True in
font_manager.py as per the docstring there:

Experimental support is included for using `fontconfig` on Unix
variant platforms (Linux, OS X, Solaris).  To enable it, set the
constant ``USE_FONTCONFIG`` in this file to ``True``.  Fontconfig has
the advantage that it is the standard way to look up fonts on X11
platforms, so if a font is installed, it is much more likely to be
found.)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-24 Thread Paul Ivanov
On Mon, Oct 24, 2011 at 6:35 AM, Rich Shepard  wrote:
>   Would you like a copy of kidsn.afm?

sure. let's take a look.

What about the .afm that ships with matplotlib which also caused
problems - did you verify that the one you have is the same as the one
under version control in matplotlib?

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-24 Thread Paul Ivanov
On Mon, Oct 24, 2011 at 2:47 PM, Rich Shepard  wrote:
> Underline Position -100
> Underline Thickness 50

those two properties should not have spaces in them - according the
the AFM file spec that I could find - they should be one word - which
is what matplotlib expects - and this is the source of all of the
"'Found an unknown keyword in AFM header (was Underline)" warning that
you saw.

> C 127 ; WX 262 ; N  ; B 64 506 246 730 ;

I still find it strange that this character is even in the font file
- maybe it had a value other than just space, but copy pasting made it
appear as such? Please resend the file as an attachement so we can
verify.

In the meantime - this patch should get around trying to parse any
such files without causing tracebacks

in lib/matplotlib/afm.py, after the line that says 'if
line.startswith('Comment'): continue' add another line that says 'if
line.startswith('C 127'): continue'

>> What about the .afm that ships with matplotlib which also caused problems
>> - did you verify that the one you have is the same as the one under
>> version control in matplotlib?
>
>   Well, the source file came from the matplotlib Web site, so I assume that
> it/they are OK. The SlackBuild script essentially re-packages the download
> as a Slackware package so it can be managed more easily and consistently
> with other packages.

If this was really the case, we should not have been seeing "Found an
unknown keyword in AFM header (was Underline)" for the afm files that
ship with matplotlib (but we were on your machine - so something
changed them).

Please diff your pagko8a.afm against
https://raw.github.com/matplotlib/matplotlib/master/lib/matplotlib/mpl-data/fonts/afm/pagko8a.afm

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-24 Thread Paul Ivanov
On Mon, Oct 24, 2011 at 3:26 PM, Rich Shepard  wrote:
> On Mon, 24 Oct 2011, Paul Ivanov wrote:
>
>> those two properties should not have spaces in them - according the the
>> AFM file spec that I could find - they should be one word - which is what
>> matplotlib expects - and this is the source of all of the "'Found an
>> unknown keyword in AFM header (was Underline)" warning that you saw.
>
> Paul,
>
>   That specific font is apparently kid oriented (not surprising as it comes
> from Corel a long time ago). I can delete it and never miss it.

Ok - strange that we saw a lot of errors caused by probably the same
deviation from the AFM standard in several other files as indnicated
by the error file Ben posted earlier in this thread.

>
>>> C 127 ; WX 262 ; N  ; B 64 506 246 730 ;
>>
>> I still find it strange that this character is even in the font file
>> - maybe it had a value other than just space, but copy pasting made it
>> appear as such? Please resend the file as an attachement so we can
>> verify.
>>
>> In the meantime - this patch should get around trying to parse any
>> such files without causing tracebacks
>>
>> in lib/matplotlib/afm.py, after the line that says 'if
>> line.startswith('Comment'): continue' add another line that says 'if
>> line.startswith('C 127'): continue'
>
>   OK. Done.

so no more tracebacks?

>> If this was really the case, we should not have been seeing "Found an
>> unknown keyword in AFM header (was Underline)" for the afm files that
>> ship with matplotlib (but we were on your machine - so something
>> changed them).
>>
>> Please diff your pagko8a.afm against
>> https://raw.github.com/matplotlib/matplotlib/master/lib/matplotlib/mpl-data/fonts/afm/pagko8a.afm
>
>   There's no difference between
> /usr/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/afm/pagko8a.afm
> and the pagko8a.afm I downloaded from github.

Well, that's a mystery... why did you previously see a "Found an
unknown keyword in AFM header (was Underline)" message for it...

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py

2011-10-25 Thread Paul Ivanov
On Tue, Oct 25, 2011 at 1:59 PM, Rich Shepard  wrote:
> On Mon, 24 Oct 2011, Rich Shepard wrote:
>
>>> so no more tracebacks?
>>   I'll try again tomorrow morning before I head to the dentist.
>
>   I didn't try then, but just did now. Still the same error:
>
> Found an unknown keyword in AFM header (was Underline)
> Traceback (most recent call last):
>   File "./eikos.py", line 6, in 
>     from modelPage import modModel
>   File "/home/rshepard/development/trunk/modelPage.py", line 9, in 
>     from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
> FigureCanvas
>   File
> "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_wxagg.py",
> line 20, in 
>     from matplotlib.figure import Figure
>   File "/usr/lib/python2.6/site-packages/matplotlib/figure.py", line 18, in
> 
>     from axes import Axes, SubplotBase, subplot_class_factory
>   File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 14, in
> 
>     import matplotlib.axis as maxis
>   File "/usr/lib/python2.6/site-packages/matplotlib/axis.py", line 10, in
> 
>     import matplotlib.font_manager as font_manager
>   File "/usr/lib/python2.6/site-packages/matplotlib/font_manager.py", line
> 1323, in 
>     _rebuild()
>   File "/usr/lib/python2.6/site-packages/matplotlib/font_manager.py", line
> 1273, in _rebuild
>     fontManager = FontManager()
>   File "/usr/lib/python2.6/site-packages/matplotlib/font_manager.py", line
> 997, in __init__
>     self.afmlist = createFontList(self.afmfiles, fontext='afm')
>   File "/usr/lib/python2.6/site-packages/matplotlib/font_manager.py", line
> 559, in createFontList
>     font = afm.AFM(fh)
>   File "/usr/lib/python2.6/site-packages/matplotlib/afm.py", line 305, in
> __init__
>     parse_afm(fh)
>   File "/usr/lib/python2.6/site-packages/matplotlib/afm.py", line 293, in
> parse_afm
>     dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
>   File "/usr/lib/python2.6/site-packages/matplotlib/afm.py", line 177, in
> _parse_char_metrics
>     name = vals[2].split()[1]
> IndexError: list index out of range
>
>   Sigh. I'm sure it's as frustrating for you as it is for me.

Well, I hope the dentist trip was more of a success :) Don't worry
about it - it's become kind of a fun challenge now.

I see you sent this just a few minutes ago - let's try to figure this
out interactively via IRC on #matplotlib channel on freenode. If you
don't have an IRC client handy, you can just use this web-based one.
http://webchat.freenode.net/?channels=matplotlib

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] 0.99.1.2: error in afm.py [RESOLVED]

2011-10-25 Thread Paul Ivanov
On Tue, Oct 25, 2011 at 4:59 PM, Rich Shepard  wrote:
> On Tue, 25 Oct 2011, Paul Ivanov wrote:
>
>> I see you sent this just a few minutes ago - let's try to figure this out
>> interactively via IRC on #matplotlib channel on freenode. If you don't
>> have an IRC client handy, you can just use this web-based one.
>> http://webchat.freenode.net/?channels=matplotlib
>
> Paul, et al.:
>
>   Changing "underline " to "underline" fixed the problem. Now I have some
> legacy database connection issues since pysqlite3 is now included with
> python. Ergo, no more matplotlib complaints! (I suppose that removing the
> kidsd.* font had nothing to do with it, but I don't use that font in any
> case.)

Awesome! glad we finally got to the bottom of it. For the record  - in
case others start seeing this error: "Found an unknown keyword in AFM
header (was Underline)", when the afm file in question splits up the
UnderlinePosition to be two words with a space between them, here's
the patch to fix that problem.

diff --git a/lib/matplotlib/afm.py b/lib/matplotlib/afm.py
index bb51634..127e63d 100644
--- a/lib/matplotlib/afm.py
+++ b/lib/matplotlib/afm.py
@@ -132,6 +132,7 @@ def _parse_header(fh):
 line = fh.readline()
 if not line: break
 line = line.rstrip()
+line = line.replace("Underline ", "Underline")
 if line.startswith('Comment'): continue
 lst = line.split( ' ', 1 )
 #print '%-s\t%-d line :: %-s' % ( fh.name, len(lst), line )

I won't commit this to trunk, because it doesn't seem like anyone else
has run into this before - so maybe there are very few afm files out
there using this *incorrect*, as far as I can ascertain,  version of
the AFM headers

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] set background of axes + labels

2011-11-11 Thread Paul Ivanov
On Wed, Nov 9, 2011 at 7:37 AM, Brent Pedersen  wrote:
> Hi,
> I have an image like this:
> https://docs.google.com/open?id=0B7eMlcFeoB_rMTU1OTU0NmMtMzM3MC00YWI3LWFlNTYtNzg0MTM4MWI3OWMz
>
> with an axes inside of another. I'd like to set the background behind
> the labels of the inner figure.
> I've tried set_frame_on on the axis, set_frameon on the figure,
> axisbg_color, and so on.

Would it be sufficient to set the background color behind the text
labels? If 'ax' is your inner axes, do:

ax.yaxis.label.set_backgroundcolor('red')
ax.xaxis.label.set_backgroundcolor('red')

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] legend border, frameon keyword

2011-11-11 Thread Paul Ivanov
Oops, didn't reply to list last time:

On Fri, Nov 11, 2011 at 8:53 AM, Paul Ivanov  wrote:
> On Tue, Nov 8, 2011 at 4:49 PM, magurling  wrote:
>>
>> I want a legend without the black border. I've tried a few things that have
>> been suggested on this forum and elsewhere to no avail. According to what
>> I've seen, it should be as simple as:
>
> Your example works as intended here.
>
>
>> It must be something simple that I am doing wrong. Any ideas?
>
> might you be on an old matplotlib.__version__?


best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] legend border, frameon keyword

2011-11-11 Thread Paul Ivanov
>> On Fri, Nov 11, 2011 at 8:53 AM, Paul Ivanov  wrote:
>>> might you be on an old matplotlib.__version__?

On Fri, Nov 11, 2011 at 11:18 AM, magurling  wrote:
> This is probably it. I installed by "apt-get install" but keep getting
> version 0.99.3 installed.
> I need to install a more recent version before I trouble anyone further.
> Which version are you using Paul?

1.2.0dev from Git :), but you will be fine with the latest stable (v1.1.0)

see 
http://matplotlib.sourceforge.net/users/installing.html#installing-from-source

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] legend border, frameon keyword

2011-11-11 Thread Paul Ivanov
On Fri, Nov 11, 2011 at 12:40 PM, magurling  wrote:
> I updated matplotlib to 1.1.0; both methods work now.

Thanks for letting us know, and glad it works for you now - that
information is useful for those who search for similar error messages
in the future and find this thread.

> I would say "Thanks  Paul and Francesco" but I just read the mailing list 
> etiquette.

you're very welcome - though I'm not sure what etiquette you're
referring to? I think it's useful for poster who ask for help to
report back when they've overcome whatever problem they were having
along with how they resolved it, so that others can follow in their
footsteps later.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
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] constant spacing with griddata

2011-12-19 Thread Paul Ivanov
Hi Brad,

Brad Malone, on 2011-12-19 19:06,  wrote:
> However, when I do my own data I get an error message that says:
> 
> > Traceback (most recent call last):
> >   File "make_colormap.py", line 248, in 
> > zi=griddata(x,y,z,xi,yi,interp='linear')
> >   File "/usr/lib/pymodules/python2.6/matplotlib/mlab.py", line 2579, in
> > griddata
> > raise ValueError("output grid must have constant spacing"
> > ValueError: output grid must have constant spacing when using
> > interp='linear'
...
 
> However, my code, when I do something like
> 
> > xi=linspace(-20.1,20.1,100)
> > yi=linspace(-20.1,20.1,200)
> > zi=griddata(x,y,z,xi,yi,interp='linear')
> > CS=plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
> 
> 
> it gives me the above error complaining about "constant spacing".
> 
> Anyone have an idea what I might be missing here? I can turn interp to 'nn'
> and the code works fine, but I'm just curious what about a "constant
> spaced" output grid I don't understand. Is it even possible to create a
> non-constant spaced output grid with linspace?

Looking at the code, it seems to be a floating point issue for
the way linspace works for the particular values you specified.
This should work for you, instead:

  xi=np.arange(-20.1,20.1+1e-14, 40.2/99)
  yi=np.arange(-20.1,20.1+1e-14,40.2/199)

NOTE: neither xi.max() nor yi.max() are "exactly" 20.1, the way
they were with linspace, nor is xi.max() exactly yi.max(). I say
"exactly" (in quotes) because when you type in 20.1, the floating point
number that you get isn't 20.10, it's
more like 20.1000+change, in ipython, run '%precision 20' to
see what I mean.

Either the np.linspace or the mpl code likely needs to change,
because in mpl, the error gets raised when, effectively:

  dx = np.diff(xi)
  dx.max() - dx.min() > np.finfo(xi.dtype).resolution

and same for yi, which is what happens with the values you
provided to linspace, due to the way linspace works.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
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] Speeding up pcolor plot

2011-12-20 Thread Paul Ivanov
Hey again, Brad,

Brad Malone, on 2011-12-19 23:44,  wrote:
> Hi, I am plotting a grid with pcolor. Below I've got a 1000x1000 grid.
> 
> xi=linspace(-0.1,x[-1]+2,1000)
> > yi=linspace(-0.1,maxfreq+10,1000)
> > print 'Calling griddata...'
> > zi=griddata(x,y,z,xi,yi,interp='nn')
> > plt.pcolor(xi,yi,zi,cmap=plt.cm.hot)
... 
> How could I modify my above data (which is in xi,yi,and zi) to
> work with imshow (which seems to take 1 argument for data).

Try either:

  plt.matshow(zi,cmap=plt.cm.hot)

or

  plt.imshow(zi,cmap=plt.cm.hot)

The first should be the quickest - it doesn't do any
fancy interpolation, and actually just passes some arguments to
the second. Using imshow directly, however, allows you to set a
different type of interpolation, should you desire it. If
you want xi and yi to be accurately reflect in the plot, you
might have to play around with changing the axis formatters
(though there might be an easier way of doing that, which escapes
me right now)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
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] contourf with rgba colours

2011-12-30 Thread Paul Ivanov
Eric Firing, on 2011-12-27 15:31,  wrote:
> It looks like this is something I can fix by modifying ListedColormap. 
> It is discarding the alpha values, and I don't think there is any reason 
> it needs to do so.

One of my first attempts at a contribution to matplotlib three
years ago was related to this. It was in reply to a similar
question on list, and I wrote a patch, but never saw it through
to inclusion because it wasn't something I needed.

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg09216.html

I think it's a helpful starting point, as I include a discussion
on the limitation of mpl colormaps there.
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
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] Bug in griddata

2012-01-10 Thread Paul Ivanov
Thanks for the report, Ethan,

Ethan Swint, on 2012-01-10 16:34,  wrote:
> Can anyone else reproduce?

Confirming, this is a bug. We need to change the matplotlib code,
but I'm not sure how to proceed. I've filed it as the ominously
numbered matplotlib issue #666

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

> It seems that 'xi,yi = np.meshgrid(xi,yi)' from line 2766 of mlab.py 
> doesn't always produce uniformly spaced data, as the test for uniform 
> data fails at line 2779.  Ignoring the error, however, results in 
> satisfactory evaluation of interp() on 2783.

That's not quite the issue here, as meshgrid simply reshapes and
repeats the data that you hand it. 

At first I was going to blame linspace, because a similar issue
came up on this list late last year, and in that example, simply
using arange instead of linspace resolved the issue:

http://old.nabble.com/constant-spacing-with-griddata-td33007330.html#a33007330

There, I considered the possibility that either (or both) the
numpy and mpl code should be changed. 

With your example, I'm convinced now the MPL code needs to
change, since here, linspace and arange produce identical
results. The reason I'm not sure how to proceed is that the
difference between dx.max() and dx.min() can be an order of
magnitude greater than the epsx value it is compared against.
Here's a modification to your example that does this

  In [155]: xi = np.linspace(0,603,100);dx =np.diff(xi); dx.ptp()
  Out[155]: 0.11368684
  
  In [157]: zi = griddata(x,y,z,xi,yi,interp='linear')
  --error--
  In [158]: debug
  > 
/home/pi/usr/local/lib/python2.6/site-packages/matplotlib/mlab.py(2780)griddata()
 2779 if dx.max()-dx.min() > epsx or
  dy.max()-dy.min() > epsy:
  -> 2780 raise ValueError("output grid must have
  constant spacing"
 2781  " when using
  interp='linear'")
  
  ipdb> dx.ptp()
  1.1368683772161603e-13
  ipdb> epsx
  1.0001e-15
  ipdb> 

I believe that this has to do with the limited precision and
non-uniformity of the possible numbers represented by the
floating point standard. The check for constant spacing likely
should take into account and compare dx.ptp() to the average dx
itself, or something like that.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
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] WYSIWYG figure

2012-01-11 Thread Paul Ivanov
Hi Petro,

Petro, on 2012-01-11 15:39,  wrote:
> Can I set a figure to appear on my screen in the same way as it is saved
> in png file?

You sure can. A likely reason these two don't appear the
same is that your 'figure.dpi' rcParam is not the same as the
'savefig.dpi' parameter. The same may apply to 'figure.facecolor'
and 'figure.edgecolor' and their savefig counterparts.

Another reason might be that you're using a tiling window
manager. I use xmonad, and it will resize figures so that they
all fit on the screen without overlap, and since I put the call
to plt.show() *after* savefig, the figures get saved as whatever
size they were originally created as, but then show up as
whatever space they can fit into given that my window manager
resized them. You can resize them back, assuming that 'f' is the
Figure instance, using something like:

f.set_size_inches(plt.rcParams['figure.figsize'], forward=True)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Grid problem?

2012-01-18 Thread Paul Ivanov
Hi David,

David Perlman, on 2012-01-06 16:57,  wrote:
> Am I doing this wrong?  I am doing the best I can to follow the
> documentation exactly.

It doesn't look like you're doing it wrong - and your example
works for me, though I'm not running OS X and can't verify that
it works as it should on your chosen backend.

Can anyone else who has OS X verify David's error? David, it'd be
useful to know what your matplotlib.__version__ is, as well as
whether or not the error occurs on the latest version, if that's
possible.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Eye patterns (Heat plot?)

2012-01-23 Thread Paul Ivanov
Hi Russ,

Russ Dill, on 2012-01-21 13:30,  wrote:
> I'm using matplotlib from pylab to generate eye patterns for signal
> simulations. My output pretty much looks like this:
> 
> http://www.flickr.com/photos/31208937@N06/6079131690/
> 
> Its pretty useful as it allows one to quickly see the size of the eye
> opening, the maximum/minimum voltage, etc. I'd really like to be able
> to create a heat diagram, like these:
> 
> http://www.lecroy.com/images/oscilloscope/series/waveexpert/opening-spread2_lg.jpg
> http://www.lecroy.com/images/oscilloscope/series/waveexpert/opening-spread1_lg.jpg
> http://www.iec.org/newsletter/august07_2/imgs/bb2_fig_1.gif
> http://www.altera.com/devices/fpga/stratix-fpgas/stratix-ii/stratix-ii-gx/images/s2gx-rollout-6g-eye.jpg
> 
> Is there any way within matplotlib to do that right now?

the quick and dirty way to get close to what you want is to add
an alpha value to the lines you're already plotting. Here's a
small example:

  x = np.arange(0,3,.01)
  y = np.sin(x**2)
  all_x,all_y = [],[]
  ax = plt.gca()
  for i in range(100):
  noisex = np.random.randn(1)*.04
  noisey = (np.random.randn(x.shape[0])*.2)**3
  ax.plot(x+noisex,y+noisey, color='b', alpha=.01)
  all_x.append(x+noisex)
  all_y.append(y+noisey)

To get a heat diagram, as was suggested, you can use a 2d
histogram.

  plt.figure()
  all_x =np.array(all_x)
  all_y = np.array(all_y)
  all_x.shape = all_y.shape = -1
  H, yedges, xedges = np.histogram2d(all_y, all_x, bins=100)
  extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
  ax = plt.gca()
  plt.hot()
  ax.imshow(H, extent=extent, interpolation='nearest')
  ax.invert_yaxis()

I'm attaching the two images for reference

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<><>--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot_date() runtime error

2012-01-26 Thread Paul Ivanov
Hi Shankar,

Shankararaman Ramakrishnan, on 2012-01-26 18:24,  wrote:
> I have been trying to leverage plot_date() to generate time trends. I
> seem to run into the following runtime error and don't have much
> insight as to why this is happening. Specifically, I don't quite see why
> the function is attempting to set the lower bound to 0001-01-01 UTC when
> my x-axis starts only from day number 729390. 

I suspect this may be the case because you've already plotted
something on this axis that resolves to this early date. For
example, I can reproduce an error similar to yours by first doing
plot(1,0) before the plot_date call.

Can you try to create a new figure just before the call to plot_date?

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] (no subject)

2012-01-28 Thread Paul Ivanov
Paul Hobson, on 2012-01-28 23:21,  wrote:
> There is undoubtedly a more efficient way to do this, but give this a shot:
> 
> import numpy as np
> import matplotlib.pyplot as plt
> 
> x = np.arange(0, 10.5, 0.5)
> y = -3.0*x + 0.5*x**2
> 
> color_list = ['FireBrick', 'Orange', 'DarkGreen', 'DarkBlue', 'Indigo']
> limits = np.arange(0, 11, 2)
> fig, ax1 = plt.subplots()
> for n, color in enumerate(color_list):
> lower = np.where(x >= limits[n])[0]
> upper = np.where(x <= limits[n+1])[0]
> index = np.intersect1d(lower, upper)
> ax1.plot(x[index], y[index], linestyle='-', color=color, linewidth=2)

Another way (if you're ok with only coloring the markers) would
be to use ax1.scatter(x,y,c=colorlist) where the length of all
three arguments is the same. Scatter can do that with the size of
the markers by passing the s= argument.
 
best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How matplotlib got me a job

2012-02-06 Thread Paul Ivanov
Benjamin Root, on 2012-02-06 13:59,  wrote:
> Alternate title: "How I finally convinced my Dad that open-source can put
> food on the table". Since this entire story got started on this mailing
> list, I figured it would be appropriate to end it here.
> 
> Last Friday, I signed a contract to begin working as a "Senior Scientific
> Programmer" for a research company.   

Congrats on the new job, Ben! Great story, I could say that it
had me "Root-ing" for you - but that would make you groan from
the number of times you've probably heard it before, so I'm not
gonna do that ;)

> Lastly, a reminder to everyone on this list, I hope this encourages more of
> you to help each other out with answers.  You never know if the person you
> help out is your future co-worker!

Hope this doesn't mean you'll be posting less, now :)

I want to second Ben's comments: I learned (and continue to
learn) quite a bit about matplotlib by trying to answer the
questions others have (with my trusty IPython tab-completion, and
when necessary, doing what every Python Jedi does, and use the
Source) - and by following along with the answers others provide.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Switch graphs

2012-02-07 Thread Paul Ivanov
Hi Phil,

phils, on 2012-02-04 07:41,  wrote:
> Newbie to using matplotlib

welcome to the party :)
 
> Is it possible to use wx and have a window with say 2 buttons on where when
> clicking on either button a different graph will appear using a different
> data set. Any examples?

Yes, it's possible. Here's a modified version of
examples/event_handling/keypress_demo.py which toggles between
two different axes when you press the 'w' key on your keyboard:
one has green points connected by dashed lines, the other with
multi-colored multi-sized scatter data.

import numpy as np
import matplotlib.pyplot as plt

plt.close('all')
def press(event):
print('press', event.key)
if event.key=='w':
visible = ax.get_visible()
ax.set_visible(not visible)
ax2.set_visible(visible)
fig.canvas.draw()

fig = plt.figure()
ax = fig.add_axes([.1,.1,.8,.8], label='one')
ax2 = fig.add_axes([.1,.1,.8,.8], label='two')
ax2.set_visible(False)

fig.canvas.mpl_connect('key_press_event', press)

ax.plot(np.random.rand(12), np.random.rand(12), 'go--')
ax2.scatter(100*np.random.rand(12), 100*np.random.rand(12),
c=np.random.rand(12), s=np.random.rand(12)*100)

plt.show()


I don't want to take away all of your fun, so have a look at
adding (mouse clickable) buttons to this using either
examples/widgets/buttons.py or examples/widgets/radio_buttons.py
- depending on your preference.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Change xaxis labels

2012-02-07 Thread Paul Ivanov
C M, on 2012-02-06 09:33,  wrote:
> On Mon, Feb 6, 2012 at 9:23 AM, David Craig  wrote:
> 
> > Hi, I have a plot and the xaxis shows number of seconds after a start
> > point. I would like to convert them to days anyone know how to do this.
> > I have looked at the documentation but cant find what I need.
> 
> Couldn't you divide your data points by the conversion (86400) before
> plotting?  E.g., 432,000 seconds then becomes 5 days.

Another way to do this is to change the Formatter which generates
what the labels of each tick out to be to do this computation.

Take a look at this example:
http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html

Just define something like:

def your_function(x,pos=None):
return "%d days" % (x/86400)

ax.xaxis.set_major_formatter(ticker.FuncFormatter(your_function))

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Partial coloring of text in matplotlib

2012-02-07 Thread Paul Ivanov
Benjamin Root, on 2012-02-07 13:46,  wrote:
> Also, how deep should this rabbit hole go?  I could imagine one could want
> this for title() and figtitle().  Maybe it would be best to implement this
> at the Text() constructor level?

For this reason, I would discourage even implementing such
functionality in the core of matplotlib. This functionality doesn't strike me
as something that ought to be available everywhere by default - if someone
needs it, they can implement it as follows:

-
import matplotlib.pyplot as plt
from matplotlib import transforms

def rainbow_text(x,y,ls,lc,**kw):
"""
Take a list of strings ``ls`` and colors ``lc`` and place them next to each
other, with text ls[i] being shown in color lc[i].

This example shows how to do both vertical and horizontal text, and will
pass all keyword arguments to plt.text, so you can set the font size,
family, etc.
"""
t = plt.gca().transData
fig = plt.gcf()
plt.show()

#horizontal version
for s,c in zip(ls,lc):
text = plt.text(x,y," "+s+" ",color=c, transform=t, **kw)
text.draw(fig.canvas.get_renderer())
ex = text.get_window_extent()
t = transforms.offset_copy(text._transform, x=ex.width, units='dots')

#vertical version
for s,c in zip(ls,lc):
text = plt.text(x,y," "+s+" ",color=c, transform=t,
rotation=90,va='bottom',ha='center',**kw)
text.draw(fig.canvas.get_renderer())
ex = text.get_window_extent()
t = transforms.offset_copy(text._transform, y=ex.height, units='dots')


plt.figure()
rainbow_text(0.5,0.5,"all unicorns poop rainbows ! ! !".split(), 
['red', 'orange', 'brown', 'green', 'blue', 'purple', 'black'],
size=40)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How matplotlib got me a job

2012-02-08 Thread Paul Ivanov
Patrick Marsh, on 2012-02-07 13:58,  wrote:
> As I continue to mature as a Python person, I want to give back
> explicitly to the community that's given so much to me. The problem
> is, I don't know how. I'm intimidated by the awesomeness of what I see
> being done around me that I don't even know where to begin. How does
> one even begin to learn how to understand the deep intricacies of MPL,
> Numpy, and Scipy so that I'd begin to develop a comfort level that
> would allow me to begin to actively contribute? I know pretty much
> everyone on these listservs, including myself, is busy. (I'm in the
> midst of a 30-day PhD General Exam, and probably shouldn't even be
> reading the listservs and/or typing this email! *wink*) But if there
> are those out there that are willing to take a little time and invest
> in me, and I'm sure there are others like me, I'd gladly become an
> active contributor instead of a lurker.

One simple, minimally intimidating way to contribute is by making
improvements to the documentation. Here's a relevant pitch I just
made on the IPython lists about how easy, yet valuable such
improvements can be.

http://mail.scipy.org/pipermail/ipython-user/2012-February/009428.html

Another would be to send the colleagues whom your helping here to
these lists, that way any effort you put in to help them has a
good chance of helping others, thanks to search engines and
archives.

Yet another would be to go through some the active issues on the
tracker and trying to make a test for them. 

Yet another still would be to test the various active pull
requests - and confirm that the fixes or new functionality they
provide actually work - look through patches and ask questions -
we have a lot PRs that get very few eyes or comments on them
(Last [academic] year, I consciously made an effort to be more
active on this list, and though I haven't pitched in as much
lately, perhaps the rest of this year I should focus my efforts
on incoming PRs)
 
> Anyways, I know this email is a tad on the long side, and a little off
> the original topic, so if you're still reading, thanks! This is
> something that's been weighing on me for a few months now, and I
> thought Ben's exultation of the benefits of the community might be a
> good time to open up.

I'm still rather enjoying this whole thread, thanks for opening
up. I got worried how relatively quiet it's been here for a few
months, and glad we're starting to buck that trend.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Figure zoom crosshair color

2012-11-13 Thread Paul Ivanov
On Tue, Nov 13, 2012 at 8:38 AM, David Brunell  wrote:

> Hello, I have what I hope is a simple question.  When producing a
> figure/plot, I have a window which pops up with the figure inside and a few
> tool buttons along the bottom, including "Zoom to rectangle."  Clicking the
> Zoom tool button, I'm presented with a black crosshair to select my zoom
> rectangle.  Many of the images I work with are predominantly black; is
> there any way to change the color of the crosshair so as to make it more
> visible?  Thanks.


Hi David,

Unfortunately, those widgets are backend specific, so changing them is not
trivial in general, since each toolkit has its own way of specifying the
cursor. With that said, you can try to figure out if there's a way to do it
for your backend `import matplotlib as mpl; mpl.get_backend()` will tell
you which backend you're using, and then you'll need to look in the
relevant source code for where the cursor is define.

If you don't know where your matplotlib code lives, you can the path of the
relevant files using this:

  import matplotlib.backends as b
  import os
  os.path.dirname(b.__file__)

There, you'll find files for all of the backends, and the `cursord`
dictionary in most of them is what specifies how the widgets look. I'm not
sure which toolkits allow one to change the color of the default cursors,
but some of them allow you to even specify your own color images, so it
should be possible.

An alternative, of course, would be to change the colormap you're plotting
with, or add an alpha value to the images you're plotting so that the black
widgets can be seen. Maybe it's inelegant, but looks like the path of least
resistance...

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Figure zoom crosshair color

2012-11-15 Thread Paul Ivanov
On Thu, Nov 15, 2012 at 3:24 PM, David Brunell  wrote:

> Hello Paul,
>
> Thanks so much for your carefully-crafted reply.  I had a hunch that it
> would not be a simple matter.  I'm using wxAgg for the backend.
>
> I ended up using a Matplotlib widget cursor like this:
> cursor = Cursor(ax, useblit=True, color='red', alpha = 0.5, linestyle =
> '-', linewidth=1)
>
> It does not do exactly what I want, but it's cleaner than hacking into the
> backend.
>

This is, of course, a perfectly legitimate solution, so I hope you don't
mind me forwarding the correspondence to the list for posterity.


> Again, thanks for your help.
>

Happy to be helpful,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Varying alpha in ListedColormap not working

2012-12-05 Thread Paul Ivanov
On Wed, Dec 5, 2012 at 2:36 PM, Oliver King  wrote:
> What appears to be happening is that the alpha values in the cmap I use when 
> I create the ListedColormap object are being ignored by the add_collection 
> function. I see that this bug (or something quite like it) was reported in 
> late 2008:
> http://matplotlib.1069221.n5.nabble.com/create-ListedColormap-with-different-alpha-values-tt18693.html#a18697
>
> Did the patch from late 2008 not make it into the code, or has this bug 
> resurfaced? Does anyone know of a workaround for this issue?

It's all a blur now, but I don't think that patch made it in because
colormaps were inherently RGB not RGBA.

Something similar to that patch was merged in a year ago:
https://github.com/matplotlib/matplotlib/pull/660 and attached is the
result of running your code on my machine.

What is your matplotlib.__version__ ? I think that code only made it's
way into v1.2.0 (the latest stable), and was did not make it into
v1.1.1 (or anything before it)

--
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
<>--
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] help, installing matplotlib on mac 10.8

2013-04-21 Thread Paul Ivanov
Hi Charles,

I'm sending my reply to the matplotlib-users list - please follow
up there, so that others benefit from your experience, or folks
who have run into the same issue can also pitch in with their
help. 

Here's where to go to sign up: 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Once you're signed up, you hit "reply all" to this email (it
would be kind of you to remove my name from the addressee list
when you do that, so that the email goes only to the
matplotlib-users list, of which I'm a member)

See the rest of my reply below your original message.

cnyaig...@gmail.com, on 2013-04-21 09:43,  wrote:
> Hello Paul
> 
> I wished to use matplotlip, but I am facing diffuculties and I
> was wondering if you can help.
> 
> Matplot lib is installed but pylab has the following error. I
> will appreciate a suggestion if you have some please
> 
> Charles
> 
> 
> 
> >>> import numpy as np
> >>> import pylab as pl
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pylab.py",
>  line 1, in 
> from matplotlib.pylab import *
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pylab.py",
>  line 222, in 
> from matplotlib import mpl  # pulls in most modules
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl.py",
>  line 1, in 
> from matplotlib import artist
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py",
>  line 7, in 
> from transforms import Bbox, IdentityTransform, TransformedBbox, \
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py",
>  line 35, in 
> from matplotlib._path import (affine_transform, 
> count_bboxes_overlapping_bbox,
> ImportError: 
> dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so,
>  2): no suitable image found.  Did find:
>   
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so:
>  no matching architecture in universal wrapper

This looks like conflicting versions of python are being used (64
bit and 32 bit). One trick for getting to the bottom of Python
stack traces is to take the text of the *last* line of the
traceback, remove all but the last few bits of the file path
(since other folks won't necessarily be installing to the extact
path you've installeed to), and feed it to google. 

The first google hit for "_path.so: no matching architecture in
universal wrapper" is this stackoverflow post:
http://stackoverflow.com/questions/5419439/matplotlib-pyplot-on-os-x-with-64-bit-python-from-python-org

See if the solution suggested there (installing 32-bit version
from python.org)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] another example of gradient color lines

2013-04-22 Thread Paul Ivanov
Hey everyone,

Over on IRC (#scipy channel on freenode), Baribal asked this:

  I'm computing a dendrite on a continuous surface ([0,
 1[, [0, 1[) and want to visualize it. What module would you
 recommend? In practice, I need to draw lines from x_1/y_1 to
 x_2/y_2 with a color gradient applied.

And further specified that the this is just for straight lines,
and each point also has an RGB value associated with it.

I coded up a solution (plot_gradient_rbg_pairs), and thought I'd
share it here. I've also posted it to a gist, in case I end up
updating it later. https://gist.github.com/5439438

#!/usr/bin/env python
"""A quick hack to draw gradient lines using a colormap.

This was written in response to 's question on IRC.

There are two functions provided here:

`plot_gradient_hack` takes two arguments, p0 and p1, which are both (x,y)
pairs, and plots a gradient between them that spans the full colormap.

`plot_gradient_rbg_pairs` does the same thing, but also takes rgb0 and rgb1
arguments, makes a new colormap that spans between those two values, and uses
that colormap for the plot.

There's an alternative solution over here [1], but that uses many more points.

1.  
http://matplotlib.1069221.n5.nabble.com/Gradient-color-on-a-line-plot-td17643.html
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.colors import LinearSegmentedColormap

def plot_gradient_hack( p0, p1, npts=20, cmap=None, **kw):
"""
Draw a gradient between p0 and p1 using a colormap

The **kw dictionary gets passed to plt.plot, so things like linestyle,
linewidth, labels, etc can be modified directly.
"""
x_1, y_1 = p0
x_2, y_2 = p1

X = np.linspace(x_1, x_2, npts)
Xs = X[:-1]
Xf = X[1:]
Xpairs = zip(Xs, Xf)

Y = np.linspace(y_1, y_2, npts)
Ys = Y[:-1]
Yf = Y[1:]
Ypairs = zip(Ys, Yf)

C = np.linspace(0,1, npts)
cmap = plt.get_cmap(cmap)
# the simplest way of doing this is to just do the following:
for x, y, c in zip(Xpairs, Ypairs, C):
plt.plot(x, y, '-', c=cmap(c), **kw)

# But for cases when that  will be too slow, you can make this go faster,
# follow along with this example:
# http://matplotlib.org/examples/pylab_examples/line_collection2.html


def plot_gradient_rbg_pairs(p0, p1, rgb0, rgb1, **kw):
"""Form the gradient from RGB values at each point


The **kw dictionary gets passed to plt.plot, so things like linestyle,
linewidth, labels, etc can be modified directly.
"""
cmap = LinearSegmentedColormap.from_list('tmp', (rgb0, rgb1))
plot_gradient_hack(p0, p1, cmap=cmap, **kw)

# plot gradient that just spans the full colormap
plot_gradient_hack( (1,2), (5,6) )

# we can specify the colormap, and set some properties for the plot
plot_gradient_hack( (2,5), (5,3), cmap='bwr', linewidth=3.)

# We also have a simple wrapper to specify the two rgb points to interpolate
# the gradient between
plot_gradient_rbg_pairs( (1.1,2), (5.1,6), (0,0,0), (1,1,1) ) # black to white
plot_gradient_rbg_pairs( (1.2,2), (5.2,6), (0,0,0), (0,0,1),  # black to blue
 linestyle='--', linewidth=9) 
plot_gradient_rbg_pairs( (1.3,2), (5.3,6), (1,0,0), (0,1,0),  # red to green
 linewidth=4 )

plt.show()

# we can use this gradient plot to display all colormaps on one plot easily
plt.figure()
with matplotlib.rc_context({'lines.solid_capstyle':'butt'}):
# the default projecting capstyle looks kind of ugly. rc_context was
# introduced in matpltolib 1.2.0, if you are running a version older than
# that, you can ignore this line and remove one level of indentation from
# the for loop
for i, map_name in enumerate(plt.cm.cmap_d):
plot_gradient_hack((0, i), (1, i), cmap = map_name, linewidth=4)
plt.text(1,i, map_name, va='center')
# comment out this last line to plot all ~140 colormaps
if i==25: break
plt.show()

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] better way to change spine and ticklabel colors?

2010-06-07 Thread Paul Ivanov
Hi all,

I've really been enjoying matplotlib, but in getting my graphs to look just
the way I want, I find myself having to just through some hoops to get
there.

my question is: is there a better way of changing spine, tick, and
ticklabels colors?

Here's what I use right now:

[s.set_color(color) for s in ax.spines.values()]
[s.set_color(color) for s in ax.yaxis.get_ticklines()]
[s.set_color(color) for s in ax.xaxis.get_ticklines()]
[(s.set_color(color),s.set_size(8)) for s in ax.xaxis.get_ticklabels()]
[(s.set_color(color),s.set_size(8)) for s in ax.yaxis.get_ticklabels()]
ax.yaxis.grid(which='major',linestyle='-',color=color,alpha=.3)

I realize that I should probably set the rcParam equivalents before creating
ax. But once I have an axesSubplot ax, what's the best way to fiddle with
these parameters?

you can see a full example here:
http://pirsquared.org/blog/2010/06/07/ca-prop/

best,
Paul Ivanov

-- 
I only use the 314 gmail account for mailinglists. Please send off-list
personal correspondence to my initials (two letters) at berkeley dot edu.
--
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] Case stories of software including Matplotlib

2010-07-27 Thread Paul Ivanov
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tony S Yu, on 07/27/2010 11:53 AM, wrote:
> On Jul 27, 2010, at 1:31 PM, ms wrote:
>> On 27/07/10 15:05, Benjamin Root wrote:
>>> On Tue, Jul 27, 2010 at 6:01 AM, German Ocampo
 wrote:
>>>> Good morning
>>>>
>>>> Do you know where I could get examples of case stories about
>>>> commercial or open source software that has been developed using the
>>>> Matplotlib library?
>>>>
>>>> Many Thanks
>>>>
>>>> German
>>>>
>>> German,
>>>
>>> Interesting idea.  Might be something nice to add to the project page,
>>> maybe?
>>
>> I have no ready "case story" about it, but I developed and published a
>> MPL-based open source software here:
>>
>> http://code.google.com/p/hooke
>>
>> which has been presented in a peer-reviewed academic publication on
>> "Bioinformatics" (
>>
http://bioinformatics.oxfordjournals.org/cgi/content/abstract/btp180?ijkey=B9QGeobopuepKnZ&keytype=ref

>> )
>>
>> If you need information to build a "case story", ask me -perhaps I can
>> help you if it's not too much work.
>>
>> cheers,
>> M.
>
>
> German,
>
> You might be interested in CellProfiler Analyst
(http://www.cellprofiler.org/). Also, matplotlib is an optional
dependency for FiPy (http://www.ctcms.nist.gov/fipy/).
>
> Best,
> -Tony

German,

I've always loved the NASA JPL Mars mission story: see page 28 of this
talk[1] by Fernando Perez, I inlined the highlight below:

From: Name Elided 
Date: Oct 2, 2007 7:15 PM
Subject: Fwd: matplotlib bug numbers
To: John Hunter 

One of my lead developers mentioned that they had sent a bug to you
about the annotations feature of MatPlotLib. Would you be able to
let me know what the timeline is to resolve that bug? The reason is
that the feature is needed for the Phoenix project and their arrival
at Mars will be in March sometime, but they are doing their testing
in the coming few months.  This annotation feature is used on
reports that present the analysis of the trajectory to the
navigation team and it shows up on our schedule. It would really
help me to know approximately when it could be resolved.

[1] <http://fperez.org/talks/0904_parlab_scipy.pdf>

best,
Paul Ivanov
- -- 
I only use the 314 gmail account for mailinglists. Please send off-list
personal correspondence to my initials (two letters) at berkeley dot edu.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxPNloACgkQe+cmRQ8+KPelJACfVPTUXgceOEHeimYnKHbzN5o1
HzwAnjb7kcEUdC7w1m/tE0qhAemd8xL8
=75vU
-END PGP SIGNATURE-

--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] aligning multiple legends

2010-09-06 Thread Paul Ivanov
I want to have two legends (from different axes) positioned right up
against on another.

Here's a static example, except I want the second legend to be defined
relative to the first (if leg is moved, I want leg2 to move as well). I
can't seem to figure out the proper bbox_to_anchor and bbox_transform
parameters to pass to the second legend() to make this work.

# small example
ax = plt.subplot(1,1,1)
ax2 = ax.twinx()
ax.plot([0,1], label='ax1')
ax2.plot([1,0], 'r--',label='ax2')
leg = ax.legend(loc='lower left', borderaxespad=0,
bbox_to_anchor=(.85,.85))
leg2 = ax2.legend(loc='upper left', borderaxespad=0,
    bbox_to_anchor=(.85,.85))

thanks in advance,
Paul Ivanov

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

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


Re: [Matplotlib-users] aligning multiple legends

2010-09-06 Thread Paul Ivanov
Paul Ivanov, on 2010-09-06 18:01, wrote:
> I want to have two legends (from different axes) positioned right up
> against on another.
> 
> Here's a static example, except I want the second legend to be defined
> relative to the first (if leg is moved, I want leg2 to move as well). I
> can't seem to figure out the proper bbox_to_anchor and bbox_transform
> parameters to pass to the second legend() to make this work.
> 
> # small example
> ax = plt.subplot(1,1,1)
> ax2 = ax.twinx()
> ax.plot([0,1], label='ax1')
> ax2.plot([1,0], 'r--',label='ax2')
> leg = ax.legend(loc='lower left', borderaxespad=0,
>   bbox_to_anchor=(.85,.85))
> leg2 = ax2.legend(loc='upper left', borderaxespad=0,
>   bbox_to_anchor=(.85,.85))
> 

I guess I really just want one legend, so I figured out an alternative
solution:

# alternative to having two legends
ax = plt.subplot(1,1,1)
ax2 = ax.twinx()
lines=  ax.plot([0,1], label='ax1')
lines2= ax2.plot([4,3], 'r--',label='ax2')
lines.extend(lines2)
labels = [l.get_label() for l in lines]
leg = ax.legend(lines, labels)

Is this a reasonable way of achieving the desired result?

thanks,
Paul

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

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


[Matplotlib-users] closing figure inside a callback seg faults

2010-10-15 Thread Paul Ivanov
I want to do something like this:

  import matplotlib.pyplot as plt
  def onclick(event):
  if event.button==1:
plt.close()
  fig = plt.gcf()
  cid = fig.canvas.mpl_connect('button_press_event', onclick)
  plt.show()

I've tried several variations on this theme, but all of them cause
crashes. Am I missing something?

I'm using 1.0.0 with WXAgg

thanks,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
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] unwanted label clipping in gallery

2010-10-27 Thread Paul Ivanov
Alan G Isaac, on 2010-10-27 18:31,  wrote:
> Here is another example of unwanted text clipping
> in the gallery:
> http://matplotlib.sourceforge.net/examples/api/two_scales.html#api-two-scales
> (Both y axis labels are clipped.)
> 
> I also think the example would be more complete if it
> 1. set a 270 degree rotation on the second ylabel, and
> 2. showed how to make a single legend for the two lines
> 
> Btw, how *does* one best do 2?

I don't know if it's best, but legend can take a list of objects 
and labels, so you can just grab all of the objects from the twin,
and put them all in one legend:

  def onelegend_twinaxes(axis,twin):
  #make a joint axis legend
  lines = twin.get_lines()
  lines.extend(axis.get_lines())
  labels = [l.get_label() for l in lines]
  return axis.legend(lines, labels)

Here's a picture of what that looks like (thought I did some
other prettifications).
<http://pirsquared.org/images/twinaxes_onelegend.png>

I wrote this in a solution set for a class I'm TAing this
semester, so you can look at the whole thing here, if you'd like.
the file is part of the solutions for Lab #1, it's called lab1.py
(but actually links to lab1.txt):
<http://redwood.berkeley.edu/wiki/VS265:_Homework_assignments>
 
-- 
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


Re: [Matplotlib-users] unwanted label clipping in gallery

2010-10-29 Thread Paul Ivanov
Alan G Isaac, on 2010-10-28 21:29,  wrote:
> On 10/27/2010 8:21 PM, Paul Ivanov wrote:
> >def onelegend_twinaxes(axis,twin):
> >#make a joint axis legend
> >lines = twin.get_lines()
> >lines.extend(axis.get_lines())
> >labels = [l.get_label() for l in lines]
> >return axis.legend(lines, labels)
> 
> That works.
> 
> > <http://redwood.berkeley.edu/wiki/VS265:_Homework_assignments>
> 
> Cool.  What proportion of the students choose Python?

This is the first time that Python's been officially encouraged,
and it's been about 1 in 6.

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


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

2010-10-29 Thread Paul Ivanov
Daniel Hyams, on 2010-10-29 17:07,  wrote:
> 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.

I think you can just get what you want using:

  plt.plot([3,1,4,1,5,9,2,6,5], label='awesome')
  plt.legend(bbox_to_anchor=(1,1),loc=2)

where loc=2 could have also been written as loc='upper left'

> 
> Ascii art is fun! :)

Indeed!

P.S.
Your posts made it to this and the devel list - they
(frustratingly) don't send you your own copy back when you post
something. I usually verify that the post went through my
checking gmane or sourceforge archives.

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


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

2010-10-29 Thread Paul Ivanov
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


Re: [Matplotlib-users] One legend, two axes?

2010-12-15 Thread Paul Ivanov
Skip Montanaro, on 2010-12-15 12:49,  wrote:
> > Skip,You can call figlegend() and build a legend for the figure,
> > irrespectively of any axes.
> 
> Thanks.  Sounds like exactly what I need.

Hi Skip,
I just wanted to chime in and give you a concrete example of how
you can get all of the line instances from one axes and include
them in the legend of another, or in a figlegend:

  ax = plt.subplot(1,2,1) 
  ax2 = plt.subplot(1,2,2) 
  ax.plot([0,1], label='ax1') 
  ax2.plot([4,3], 'r--',label='ax2') 
  lines =ax.get_lines()
  lines.extend(ax2.get_lines())
  labels = [l.get_label() for l in lines] 
  leg = ax.legend(lines, labels)
  # or, alternatively...
  leg2 = plt.figlegend(lines,labels,loc='center')


this is a slight revision to what was previously discussed here:
<http://old.nabble.com/aligning-multiple-legends-td29638901.html>

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] starting with pplots

2010-12-22 Thread Paul Ivanov
Pawel, on 2010-12-18 20:04,  wrote:
> Hi,
> 
> I am a new user of matplotlib so maybe my question is elementary, but 
> have not been able to find an answer to my problem in the archive.
> 
> I would like to make a 2D plot of colored points of 3D data (clusters). 
> My data looks like this:
> 
> 11837.2120-0.08582.
> 23975.2120-0.06722.
> 37609.2120-0.03062.
> 53263.9800-0.06902.
> 72106.67600.2708 1.
> 92674.6760-0.01293.
> 116758.676-0.12453.
> ...
> 
> So I need to plot the first and second column as points on the x-y axis 
> and color the points according to the numbers in the third column (which 
> are integers ranging from 1 to5).
> 
> I'd appreciate any help. I realize something so typical should be 
> somewhere in the documentation but I was not able to find it.

Hi Paul,
welcome to matplotlib! So you need to read in those columns
somehow (as numpy arrays, or lists), but once you've got that,
it's just a matter of initiating a 3d plot, and calling scatter
with the three columns.

take a look at this example and it's source code:
http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html#scatter-plots

for your purposes, the code will be something like:

  from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot as plt
  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  ax.scatter(x,y,z)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bug with twinx and scientific style

2010-12-23 Thread Paul Ivanov
Václav Šmilauer, on 2010-12-23 14:51,  wrote:
> Hi there,
> 
> when I use twinx() to have y1 and y2 axes and set ticklabel_format
> style to 'sci' on the y2 axis, ticks on the y2 are properly numbered,
> but the "1e-5" that is supposed to be atop y2 appears on the top of
> y1 instead. When both y1 and y2 use the exponents, they overwrite
> each other -- a minimal example (result attached in pdf):
> 
> import pylab
> 
> pylab.plot([0,1e-2,2e-2,3e-2],[1e3,5e3,6.1e3,1e3],'g-')
> 
> pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both')  # this is 
> not necessary to show the bug
> 
> pylab.twinx()
> 
> pylab.plot([1e-2,2e-2,3e-2,4e-2],[2e-5,3e-5,0,-1e-5],'r-')
> 
> pylab.ticklabel_format(style='sci',scilimits=(0,0),axis='both')   # makes 
> 1e-5 appear on the left instead of on the right
> 
> pylab.show()
> 
Hi Václav,

thanks for the bug report. As a temporary workaround - use 

plt.gca().yaxis.set_offset_position('right')

Committers: the patch attached fixes this problem. I thought that
there might be a similar problem for twiny() - but ax.xaxis does
not appear to have .set_offset_position() method.
 
> I've had this issue with versions .99, 1.0.0, running on Linux
> (Ubuntu, versions 9.04 through to 10.10).

me too, and I kept forgetting to report it.

> PS. what's wrong with the sf.net bugzilla? I was not able to post the
> issue there --

this I do not know.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
Index: CHANGELOG
===
--- CHANGELOG	(revision 8845)
+++ CHANGELOG	(working copy)
@@ -1,3 +1,5 @@
+2010-12-23 Fixed twinx scientific notation offset being misplaced
+
 2010-11-22 Fixed error with Hammer projection. - BVR
 
 2010-11-12 Fixed the placement and angle of axis labels in 3D plots. - BVR
Index: lib/matplotlib/axes.py
===
--- lib/matplotlib/axes.py	(revision 8845)
+++ lib/matplotlib/axes.py	(working copy)
@@ -7391,6 +7391,7 @@
 frameon=False)
 ax2.yaxis.tick_right()
 ax2.yaxis.set_label_position('right')
+ax2.yaxis.set_offset_position('right')
 self.yaxis.tick_left()
 ax2.xaxis.set_visible(False)
 return ax2
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ODP: starting with pplots

2010-12-23 Thread Paul Ivanov
Pawel Janowski, on 2010-12-23 10:09,  wrote:
> Hi Pavel,
> 
> Thanks for your help. Matplotlib seems to be a really cool tool. Your
> response almost answered my question. What I want is for the 3D plot to be
> 2D. I mean the z-axis can only take on 5 discreet values so I don't want to
> visualize 3 dimensions but just two with the data points colored five
> different colors depending on the z value. 

Pawel,

(I'm replying back to the list, so that others may benefit -
hello there, search engine visitors from the future!)

In that case, you can either follow Goya's suggestion - if you
only want to draw points. scatter will actually rescale the color
values you give to whatever colormap you're using - and for your
case, with just five z values in range(1,6), I found a slight
tweak to the 'hsv' colormap does the trick.

  from numpy.random import rand, randint
  import matplotlib.pyplot as plt
  x,y = rand(2,100)
  z = randint(1,6,100)
  plt.scatter(x,y,c=z, vmin=-1, cmap=plt.get_cmap('hsv'))

You can see the built-in colormaps here:
http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html

and as Goyo showed, it's pretty easy to make a new one.

If you want more control, such as changing the shape of the
marker, not just the color, or if there's some order to your points
that you want to also see (for example, draw lines between points
of the same z value) - you can use a boolean mask. 

  from numpy.random import rand, randint
  import matplotlib.pyplot as plt
  x,y = rand(2,100)
  z = randint(1,6,100)
  for i,c,m in zip(range(1,6),'rgbmk', 'odp*s'):
  mask = z==i
  plt.plot(x[mask],y[mask], color=c, marker=m)

hope that helps,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] manipulating histogram data from hist function

2010-12-27 Thread Paul Ivanov
Philippe Piot, on 2010-12-27 13:58,  wrote:
> 1/  When executing the above script, I also display the histograms
> generated when invoking "hist" (I tried to make this line tranparaent
> by using alpha=0 but it did not work).

Hi Philippe,

welcome to matplotlib - I think what you really want to do is
just use numpy's histogram function, and then plot the result.
This is actually the function matplotlib's hist uses behind the
scenes.

> 2/ can I directly manipulate the data within an histogram to
> arbitrarily offset the histogram?

Once you get the histogram using numpy, you can plot it in in any
way you want. Here's a small example:

  import numpy as np
  import matplotlib.pyplot as plt
  h,edges = np.histogram(np.random.randn(1000))
  plt.bar(edges[:-1],h, width=edges[1]-edges[0])
  plt.bar(edges[:-1]-10,h, width=edges[1]-edges[0]) #offset
  plt.step(edges[1:],h) # plot as step lines instead of bars
  plt.step(edges[1:]+10,h) # same as above, with an offset

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Drawing a circle around a letter

2010-12-28 Thread Paul Ivanov
Nathann Cohen, on 2010-12-26 22:27,  wrote:
> Hello everybody !!!
> 
> When adding some text to a plot, is there a way to know the actual
> size of the letters as they appear, in such a way that I could, for
> instance, draw a circle around a 'A', so that the A perfectly fits
> inside ("the smallest circle containing the letter"), regardless of
> the actual size of the picture I'm drawing ?

Hi Nathann,

Here's a quick and dirty way of getting what you want:

  import matplotlib.pyplot as plt
  import numpy as np
  ax = plt.subplot(111)
  t = plt.text(0.5,0.5,'A', ha='center', va='center')
  plt.draw()
  b = t.get_window_extent() # bounding box in pixel coordinates
  r = np.sqrt((b.bounds[-2]/2)**2 + (b.bounds[-1]/2)**2)
  plt.scatter(0.5,0.5, s=np.pi*r**2, marker='o', edgecolor='k', facecolor='w', 
lw=1,zorder=-1)

I don't think there's a super simple way of doing this by hand -
because text keeps its size constant regardless of how you
manipulate the axes. Here's an example that does what you want,
if you only need the circle in one particular view (i.e. if you
won't be rescaling/zooming in or out the axes:

  ax = plt.subplot(111)
  plt.plot([0,1,1],[0,0,1]) # keep the axes from resizing when we draw our 
circle
  t = plt.text(0.5,0.5,'A')
  plt.axis('equal')
  plt.draw()
  b = t.get_window_extent() # bounding box in pixel coordinates
  bbox = b.inverse_transformed(ax.transData)
  xc,yc = bbox.get_points().mean(0)
  r = np.sqrt((bbox.bounds[-2]/2)**2 + (bbox.bounds[-1]/2)**2)
  theta = np.linspace(0,2*np.pi,200)
  x,y = r*(np.cos(theta)), r*np.sin(theta)
  l = plt.plot(x+xc, y+yc)

This does exactly what you want, but now, anytime you resize the
axes, the A will stay the same size, but that circle will get
resized.

  ax = plt.subplot(111)
  plt.plot([0,1,1],[0,0,1]) # keep the axes from resizing when we draw our 
circle
  t = plt.text(0.5,0.5,'A')
  plt.axis('equal')
  plt.draw()
  b = t.get_window_extent() # bounding box in pixel coordinates
  bbox = b.inverse_transformed(ax.transAxes)
  xc,yc = bbox.get_points().mean(0)
  r = np.sqrt((bbox.bounds[-2]/2)**2 + (bbox.bounds[-1]/2)**2)
  theta = np.linspace(0,2*np.pi,200)
  x,y = r*(np.cos(theta)), r*np.sin(theta)
  l = plt.plot(x+xc, y+yc, transform=ax.transAxes)

The above will keep the circle from resizing when you move - but
now it prevents the circle from following 'A' as you pan around.

I see that matplotlib.collections (which is what plt.scatter
creates in the quick-and-dirty example) uses offset and
transOffset to get the job done, but I couldn't figure out a way
to get my last two examples to do something similar by just
manipulating the transforms. 

Hopefully someone chimes in with a better solution. For more on
transformations see:
http://matplotlib.sourceforge.net/users/transforms_tutorial.html

And you can wrap my hand-rolled solution nicely using something
like:
http://matplotlib.sourceforge.net/examples/api/line_with_text.html

best, 
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Control of thread/program not returning to ipython after creating a plot.

2010-12-31 Thread Paul Ivanov
On Fri, Dec 31, 2010 at 11:42 AM, Benjamin Root  wrote:
>
> On Sun, Dec 19, 2010 at 3:34 AM, Sylvain Munaut <246...@gmail.com> wrote:
>>
>> Hi,
>>
>> I was wondering if you ever found a solution to this problem ?
>>
>> I have the exact same issue with GTK (Agg or cairo) and WX backends
>> ... I'm also under gentoo using ipython-0.10.1 and matplotlib-1.0.0
>> I don't have the warnings you have but same behavior, I have to call
>> show (if I don't a blank 'frozen' window is all that appears) but then
>> the ipython doesn't have control anymore.
>>
>> Cheers,
>>
>>   Sylvain
>>
>
> It is very possible that this problem was fixed shortly after the 1.0.0 
> release.  Another possibility is that ipython might be causing an issue where 
> it is loading some older matplotlib codes before the rest of matplotlib 1.0.0 
> is loaded (I have seen this happen once).
>
> You can test for this theory by seeing if you have the same problem when 
> using the regular python shell.  If not, then it is likely to be a problem 
> with ipython.  If you do have the same problem in regular python, then the 
> problem is with matplotlib and you will need to build the latest from svn.
>
> Ben Root
>

If the issue was GTK only - it is a known problem with IPython 0.10.1
for which the fix is waiting to be merged here:

https://github.com/ipython/ipython/issues/issue/237

but if you think the WX backend is also affected - it might just be
that you're not starting ipython with the -pylab flag to get the
threading to work without blocking. Can you try starting "ipython
-pylab -gthread" and "ipython -pylab -wthread"  to see if that fixes
the issue? Make sure that you change the backend accordingly - and use
plt.get_backend() to ensure the appropriate one is being used.

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to make a grid of (plot) grids?

2011-01-03 Thread Paul Ivanov
Gf B, on 2011-01-03 15:23,  wrote:
> 
> Can such a "grid of grids" be done with matplotlib?  If so, could someone
> show me how?

Take a look at GridSpec - in particular:
http://matplotlib.sourceforge.net/users/gridspec.html#gridspec-using-subplotspec

You'll be able to group the inner grids visually by adjusting the
spacing.  As far as getting the spines to only outline the outer
grid, and not the inner grid - I think you'll have to do it
manually by hiding the appropriate spines for the inner subplots.
Have a look here for how to do that:
http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html

best
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to make a grid of (plot) grids?

2011-01-04 Thread Paul Ivanov
Gf B, on 2011-01-04 12:31,  wrote:
> On Mon, Jan 3, 2011 at 3:53 PM, Paul Ivanov  wrote:
> Gf B, on 2011-01-03 15:23,  wrote:
> > > Can such a "grid of grids" be done with matplotlib?  If so, could someone
> > > show me how?
> >
> >  You'll be able to group the inner grids visually by adjusting the
> > spacing.  As far as getting the spines to only outline the outer
> > grid, and not the inner grid - I think you'll have to do it
> > manually by hiding the appropriate spines for the inner subplots.
> >
> 
> This sort of ad-hoc manual tweaking is what I was hoping to avoid.
> 
> What would it take to implement a "true" grid-of-grids function in
> matplotlib?  What I mean by this is a function that can arrange in a grid
> not only plots but also other grids.  (Is this a question for the devel
> group?)

I think the true grid-of-grids functunality is already
implemented. Here's a replication of your Mathematica plots:


import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from itertools import product

def squiggle_xy(a, b, c, d, i=np.linspace(0.0, 2*np.pi, 200)):
return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d)

f = plt.figure(figsize=(8, 8))

# gridspec inside gridspec
outer_grid = gridspec.GridSpec(4, 4, wspace=0.0, hspace=0.0)
for i in xrange(16):
inner_grid = gridspec.GridSpecFromSubplotSpec(3, 3,
subplot_spec=outer_grid[i], wspace=0.0, hspace=0.0)
a, b = int(i/4)+1,i%4+1
for j, (c, d) in enumerate(product(range(1, 4), repeat=2)):
ax = plt.Subplot(f, inner_grid[j])
ax.plot(*squiggle_xy(a, b, c, d))
ax.set_xticks([])
ax.set_yticks([])
f.add_subplot(ax)

all_axes = f.get_axes()

#show only the outside spines
for ax in all_axes:
for sp in ax.spines.values():
sp.set_visible(False)
if ax.is_first_row():
ax.spines['top'].set_visible(True)
if ax.is_last_row():
ax.spines['bottom'].set_visible(True)
if ax.is_first_col():
ax.spines['left'].set_visible(True)
if ax.is_last_col():
ax.spines['right'].set_visible(True)

plt.show()


It's a matter of taste, but I think you can get away hiding all
spines, and just setting the hspace and wspace for the outer_grid
to some small value (this is what I meant by 'adjusting the
spacing').

I'll send a patch to the devel list shortly adding this example
with the following documentation 

A Complex Nested GridSpec using SubplotSpec
===
Here's a more sophisticated example of nested gridspect where we put
a box around outer 4x4 grid, by hiding appropriate spines in each of the
inner 3x3 grids. 

it'll be placed on the gridspec page, after this section:
http://matplotlib.sourceforge.net/users/gridspec.html#gridspec-using-subplotspec

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] defining a custom RGB colormap

2011-01-05 Thread Paul Ivanov
Michael Rawlins, on 2011-01-05 08:44,  wrote:
> How does one define a range of colors for a custom user-defined
> colormap?  I'm fairly new to matplotlib and have been using
> standard colormaps.  Below is a sample program that makes a
> color bar based on the hot colormap.  I'd like to have a
> colormap like hot, but that starts at, say, orange (near 14%),
> and runs to black (40%).
 
Hi Michael,

first a quick aside: your reversing of the colormap is
unnecessary - just change the colordict assignment line to be:

  colordict=cm.hot_r._segmentdata.copy()

and get rid of the two nested for loops. Or better still, get rid
of colordict altogether and just use

  maprev = cm.hot_r

Ok, as far as your question - I'm not certain that this is what
you're asking for - but if you want to construct a colormap that
"stretches" the portion of your plot that goes from 14 to 40
"percent" (as labeled), to be the entire range of a colormap -
use the following:

All colormaps take as input a value from 0.0-1.0, and give you
back an rgba tuple. You already have a normalization 'norm' in
there which maps an arbitrary interval (0-40 in your case) to the
0.0-1.0 interval. So you like the color value at 14 - let's find
out what the scalar value for 14 is, once it's mapped to the
0.0-1.0 interval.

In [68]: norm(14)
Out[68]: 0.34998

So that's the value we will pass to cm.hot_r to get the color at
14.  Let's verify that this is actually what's going on - I'll
create a new figure and plot just one big dot on there of what
should hopefully be the same color.

In [69]: f, ax = plt.subplots(1,1)
In [70]: plt.scatter(0,0,c=cm.hot_r(norm(14)),s=1000) # c is color, s is size
Out[70]: 

Ok, that looks good. We can repeat the procedure for the 40
"percent" case

In [89]: norm(40)
Out[89]: 1.0
In [90]: plt.scatter(0,0,c=cm.hot_r(norm(40)),s=1000)
Out[90]: 

No surprises there (it's black). Now let's create our own
segmented map. You can look at the documentation and an example:
http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap
http://matplotlib.sourceforge.net/examples/pylab_examples/custom_cmap.html

but a LinearSegmentedColormap just splits deals with the rgb
channels seperately, and for each color, defines transition
points in the 0.0-1.0 interval which are refered to as 'x' in the
links above, as well as the color to use before the transition
point ('y0'), and the color to use after the point ('y1'). Here's
a quote from the docs about this:

  Each row in the table for a given color is a sequence of x, y0,
  y1 tuples. In each sequence, x must increase monotonically from 0
  to 1. For any input value z falling between x[i] and x[i+1], the
  output value of a given color will be linearly interpolated
  between y1[i] and y0[i+1]:
  
row i:   x  y0  y1
   /
  /
row i+1: x  y0  y1
  
  Hence y0 in the first row and y1 in the last row are never used.

Armed with this knowledge, you can now use the color from
cm.hot_r(norm(14)) to get the entries for the first rows of your
new map (remember that you're doing red, green, and blue
seperately) - and then remap the remaining transition points (the
'x' portion of the tuple) to stretch portion of the colormap's
0.0-1.0 interval that you're interested in (i.e. map 0.345-1.0 to
0.0-1.0).

Now that's only if you want full control of the linear segments -
there's a quick and dirty way to get what you want by specifying
a ListedColormap using values taken from the colormap you're
using. I'll just get a whole bunch of values from the desired
interval of the colormap, map them through the colormap, and get
my new colormap out.

In [209]: vals = norm(np.linspace(14,40,1000))
In [210]: newcm = cm.colors.ListedColormap(cm.hot_r(vals))

Let's plot the original map (as in your email), and the new one
we created.

In [211]: f,(ax2,ax3) = plt.subplots(2,1)
In [212]: cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cm.hot_r,
   .:  norm=norm,
   .:  orientation='horizontal')
In [213]: cb2.set_label('"percent"')
In [214]: 
In [215]: cb3 = mpl.colorbar.ColorbarBase(ax3, cmap=newcm,
   .:  orientation='horizontal')
In [216]: cb3.set_label("colormap interval 0.0-1.0")
In [217]: plt.draw()


And to further clarify that we did the right thing, let's adjust
the xlim on that original plot.

In [221]: ax2.set_xlim(norm(14),norm(40))
Out[221]: (0.34998, 1.0)
In [222]: plt.draw()


Hope this clears things up,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Des

Re: [Matplotlib-users] semilogy

2011-01-05 Thread Paul Ivanov
Neal Becker, on 2011-01-05 08:19,  wrote:
> I want to plot semilogy with major and minor grid.  I tried:
> 
> plt.grid(which='both')
> 
> But 2 problems:
> 
> 1) For semilogy, most of my viewers will expect to see 10 minor
> ticks/major tick.  I got 5.  How do I change it?

Hi Neal,

odd, it works here. (See attached image)

In [1]: plt.semilogy(((np.random.rand(50)*9+1)))

If your problem persists, can you provide a small example where
this does not work?  You might check the minor locator -  make
sure that it is base 10

In [2]: plt.gca().yaxis.minor.locator._base
Out[2]: 10.0

> 2) I'd like the major ticks to be solid lines, and minor ticks
> to be dashed.  I got all dashed.

In [3]: plt.grid(which='major', linestyle='solid')
In [4]: plt.grid(which='minor', linestyle='dashed')

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<>

signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] defining a custom RGB colormap

2011-01-05 Thread Paul Ivanov
Michael Rawlins, on 2011-01-05 14:42,  wrote:
> Thanks for the detailed tutorial. I'm getting errors when I
> attempt to use plt.subplots(1,1) and the newcm assignment.
> 
> Traceback (most recent call last):
>   File "colorbar_Mytest2.py", line 17, in 
> f, ax = plt.subplots(1,1)
> AttributeError: 'module' object has no attribute 'subplots'

Ah, you must be using an older version of matplotlib - subplots
is a (recently added) convenience shortcut for:

  f = plt.figure()
  ax = plt.subplot(1,1,1)

It comes in handy when you're making lots of subplots by letting
you do it with one call, instead of doing that one by one (as I
have rewritten below, so you could run without having to upgrade
your matplotlib.

> Also, what does In and Out do, as in Out[68]: 0.34999?

That's just the prompts from IPython - I *highly* recommend using
IPython in place of the default python shell for interactive usage. 
In[10] is what I typed,  Out[10] is the result of my command at
In[10].

> Here are just a few of the errors I'm getting when executing
> colorbar command with newcm. 

> Here's a simplified version that works for me:

ouch! this code doesn't do quite what you want

> from pylab import *

Try to avoid doing this - because you will get unintended
consequences such as the one on the following line.
 
> vals = norm(np.linspace(14,40,1000))

This was meant to go *after* you initialize the 'norm' variable
with norm = mpl.colors.Normalize(...). That's the norm I
meant to be using. But because of the "from pylab import *" line,
the norm function from numpy was imported - which is what was being
used on that line as written in your code. 

so the vals=  line is equivalent to

  vals = numpy.norm(np.linspace(14,40,1000))

which meant vals got assigned the value 886.25397758173483, and
not at all what we wanted. We wanted it to get an array of 1000
numbers:

  vals = mpl.colors.Normalize(vmin=0, vmax=40)(np.linspace(14,40,1000))

That's where your trouble with newcm were coming from. Here's the
complete example again, I've renamed the 'norm' variable to
'rawlins_norm' for clarity.

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import cm 
import numpy as np

# Make a figure and axes with dimensions as desired.
fig = plt.figure(figsize=(8,3))
ax1 = plt.subplot(2,1,1)
ax2 = plt.subplot(2,1,2)

# Set the colormap and norm to correspond to the data for which
# the colorbar will be used.
rawlins_norm = mpl.colors.Normalize(vmin=0, vmax=40)   # here set colorbar 
min/max
# the right place for vals
vals = rawlins_norm(np.linspace(14,40,1000))
newcm = cm.colors.ListedColormap(cm.hot_r(vals))

cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r,
 norm=rawlins_norm,
 orientation='horizontal')

cb1.set_label('"percent"')
cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=newcm,
 orientation='horizontal')

cb2.set_label("colormap interval 0.0-1.0")
plt.subplots_adjust(hspace=.7, bottom=.2)

#comment out the next line to see the original (0-40 colormap)
ax1.set_xlim(rawlins_norm((14,40)))
plt.show()


best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Setting tick colors on a Polar plot for a circumplex

2011-01-11 Thread Paul Ivanov
Damien Bathory, on 2011-01-11 15:27,  wrote:
> Hi All.
> ...
> I want to change the color of the ticklines set by set_thetagrids(), but I
> am not having any luck.
> ( See black instead of green ticklines here:
> http://i1234.photobucket.com/albums/ff405/dbathory/circum.png )
> 
> Should I be able manipulating the ticklines in this way after calling
> set_theagrids?
> 
> for line in ax.xaxis.get_ticklines():
> line.set_color('g')
> 
> I've also tried using the tick_params() call to set the default tickline
> color, with no luck.
> I've tried this on matplotlib v1.00 and v98.1, with the same results (black
> instead of green).

Hi Damien,

Those aren't ticks, those are grid lines (verify by pressing 'g'
after selecting the axes to toggle the grid on and off).

  ax.grid(color='green')

is what you can use to set the grid line color (and other aspects, like
linewidth, linestyle, alpha, etc).

hope that helps,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Newbie: How to control space between sets of bars in bar chart

2011-01-12 Thread Paul Ivanov
Christopher Brewster, on 2011-01-13 00:27,  wrote:
> I have a bar chart with three sets of figures and I would like
> some space between the three sets. I cannot seem to find
> anything in the manual or online which explains how to separate
> sets of data.  I tried adding a blank (white bar) with 0 data
> and that did not work. When I made the data non zero I got
> overlapping bars. Basically I want the US/EU/Japan data
> slightly set apart. This is the default if I use a speadsheet
> package.

Hi Christopher,

Given the width for each bar that you've chosen and how you're
offsetting each year, there's just not room left between the
indexes that you're using. Just change your ind assignment line
to this:
 
 ind = np.arange(0, 2*N, 2) 

this spaces your indexes out more.

hope that helps,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] sensible tick labels for log scale?

2011-01-12 Thread Paul Ivanov
Christopher Fonnesbeck, on 2011-01-12 20:12,  wrote:
> I'm wondering if there is a way of automating tick labeling on
> log-scale axes, so that labels do not overlap. Specifically,
> when the values get large, they overlap which makes the labels
> unreadable. I would expect them to automatically get more
> sparse with the axis value, as they do when you generate such
> plots in R, for example.

Hi Christopher,

can you provide a small code example that demonstrates the
problem you're having?

The ticks get placed by a ticklocator. You can change the number
of ticks that get placed by setting the appropriate locators
numticks parameter.

In [50]: plt.loglog(1,1)
Out[50]: []

In [51]: ax = plt.gca()

In [52]: loc = ax.xaxis.get_major_locator()

In [53]: loc.numticks
Out[53]: 15

In [54]: loc.numticks = 10


IIRC, the variable name changes slightly from locator to locator,
but you can quickly figure it out in ipython using tab completion
in IPython once you grab a given locator object. 

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Hidding plots

2011-01-13 Thread Paul Ivanov

Salvador Benimeli, on 2011-01-13 10:10,  wrote:
> I would like to known if it is possible to hide a plot from a graph.
> 
> For example, I have the following python code:
> 
> for i in range(0,len(self.data):
> ..
> c = np.array(s[i])
> self.axes.plot_date(t[i],c,self.colors[i],label=self.labels[i])
> .
> 
> currently this code "draws" to plots on the canvas. The question is if its
> possible to hide/unhide a plot while remains the other.

Hi Salvador,

yes, it is possible. Just save the list plot_date returns, and
then call set_visible(False) on every member of that list.

  lines = plot_date([2000.10,2000.20,2000.30],[1,2,3])
  [l.set_visible(False) for l in lines]

or something like this to toggle visibility on and off

  [l.set_visible(not l.get_visible()) for l in lines]

 
best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] sensible tick labels for log scale (rephrased)

2011-01-13 Thread Paul Ivanov
Chris Fonnesbeck, on 2011-01-13 14:07,  wrote:
> I was hoping (and still hope) that Matplotlib is able to choose
> reasonable ticks on the log scale that do not overlap, but are
> more informative than just powers of 10.

Chris,

Sorry, I'm no expert with the locators, I rarely find myself
needing to mess with them. The cleaner way to get something other
than decades is to specify basex and basey. To do this for a plot
already created, you'll need to set the base of the LogLocator
and LogFormatter of your minor and major axes, like:

  fmat = plt.gca().xaxis.get_major_formatter()
  fmat.base(2)
  loc = plt.gca().xaxis.get_major_locator()
  loc.base(2)

I'm afraid I'm quite out of my element with these guys, maybe
someone else chimes in with another approach. Do post again to
clarify what you want.

Note that by default, the minor_formatter is set to be a
NullFormatter, thus no labels will be placed at the minor tick
locations. That would be a reasonable way to proceed - set the
major ticks to be non-overlapping, and put the minor ones
everywhere else.

You've probably already found it, but just in case:
http://matplotlib.sourceforge.net/api/ticker_api.html

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Analog of processing map() or protovis scale?

2011-01-16 Thread Paul Ivanov
Uri Laserson, on 2011-01-16 17:41,  wrote:
> Hi all,
> 
> Does there already exist some python implementation (in MPL or other) of an
> easy-to-use 1D scale transformation?  This is something analogous to
> processing's map function or protovis's scale functionality.  It would work
> something like:
> 
> s = linear().domain(5,100).range(13000,15000)
> 
> or
> 
> s = root(p=5).domain(0.1,0.6).range(0,1)
> 
> There could be multiple versions, including linear, log, symlog, root
> (power), discrete, etc.

Hi Uri,

I think that the closest we have matplotlib is
matplotlib.colors.Normalize[1] and matplotlib.colors.LogNorm[2], but
both of these have a fixed range of the 0-1 (which is the reason
they are in colors). Both of these do end up with an inverse
method that you could leverage to get an arbitrary range, though.

1. 
http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.Normalize
2. 
http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.LogNorm

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ColorbarBase usage

2011-01-17 Thread Paul Ivanov
Hi Bala,

Bala subramanian, on 2011-01-17 16:42,  wrote:
> I have created a figure (with two rows and two columns) and i drew four
> contourf plots (A,B,C,D etc). All the four contourf has the same coloring
> and bounds. I do not want to draw a colorbar() for each of the plots
> separately but only one colorbar at the bottom of the four plots.Something
> like the following scheme.
> 
> plot1plot2
> plot3plot4
>   colorbar
 
Here's one way of getting the type of plot you want.
I just incremented NROW by one, and for the colorbar axes
creation, changed it to be:
  ax5=FIG.add_subplot(NROW,1,NROW)

which is a quick way to get the last row to span both columns.

(I had to comment some things out to get the plot to run without
needing the data).

> I tried using mpl.colorbar.ColorbarBase as given in
> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html example to
> draw the colorbar. However i find the colorbar that is created is
> overlapping over the plots. Kindly let me know what is the correct way of
> adjuting its location and size or any other way to create this colorbar.

There, the axes are created to not overlap by hand tuning the
rectangle parameters passed (left, bottom, width, top). You can
get the same using the trick I used above, or get more
sophisticated combinations using GridSpec [1], or if you want to
get even fancier, with the AxesGrid toolkit [2]

1. http://matplotlib.sourceforge.net/users/gridspec.html
2. 
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html#toolkit-axes

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Alpha not working from imshow?

2011-01-17 Thread Paul Ivanov
Tim Burgess, on 2011-01-18 13:32,  wrote:
> I'm generating images that I want to use as overlays in Google
> Earth. Thus, I would like the masked portion of the numpy
> arrays I am using to appear as transparent.  However, I seem to
> consistently get white instead of a transparent point.
> 
> To clarify the issue, I wrote this short piece of code. I am
> setting both the figure background to transaprent and the
> masked value to transparent but I get white.
> 
> I have pulled the current svn code and built matplotlib. I get
> the same issue. 
> 
> from numpy import ma
> import matplotlib.pyplot as plt
> from pylab import colorbar, imshow, show, cm
> 
> 
> def main():
>   a = ma.array([[1,2,3],[4,5,6]],mask=[[0,0,1],[0,0,0]])
>   fig = plt.figure()
>   fig.patch.set_alpha(0.0)
>   cmap = cm.jet
>   cmap.set_bad(alpha=0.0)
>   imshow(a, interpolation='nearest', cmap=cmap)
>   colorbar()
>   show()

Hi Tim,

sorry to hear of your troubles - add these two lines to get your
desired effect:

  ax = plt.gca()
  ax.patch.set_alpha(0.0)

The figure has a patch associated with it, but so does each axes 
subplot, which is what you were seeing through the transparent
portion of your masked array image.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] what does numRows, numCols in subplot docs mean?

2011-01-18 Thread Paul Ivanov
From: Paul Ivanov 
To: Larry Evans 
Cc: 
Bcc: 
Subject: Re: [Matplotlib-users] what does numRows, numCols in subplot docs
 mean?
Reply-To: 
In-Reply-To: <4d32e05d.4090...@suddenlink.net>
X-PGP-Key: http://pirsquared.org/PaulIvanov0F3E28F7.asc

Larry Evans, on 2011-01-16 06:11,  wrote:
> subplot(numRows, numCols, plotNum)
> 
> 
>   New subplots that overlap old will delete the old axes.
> 
> However, that doc does not explain what a row or column is or what
> overlap means.
> 
> Is there some way the figure is partitioned into rows and columns and the
> subplots appear in these rows and columns.  If so, then how is this
> partition
> done?  Does subplot(1,2,1) appear to the left and at same level as
> subplot(1,2,2)?
> What if there's subplot(1,2,1) and subplot(2,1,1).  Do they overlap and
> if so, why?
> IOW, what's the definition of overlap?

Hi Larry,

Overlap means identical parameters for subplot:
  In [1]: ax1 = plt.subplot(1,2,1)
  
  In [2]: ax2 = plt.subplot(1,2,2)
  
  In [3]: ax3 = plt.subplot(1,2,1) # overlap, will delete ax1
  
  In [4]: fig = plt.gcf()
  
  In [5]: fig.axes
  Out[5]: 
  [,
   ]
  
  In [6]: ax1
  Out[6]: 
  
  In [7]: ax2
  Out[7]: 
  
  In [8]: ax3
  Out[8]: 
  
  In [9]: ax4 = plt.subplot(2,2,1) # also overlaps with ax3
  
  In [10]: ax5 = plt.subplot(2,2,4) # overlaps with ax2
  
  In [12]: fig.axes
  Out[12]: 
  [,
   ]

The last parameter ("plotNum") for subplot determines which row
and column you want based on something like the formula:

  row = plotNum // numCols
  column = plotNum % numCols


Hope that helps,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] UNIX_import pyplot:_path.so: symbol _ZNSs4_Rep20_S_empty_rep_storageE:referenced symbol not found

2011-01-18 Thread Paul Ivanov
Clément PORNET, on 2011-01-18 18:39,  wrote:
> 
> Hi everyone,After having compiling and installing Matplotlib 1.0.1 with 
> Python 2.5.5 on a Unix platform sunos5, I ran into the following problem, 
> when trying to import pyplot or pylab.Here is the ouput when using ipython:
> 
> ImportError: ld.so.1: ipython: fatal: relocation error: file
> /home/co29/PYTHON-2.5/lib/python2.5/site-packages/matplotlib/_path.so:
> symbol _ZNSs4_Rep20_S_empty_rep_storageE: referenced symbol not
> found

Clément,

this is likely due to a misbuilt matplotlib - have you update
numpy since you last built matplotlib?

Can you try deleting ../site-packages/matplotlib, and the build/
directory for your sources of mpl1.0.1 and reinstall? Please
report back either way so we get a handle on this.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] rcParams['figure.dpi'] has no effect?

2011-01-21 Thread Paul Ivanov
Bala subramanian, on 2011-01-21 12:17,  wrote:
> Daniel,
> Did you try saving the figure with same dpi ?. Try the following.
> 
> plt.savefig('name',dpi=300)
> 
> On Fri, Jan 21, 2011 at 9:08 AM, Daniel Mader <
> danielstefanma...@googlemail.com> wrote:
> 
> > Hi,
> >
> > I need to create a huge range of plots with need to fit into a report
> > (OpenOffice or Word). In order to save the work of manual resizing them when
> > dragged and dropped, I wanted to preset a correct figure size with a nice
> > resolution:
> >
> > pylab.rcParams['figure.figsize'] = 5,4
> > pylab.rcParams['figure.dpi'] = 300
> >
> > Now, the created figure has a size of 500x400 pixels, and when I import it
> > into a word processor, its dimensions are reported as 12.7x10.16cm², which
> > matches the figsize definition. Yet, the resulting images are pretty much
> > blurred...
> >
> > How can I increase the resolution, or what am I doing wrong?

Hi Daniel,

As Bala alluded - there's a difference between display dpi and
the file saving dpi. Your change to rcParams only affected the
displayed resolution, not the resolution of saved files. 

Quoting from .matplotlibrc

  # the default savefig params can be different from the display params
  # Eg, you may want a higher resolution, or to make the figure
  # background white
  #savefig.dpi   : 100  # figure dots per inch

So try playing around with that parameter (which is what you're
doing if you call plt.savefig('name', dpi=300)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Legend for contour plots

2011-01-21 Thread Paul Ivanov
Francesco Montesano, on 2011-01-21 15:44,  wrote:
> Dear All,
> 
> I am using contour plot and I am drawing different contours with
> different colors and linestyles and I would like to have a legend with
> a caption for each contour function used.
> Here you can see an example of what I would like to do
> 
> >> #create the 2D histogram and the x and y axis
> >> x, y = np.random.normal(0, 0.5, 1000), np.random.normal(0, 1, 1000)
> >> h, xe,ye = np.histogram2d(x,y, bins=25)
> >> xe, ye = (xe[1:]+xe[:-1])/2, (ye[1:]+ye[:-1])/2
> >>
> >> lines,text = [], []   # initialise lists
> >>
> >> #contour plots
> >> lines.append(plt.contour(xe,ye,h, levels=[10,9], linestyles="-", 
> >> colors="k"))
> >> text.append("level=10, 9")
> >>
> >> lines.append(plt.contour(xe,ye,h, levels=[5,4], linestyles="--", 
> >> colors="r"))
> >> text.append("level=5, 4")
> >>
> >> plt.legend(lines, text)
> 
> Everything goes well untill I plot the legend. At the end of the mail
> I report the error that I get.
> Anyway, if I do
> >> plt.legend(lines)
> I don't get any errors but it's quite useless, since the text of the
> legend is just like:
> 
> as you can see from the attached figure.
> 
> 
> I've the feeling that the problem is that "contour" gives back a
> "matplotlib.contour.ContourSet instance", while the functions like
> "plot" gives back a " 
> Does anyone knows how to do what I want?
> 
Hi Francesco,

here's one way of getting what you want, instead of calling
legend on your 'lines' variable as you had it, do this:

  actual_lines = [cs.collections[0] for cs in lines]
  plt.legend(actual_lines, text)

As you note, the call to plt.countour does not return lines, it
returns contour sets (which is why I called the variable 'cs' in
my example). Poking around in ipython, I saw that each contour
set has a collections attribute which holds the actual lines.
 
hope that helps,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Suggestions for auto scaling fonts , etc for producing images at various scales

2011-01-21 Thread Paul Ivanov
Daryl Herzmann, on 2011-01-21 15:42,  wrote:
> Greetings matplotlib users,
> 
> Firstly, thank you so much for a great python plotting library.  I use
> it daily and find the library very intuitive :)  My question deals
> with generating raster images at multiple scales without heavy code
> modification.  My work flow is to generate two versions of the same
> plot, one thumbnail (~ 320x320) and then one 'full size' around (~
> 800x800) in PNG format for the web.
> 
> My current methodology is to generate a postscript file and then send
> it through ImageMagick's convert to generate the two different sized
> images.  I find that this works 'good enough for me', but I often run
> into problems when I have transparency in the plot and that
> information is lost in the translation of formats...  I also get
> fairly bulky file sizes, but that is probably my fault for not using
> the proper convert flags, anyway...
> 
> I have tried messing around with the dpi and figsize settings to the
> initial: fig = plt.figure() and fig.savefig() , but I can't seem to
> get similiar quality to my hacky method outlined above.  Many times,
> the fonts look nasty :)
> 
> Any tips or tricks to make this happen?  Thanks again and I sincerely
> apologize if I missed a FAQ item , etc on this...

Hi Daryl,

I'm not sure I understand what it is that you want, but if the
issue is related to scaling fonts depending on output figure size
and/or dpi - have you tried playing around with the 'font.size'
rcParam, and defining your font sized using 'xx-small',
'x-large', etc, instead of specifying a point size directly? 

From .matplotlibrc:

  # note that font.size controls default text sizes.  To configure
  # special text sizes tick labels, axes, labels, title, etc, see the rc
  # settings for axes and ticks. Special text sizes can be defined
  # relative to font.size, using the following values: xx-small, x-small,
  # small, medium, large, x-large, xx-large, larger, or smaller
  #font.size   : 12.0

I guess I'm not sure what you meant by the fonts looking 'nasty',
so if font.size doesn't address your issue, could you post a
small example that does the wrong thing, along with the type of
output you were hoping to get.

My feeling is that there shouldn't be a need to use ImageMagick -
but depending on the size and dpi of your desired figures, is the
problem that the text is not being antialiased?

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Suggestions for auto scaling fonts , etc for producing images at various scales

2011-01-21 Thread Paul Ivanov
Daryl Herzmann, on 2011-01-21 16:41,  wrote:
> On Fri, Jan 21, 2011 at 4:15 PM, Paul Ivanov  wrote:
> 
> > I guess I'm not sure what you meant by the fonts looking 'nasty',
> > so if font.size doesn't address your issue, could you post a
> > small example that does the wrong thing, along with the type of
> > output you were hoping to get.
> 
> Thanks for the responses and sorry to not be clear.  Here is an example 
> script:
> 
> import matplotlib.pyplot as plt
> 
> fig = plt.figure(figsize=(8,8))
> 
> ax = fig.add_subplot(111)
> 
> ax.plot( [0,100], [0,100] )
> ax.set_xlabel("Temperature after the sun goes down $^{\circ}F$")
> ax.set_ylabel("Temperature when the sun goes up $^{\circ}F$")
> ax.set_title("My Fancy Plot!!!")
> 
> fig.savefig('test.png', dpi=(40))
> 
> 
> with 3 different outputs. First two numbers are figsize settings and
> last is DPI.
> 
> In my perfect world, I would like to simple to this at the end of my script:
> 
> fig.savefig('thumbnail.png', .)
> fig.savefig('fullsize.png', ..)
> 
> and get two clean looking images.  If I have to rerun the script with
> different options to get a thumbnail and then a fullsize, that is okay
> too.  I just can't figure out what all needs to be tweeked / how to do
> it..

Daryl,

ok, much clearer now - what you want is for your text to not be
cut-off the way it is in the 8x8 80dpi plot? In other words,
there's not enough space left in the figure for the axis labels
to be completely displayed.

At the moment, I don't think there's a simple way of doing it,
and the quick way I find myself doing is by adjusting the subplot
parameters using:

  plt.subplots_adjust(left=..., bottom=...)

I'm almost certain that one *can* write a function to do this
pro grammatically (without having to hand tweak anything), by
looking at say, the .get_window_extent()  but I haven't found the
time to scratch that itch, yet.

If someone wants to beat me to it, here's the sort of thing that
you can do:

  def show_labels_by_shrinking(ax):
" adjust subplot parameters to fit the yaxis label"
f = ax.figure
textwidth = ax.yaxis.get_label().get_window_extent().width
labelwidth = max([lab.get_window_extent().width for lab in 
ax.get_yticklabels()])

plt.subplots_adjust(left=(textwidth+labelwidth+3*ax.yaxis.labelpad)/f.get_window_extent().width)
# the 3 *ax.yaxis.labelpad is just a fudge factor for now, need
# to look into the sourcecode to figure out what the
# appropriate placement is normally, to know how to adjust
# properly
  
  
  ax.set_ylabel('foo')
  show_labels_by_shrinking(ax)
  ax.set_ylabel("a\nmulti\nline\nexample")
  show_labels_by_shrinking(ax)
  
best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Automatic subplot_params for fitting label text (was Re: Suggestions for auto scaling fonts ,

2011-01-21 Thread Paul Ivanov
etc for producing images at various scales)
Reply-To: 
In-Reply-To: <20110121232036.GA26739@ykcyc>
X-PGP-Key: http://pirsquared.org/PaulIvanov0F3E28F7.asc

Paul Ivanov, on 2011-01-21 15:20,  wrote:
> I'm almost certain that one *can* write a function to do this
> pro grammatically (without having to hand tweak anything), by
> looking at say, the .get_window_extent()  but I haven't found the
> time to scratch that itch, yet.
> 
> If someone wants to beat me to it, here's the sort of thing that
> you can do:
> 
>   def show_labels_by_shrinking(ax):
> " adjust subplot parameters to fit the yaxis label"
> f = ax.figure
> textwidth = ax.yaxis.get_label().get_window_extent().width
> labelwidth = max([lab.get_window_extent().width for lab in 
> ax.get_yticklabels()])
> 
> plt.subplots_adjust(left=(textwidth+labelwidth+3*ax.yaxis.labelpad)/f.get_window_extent().width)
> # the 3 *ax.yaxis.labelpad is just a fudge factor for now, need
> # to look into the sourcecode to figure out what the
> # appropriate placement is normally, to know how to adjust
> # properly
>   
>   
>   ax.set_ylabel('foo')
>   show_labels_by_shrinking(ax)
>   ax.set_ylabel("a\nmulti\nline\nexample")
>   show_labels_by_shrinking(ax)

I should add that along with doing a similar thing for the xaxis,
this would need to be extended for the multiple subplot case, to
also adjust the wspace and hspace parameters accordingly. 

this is important functionality currently missing from matplotlib
out-of-the-box at the moment, so I'll try my crack at it this out
this weekend. 

CCing the devel list in case someone has more opinions.

best, 
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] a break in the y-axis

2011-01-22 Thread Paul Ivanov
Ilya Shlyakhter, on 2011-01-22 19:06,  wrote:
> Is it possible to create a "break" in the y-axis so that it has ticks
> for value 0-.2, then ticks for values .8-1.0, but devotes only a token
> amount of space to the area 0.2-0.8?
> I have a dataset with most datapoints in 0-.2 and a couple in .8-1.0,
> and none in .2-.8 .   The default scaling wastes a lot of space and
> compresses the data in the 0-.2 range
> such that it is hard to distinguish.
 
Hi Ilya,

this...

> p.s. I know I could use two y-axes with different scales; but this
> would require splitting the data into two different datasets as well,
> and would not allow connecting all points
> with one line.

... is the way I'd proceed, because it's clean, and requires the
least amount of work.  Connecting your lines across such breaks
is misleading - since the magnitude of the slope of the
connecting line segment arbitrary relative to all other line
segments. You don't actually have to divide your data, you can
just replot *all* data on the secondary plot, and then set the x
and y lims to break up your views on the data. I'm attaching a
quick sketch of what that would look like. (Note how different
the outlier line segments would look if we connected them in the
same manner that all other points are connected).

  import numpy as np
  import matplotlib.pylab as plt
  pts = np.random.rand(30)*.2
  pts[[7,11]] += .8
  f,(ax,ax2) = plt.subplots(2,1,sharex=True)
  
  ax.plot(pts)
  ax2.plot(pts)
  ax.set_ylim(.78,1.)
  ax2.set_ylim(0,.22)
  
  ax.xaxis.tick_top()
  ax.spines['bottom'].set_visible(False)
  ax.tick_params(labeltop='off')
  ax2.xaxis.tick_bottom()
  ax2.spines['top'].set_visible(False)

If this is something you really want, though, you can achieve it
by making your own projection/scale:
http://matplotlib.sourceforge.net/devel/add_new_projection.html

Yet another way would be to re-label the tick lines (e.g. make .6
label be 1.0 and subtract that offset from your two outliers.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Installing from svn

2011-01-22 Thread Paul Ivanov
Glen Shennan, on 2011-01-21 15:41,  wrote:
> Hi,
> 
> I'm trying to install matplotlib from the svn source.  I can compile
> the code and install it to my desired location but I cannot import it
> into python.
> 
> I did:
> 
> svn co 
> https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib
> matplotlib
> cd matplotlib
> python setup.py install --prefix=/home/glen/local
> 
> I have numpy and scipy installed and working correctly using the above
> prefix and matplotlib compiles and installs the same way but when I
> issue "import matplotlib as mpl" nothing results.  There is no error
> but also no library.
> 
> >>> dir(mpl)
> ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
> 
> >>> mpl.__path__
> ['matplotlib']
> 
> >>> mpl.__file__
> 'matplotlib/__init__.pyc'

Hi Glen,

what directory are you in when you're doing this?
> >>> mpl.__path__
> ['matplotlib']
suggests that you're importing from some local directory. If
everything worked right, the path should be something like
>>> mpl.__path__
['/home/glen/local/lib/python2.x/site-packages/matplotlib']

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] a break in the y-axis

2011-01-22 Thread Paul Ivanov
Paul Ivanov, on 2011-01-22 18:28,  wrote:
> Ilya Shlyakhter, on 2011-01-22 19:06,  wrote:
> > Is it possible to create a "break" in the y-axis so that it has ticks
> > for value 0-.2, then ticks for values .8-1.0, but devotes only a token
> > amount of space to the area 0.2-0.8?
> > I have a dataset with most datapoints in 0-.2 and a couple in .8-1.0,
> > and none in .2-.8 .   The default scaling wastes a lot of space and
> > compresses the data in the 0-.2 range
> > such that it is hard to distinguish.
>  
> Hi Ilya,
> 
> this...
> 
> > p.s. I know I could use two y-axes with different scales; but this
> > would require splitting the data into two different datasets as well,
> > and would not allow connecting all points
> > with one line.
> 
> ... is the way I'd proceed, because it's clean, and requires the
> least amount of work.  Connecting your lines across such breaks
> is misleading - since the magnitude of the slope of the
> connecting line segment arbitrary relative to all other line
> segments. You don't actually have to divide your data, you can
> just replot *all* data on the secondary plot, and then set the x
> and y lims to break up your views on the data. I'm attaching a
> quick sketch of what that would look like. (Note how different
> the outlier line segments would look if we connected them in the
> same manner that all other points are connected).
> 
>   import numpy as np
>   import matplotlib.pylab as plt
>   pts = np.random.rand(30)*.2
>   pts[[7,11]] += .8
>   f,(ax,ax2) = plt.subplots(2,1,sharex=True)
>   
>   ax.plot(pts)
>   ax2.plot(pts)
>   ax.set_ylim(.78,1.)
>   ax2.set_ylim(0,.22)
>   
>   ax.xaxis.tick_top()
>   ax.spines['bottom'].set_visible(False)
>   ax.tick_params(labeltop='off')
>   ax2.xaxis.tick_bottom()
>   ax2.spines['top'].set_visible(False)
> 
> If this is something you really want, though, you can achieve it
> by making your own projection/scale:
> http://matplotlib.sourceforge.net/devel/add_new_projection.html
> 
> Yet another way would be to re-label the tick lines (e.g. make .6
> label be 1.0 and subtract that offset from your two outliers.

forgot the attachment, here it is.

-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<>

signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] a break in the y-axis

2011-01-24 Thread Paul Ivanov
Eric Firing, on 2011-01-22 17:49,  wrote:
> >> Paul Ivanov, on 2011-01-22 18:28,  wrote:
> 
> Paul,
> 
> Your example below is nice, and this question comes up quite often.  If 
> we don't already have a gallery example of this, you might want to add 
> one.  (Probably better to use deterministic fake data rather than random.)
> 
> >>
> >>import numpy as np
> >>import matplotlib.pylab as plt
> >>pts = np.random.rand(30)*.2
> >>pts[[7,11]] += .8
> >>f,(ax,ax2) = plt.subplots(2,1,sharex=True)
> >>
> >>ax.plot(pts)
> >>ax2.plot(pts)
> >>ax.set_ylim(.78,1.)
> >>ax2.set_ylim(0,.22)
> >>
> >>ax.xaxis.tick_top()
> >>ax.spines['bottom'].set_visible(False)
> >>ax.tick_params(labeltop='off')
> >>ax2.xaxis.tick_bottom()
> >>ax2.spines['top'].set_visible(False)

Done in r8935, see examples/pylab_examples/broken_axis.py

I documented the above, used deterministic fake data, as Eric
suggested, and added the diagonal cut lines that usually
accompany a broken axis. Here's the tail end of the script which
creates that effect (see updated attached image).

  # This looks pretty good, and was fairly painless, but you can
  # get that cut-out diagonal lines look with just a bit more
  # work. The important thing to know here is that in axes
  # coordinates, which are always between 0-1, spine endpoints
  # are at these locations (0,0), (0,1), (1,0), and (1,1).  Thus,
  # we just need to put the diagonals in the appropriate corners
  # of each of our axes, and so long as we use the right
  # transform and disable clipping.
  
  d = .015 # how big to make the diagonal lines in axes coordinates
  # arguments to pass plot, just so we don't keep repeating them
  kwargs = dict(transform=ax.transAxes, color='k', clip_on=False)
  ax.plot((-d,+d),(-d,+d), **kwargs)  # top-left diagonal
  ax.plot((1-d,1+d),(-d,+d), **kwargs)# top-right diagonal
  
  kwargs.update(transform=ax2.transAxes)  # switch to the bottom axes
  ax2.plot((-d,+d),(1-d,1+d), **kwargs)   # bottom-left diagonal
  ax2.plot((1-d,1+d),(1-d,1+d), **kwargs) # bottom-right diagonal
  
  # What's cool about this is that now if we vary the distance
  # between ax and ax2 via f.subplots_adjust(hspace=...) or
  # plt.subplot_tool(), the diagonal lines will move accordingly,
  # and stay right at the tips of the spines they are 'breaking'

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<>

signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] X and Y label position in axes_grid1.AxesGrid/ImageGrid

2011-01-24 Thread Paul Ivanov
Russell Hewett, on 2011-01-24 13:56,  wrote:
> Hi All,
> 
> I can't get the x label on the top row of an ImageGrid to display if there
> is more than one row in the grid.  I suspect that something is being clipped
> somewhere, but have no idea what to do to fix it.  (Note, this also happens
> on the right edge of a ride-sided y axis label.)
> 
> I have included some minimal sample code below.  I'd appreciate it if anyone
> can point me in the right direction.
> 
> 
> Cheers,
> Russ

Hi Russ, 

thanks for the report - at a glance, it appears to be a bug in
AxesGrid removing redundant labels for shared axis when they
align. I've included a temporary workaround for your script, but
don't have time to look into it further at the moment. By the
way, calling grid[0].axes is redundant, so I just modified it to
use grid[0].xaxis, which is equivalent.

#---
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import mpl_toolkits.axes_grid1 as ag

import numpy as np

fig1 = plt.figure()

grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)

grid1[0].xaxis.set_label_position('top')
grid1[0].xaxis.set_label_text('foo')

grid1[1].xaxis.set_label_position('top')
grid1[1].xaxis.set_label_text('bar')

grid1[0].yaxis.set_label_position('right')
grid1[0].yaxis.set_label_text('foo')

grid1[1].yaxis.set_label_position('right')
grid1[1].yaxis.set_label_text('bar')
grid1[1].yaxis.label.set_visible(True) # tmp workaround


fig2 = plt.figure()
grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)

grid2[0].xaxis.set_label_position('top')
grid2[0].xaxis.set_label_text('bar')
grid2[0].xaxis.label.set_visible(True) # tmp workaround

grid2[1].xaxis.set_label_position('top')
grid2[1].xaxis.set_label_text('bar')

grid2[0].yaxis.set_label_position('right')
grid2[0].yaxis.set_label_text('foo')

grid2[1].yaxis.set_label_position('right')
grid2[1].yaxis.set_label_text('bar')

plt.show()
#---

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] labels in ax = Axes3D(fig) are not aligned in parallel

2011-01-24 Thread Paul Ivanov
Daniel Mader, on 2011-01-24 20:55,  wrote:
> Hi,
> 
> I have seen this ever since I use mpl_toolkits.mplot3d.Axes3D but it never
> bothered me too much until now: the labels are not aligned in paralled to
> the axes so that with longer labels or small figsizes, they run into the
> tick labels, besides looking odd.
 
Hi Daniel,

it does appear like a bug, though only for some views on the
axes, thanks for the report. I'm not very familiar with this
code, so I'll leave the bugfix for someone else, but here's the
temporary workaround:

> Is there anything I can do to change the angle manually?

# prevent the automatic rotation caused by view changes
ax.yaxis.set_rotate_label(False) 
ax.yaxis.label.set_rotation(45)

Beware that you'll have to adjust that angle on a per-view basis
to get things to look right.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] floating bar chart?

2011-01-24 Thread Paul Ivanov
C M, on 2011-01-24 16:27,  wrote:
> I looked through the gallery, but didn't see this one and am not sure
> how to create it.  It would be a "floating bar chart" (or floating
> column chart), like what is seen here:
> 
> http://peltiertech.com/Excel/pix1/BloodSugarFloater.gif

Hi Che,

just specify the 'bottom' keyword argument to bar. Note that the
second parameter is height of the bar, *not* the top of the bar

plt.bar([1,2,3,4], [2,2.5,5,3], bottom=[0,-1,1,2])

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar+log+latex

2011-01-25 Thread Paul Ivanov
Eric Firing, on 2011-01-25 19:52,  wrote:
> On 01/25/2011 06:58 PM, Shrividya Ravi wrote:
> [...]
> > On the same topic of the colorbar, how can I readjust the colors such
> > that it only goes between user-specified values? For example, I have one
> > imshow plot where the values range between 0 and 350. However, I only
> > want to look at the values between 300 and 350.
> 
> z = np.arange(25)
> z.shape = 5,5
> imshow(z, vmin=10, vmax=20, interpolation='nearest')
> colorbar(extend='both')
> 
> Does that give the desired result?

Hi Shrividya,

Here's how I interpreted what was being asked, in case that
helps. 

Also, Eric, is there a reason we make an outline instead of
just cbar.ax.set_frame_on? - My manual adjustments screw up and
confuse whatever data cbar.outline depends on

x = np.random.rand(100)
y = np.random.rand(100)
z = np.random.rand(100)
collection = plt.scatter(x, y, c=z*350, vmin=0, vmax=350)
cbar = plt.colorbar()
cbar.ax.set_ylim(cbar.norm((300,350)))
cbar.ax.set_xlim(cbar.norm((300,350))) # maintain aspect ratio
cbar.set_ticks(np.linspace(300,350,6))
# didn't see a quick way to fix the outline
cbar.outline.set_visible(False) 
cbar.ax.set_frame_on(True)
plt.draw()

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] too many values to unpack with a bar chart

2011-01-26 Thread Paul Ivanov
C M, on 2011-01-27 02:03,  wrote:
> > 3) I am getting just hammered with the following error *a lot* in date
> > plotting lately:
> >
> > ValueError: ordinal must be >= 1
> 
> 
> OK, I made up a small runnable sample to show this with bar().  (Using
> code that someone else wrote[1]).  This code runs when using
> plot_date(), but if you comment that out and comment in the ax.bar()
> line, it will give this ValueError.
> 
> 
> import matplotlib.pyplot as plt
> import matplotlib as mpl
> import numpy as np
> import datetime as dt
> 
> # Make a series of events 1 day apart
> x = mpl.dates.drange(dt.datetime(2009,10,1),
>  dt.datetime(2010,1,15),
>  dt.timedelta(days=1))
> # Vary the datetimes so that they occur at random times
> # Remember, 1.0 is equivalent to 1 day in this case...
> x += np.random.random(x.size)
> 
> # We can extract the time by using a modulo 1, and adding an arbitrary base 
> date
> times = x % 1 + int(x[0]) # (The int is so the y-axis starts at midnight...)
> 
> # I'm just plotting points here, but you could just as easily use a bar.
> fig = plt.figure()
> ax = fig.add_subplot(111)
> 
> #comment out:
> ax.plot_date(x, times, 'ro')
> 

Hi C. M.,

The reason you were getting that error is because unless you
specify otherwise, ax.bar will make the bottom of the bars at 0 -
which isn't an allowed date, hence the error. Change your bar
line to this (I also added align='center', but you can remove it
if you want):

> #comment in
bot = times.min().round()
ax.bar(x, times-bot, bottom=bot, align='center')
> 
> ax.yaxis_date()
> fig.autofmt_xdate()
> 
> plt.show()

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Paul Ivanov
Daniel Fulger, on 2011-01-27 18:16,  wrote:
> Dear all,
> 
> contourset = pyplot.contour(..)
> 
> calculates the contourset but also grabs whatever figure is currently  
> active *somewhere* in the entire code
> and whichever scope it was created. The contours are plotted into it.
> 
> While I could possibly live with that, I would really like to
> suppress any plotting and grabbig of focus. Only the contourset  
> should be calculated.
> 
> I can't find anything that describes this. Everybody wants the plot,  
> not me.
> 
> I would like to avoid hte workaround  to ask for the currently active  
> figure (if!! there is one at all), store the number, and later return  
> focus. Is there no switch parameter (in pyplot or for contour at  
> least) that turns plotting off?

Hi Daniel,

I'm not sure if this gets at what you're asking for, but if
you just want the contours plotted on a figure other than the
currently active one, grab a handle to some other axes and call
contour from the axes itself (the parameters are the same).
Here's what I mean:

---
f,ax  =plt.subplots(1,1) #grab handles to figure and axes
# or, if you're using an older version of matplotlib, do:
# f=plt.figure();ax=plt.subplot(1,1,1)


f2,ax2  =plt.subplots(1,1) # "f" no longer active figure
...
contourset = ax.contour(...) # draw to the old figure "f"
---

You can read more about the difference between using pyplot and
using the object-oriented api here:

http://matplotlib.sourceforge.net/faq/usage_faq.html

On the other hand, if you just want the contour to not show up,
you can pass it alpha=0.0 to make it completely transparent and
invisible (but it's still there)

contourset = pyplot.contour(.., alpha=0.0)
# later call contourset.set_alpha(1.0) to make visible again

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] too many values to unpack with a bar chart

2011-01-27 Thread Paul Ivanov
C M, on 2011-01-27 13:56,  wrote:
> bars = self.subplot.bar(self.final_dates, top-bot, bottom=bot, align='center')
> 
> I get the error:
> 
> TypeError: unsupported operand type(s) for -: 'list' and 'list'
> 
> Because I am trying to subtract the "bots" list from the "tops" list.
> In the example code I gave, bot and times were not lists but were a
> 'numpy.ndarray' and a numpy.float64' object, respectfully, and I guess
> the - operand can be used on them.
> 
> How can I structure my data such that this can work?  (For some reason
> I have not had nearly this much confusion with plotting lines, just
> bars).

Che, 

just make a numpy array out of your two lists, and you'll be able
to subtract one from the other.

import numpy as np
top = np.array(top)
bot = np.array(bot)

best, 
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Paul Ivanov
Benjamin Root, on 2011-01-27 13:04,  wrote:
> I believe he would rather call the core function that contour uses to
> do the heavy lifting.  This was something that one can do in matlab,
> btw.  I don't have access to the source right now.  What does contour
> call to perform this calculation?

matplotlib.contour.QuadContourSet - which in turn uses
ContourSet, and both take ax as a required argument. They use
matplotlib.contour._cntr  which is 


Daniel Fulger, on 2011-01-27 20:21,  wrote:
> no, I would like to suppress plotting entirely, avoid changing of  
> active figure and avoid handling figures or axis completely.
> I m only interested in the contourset. I wonder if my post was  
> somehow sloppy.
> 
> Yes, there are work-arounds like creating a dummy figure, similar to  
> your suggestion, and return focus to
> the previously active figure. But plotting takes time and memory, is  
> not needed and requires several code lines. Once might be ok but  
> speed and memory is important.
> Plotting with alpha=0 still requires figure and axis handling.
> 
> So how can I switch off all figure and axis related actions and  
> savely call contourset = contour(x,y,...) that does nothing else than  
> return the contours?

I understand better now, but as far as I could tell from poking
inside the QuadContourSet code, there isn't a simple way to
call the underlying machinery which generates the contours.

You'll have to look at what QuadContourSet._contour_args
does internally to see what what x, y, z should be, and then
create a contour using 

C = matplotlib.contour._cntr.Cntr(x,y,z) 

and then for each level, do something like what 
QuadContourSet._get_allsegs_and_allkinds does
C.trace(..) 

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Limits with errorbar

2011-02-01 Thread Paul Ivanov
Francesco Montesano, on 2011-02-01 12:07,  wrote:
> I attach a sample code which does not work.
> 
> import numpy as np
> > import matplotlib.pyplot as plt
> >
> > #create function to plot plus random error
> > x = np.linspace(0,3,100)
> > y = np.sin(x)
> > err = np.random.random(100)
> >
> > plt.errorbar(x,y, yerr=err, color='g',linestyle='None',xuplims=True)
> > plt.show()

Hi Francesco,

> > plt.errorbar(x,y, yerr=err, color='g',linestyle='None',xuplims=True)

I'm not sure what you're hoping to see, but you should either use
xerr with xuplims, or yerr with uplims.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with matshow and yticks: the rows of a matrix drawn by matshow does not have equal height

2011-02-01 Thread Paul Ivanov
Denzel Li, on 2011-02-01 15:34,  wrote:
> I had this problem but could not find the answer online. I will be highly
> appreciating if anyone can point me some direction on this problem.
> I installed pythonxy and used matplotlib through ipython. I used matshow to
> draw a matrix and then set ticklables. This lead to the shown rows having
> uneven height. The following shows my problem:
> --
> import numpy
> M=randn(4,6)
> matshow(M)
> ---
> This works fine and is shown in fig1.png.  However, after I set the yticks:
> 
> yticks(arange(4), ('1','2','3','4'))
> ---
> The rows of the matrix drawn have uneven height. Please see fig2.png.

Hi Denzel,

what version of matplotlib are you using? I am unable to
reproduce on fairly recent checkout of svn trunk, so it may be an
issue that was recently fixed.

one workaround would be to set the ylim after the call to yticks,
like this:

  plt.ylim(3.5, -0.5)

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Custom colormap is inconsistent. What is wrong?

2011-02-01 Thread Paul Ivanov
Jeremy Conlin, on 2011-02-01 16:48,  wrote:
> I'm trying to create a custom colormap used with pcolormesh, but the
> results seem inconsistent to me.  I want the following colors
> 
> -3 < x <= -2 - Black
> -2 < x <= -1 - Blue
> -1 < x <= 0  - Yellow
>  0 < x <= 1  - Green
>  1 < x <= inf - Red
> 
> A minimal example is copied below.  I have a 2-D array that looks like:
> 
>  -1,6,  2.5
> 1.3,  -2,  4/3
> 2.5,   6,  0
> 
> I want to get a pcolormesh that looks like
> 
> R R Y
> R K R
> B R R
> 
> But instead I get:
> 
> Y R B
> Y K Y
> K R Y
> 
> I recognize that the pcolormesh is plotted "upside-down" from how the
> matrix is printed.  I apparently don't understand how to use a custom
> colormap.  I have tried to follow the example here:
> 
> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html
> 
> but haven't been too successful.  It seems like there is a
> normalization going on that I can't seem to track down.  Can anyone
> see what is wrong?
> 
> Thanks,
> Jeremy
> 
> 
> import numpy
> import matplotlib.pyplot as pyplot
> import matplotlib.colors
> 
> C = numpy.array([[-1,6,2.5],[4/3., -2, 4/3.],[2.5,6,0.0]],dtype=float)
> 
> cMap = matplotlib.colors.ListedColormap(['k', 'b', 'y', 'g', 'r'])
> Bounds = [-3.0, -2.0, -1.0, 0.0, 1.0, numpy.inf]
> 
> # Plot
> Fig = pyplot.figure()
> pyplot.pcolormesh(C, cmap=cMap)

Hi Jeremy,

you're right, matplotlib expects colors to be in the range 0-1.
I've added the appropriate normalization below. I also had to
subtract a small number from C to adjust for your specification
of the desired intervals being closed on the upper bound, because
the default makes lower bound closed. In other words, the default
is to treat the bounds as -3 <= x < -2 for black, in your case,
instead of -3 < x <= -2 as you wanted it.


  # R R Y
  # R K R
  # B R R
  n = mpl.colors.normalize(-3,2)
  pyplot.pcolormesh(C-(1e-15), cmap=cMap,norm=n)



signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fixing overlapping annotations

2011-02-01 Thread Paul Ivanov
Kris Kuhlman, on 2011-02-01 18:03,  wrote:
> I am trying to plot a large number of locations that need to be labeled.
> Often the locations are quite clustered and the resulting text is
> unreadable.  I have been looking through the API and examples on the
> matplotlib web page, and I don't see a straightforward way to plot text
> labels, preventing them from overlapping.  There is no easy answer to the
> problem, since locating the labels so they are close to the point you want
> to label, and not overlapping is a sort of optimization problem, I guess.
> 
> Using annotate(), the location and alignment of the text can be fixed, but
> you don't know the size of the resulting box until after draw() is called.
> Once draw is called, you can inquire what the bounding box for a label is,
> and then check to see if it overlaps with other labels, but this is an
> iterative process, and draw() can be quite slow to call repeatedly.
> 
> I guess unless you use a fixed-width font (possible, but not optimal), you
> just don't know how big the labels will be, and therefore where they will
> extend to, and then how they should be avoided.  This involves coming up
> with some sort of accounting system for the location and size of each text
> box, outside of the matplotlib API, and seems sub-optimal.
> 
> Has anybody dealt with this problem and come up with an elegant or efficient
> solution?

Hi Kris,

unfortunately, there isn't a turn-key solution implemented for
this at the moment, but this would be something very useful and
something I've been wanting to see in matplotlib, but never had a
strong enough need to implement myself.

Take a look here for the type of machinery that could be used to
implement such functionality:

http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] fixing overlapping annotations

2011-02-01 Thread Paul Ivanov
Paul Ivanov, on 2011-02-01 17:14,  wrote:
> Kris Kuhlman, on 2011-02-01 18:03,  wrote:
> > I am trying to plot a large number of locations that need to be labeled.
> > Often the locations are quite clustered and the resulting text is
> > unreadable.  I have been looking through the API and examples on the
> > matplotlib web page, and I don't see a straightforward way to plot text
> > labels, preventing them from overlapping.  There is no easy answer to the
> > problem, since locating the labels so they are close to the point you want
> > to label, and not overlapping is a sort of optimization problem, I guess.
> > 
> > Using annotate(), the location and alignment of the text can be fixed, but
> > you don't know the size of the resulting box until after draw() is called.
> > Once draw is called, you can inquire what the bounding box for a label is,
> > and then check to see if it overlaps with other labels, but this is an
> > iterative process, and draw() can be quite slow to call repeatedly.
> > 
> > I guess unless you use a fixed-width font (possible, but not optimal), you
> > just don't know how big the labels will be, and therefore where they will
> > extend to, and then how they should be avoided.  This involves coming up
> > with some sort of accounting system for the location and size of each text
> > box, outside of the matplotlib API, and seems sub-optimal.
> > 
> > Has anybody dealt with this problem and come up with an elegant or efficient
> > solution?
> 
> Hi Kris,
> 
> unfortunately, there isn't a turn-key solution implemented for
> this at the moment, but this would be something very useful and
> something I've been wanting to see in matplotlib, but never had a
> strong enough need to implement myself.
> 
> Take a look here for the type of machinery that could be used to
> implement such functionality:
> 
> http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels

I should add that the overlaps and count_overlaps methods of 
mpl.transforms.Bbox could be used for some sort of iterative
solution, as you can get the bounding box using

  a = plt.annotate("Foo",(1,2))
  bbox = a.get_window_extent()

Also, depeding on the number of labels and the need for reproducibility
of plots, you can just make the labels draggable, and move them
around using the mouse

  a.draggable()

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Is it possible to plot axes with arrows ?

2011-02-03 Thread Paul Ivanov

From: Paul Ivanov 
To: Francois Maltey 
Cc: 
cc: 
Subject: Re: [Matplotlib-users] Is it possible to plot axes with arrows ?
Reply-To: 
In-Reply-To: <4d496f84.7070...@nerim.fr>
X-PGP-Key: http://pirsquared.org/PaulIvanov0F3E28F7.asc

Francois Maltey, on 2011-02-02 15:51,  wrote:
> Hello,
> 
> I use matplolib by the mathematical system Sage in order to plot a function.
> The Sage code calls matplotlib and uses its options : The Sage command is
> 
> plot (sin, x, -5, 5)
> 
> I add labels par axes_labels or remove axes by :
> 
> plot (sin(x), x, -5, 5, axes_label = ['x', 'y'])
> plot (sin(x), x, -5, 5, axes=false)
> 
> French users (and maybe others) uses arrows and not lines for axes.
> I'm looking for a plot (sin(x), x, -5, 5, axes="arrows")
> Is there a pretty way to get these arrows. The result of this code isn't 
> so fine.
> length, width and color don't match.
> 
> plot (sin(x), x, -5, 5, axes=false) + arrow ((-5,0),(5,0)) + arrow 
> ((0,-1),(0,1))
> 
> What options do you propose ?
> I don't find relevant answers in the archive.

Hi Francois,

I'm not sure I understand - but do you want the arrows at the end
of the axes spines? I don't think there's a direct way to adjust
the spines to become arrows at the moment, but we can remedy that
by making annotations in axes coordinates.  The important thing
to know here is that in axes coordinates, which are always
between 0-1, spine endpoints are at these locations: (0,0),
(0,1), (1,0), and (1,1).  Here's the code, and attached is the
resulting image

  import matplotlib.pyplot as plt
  ax = plt.subplot(1,1,1)
  
  al = 7 # arrow length in points
  arrowprops=dict(clip_on=False, # plotting outside axes on purpose
  frac=1., # make end arrowhead the whole size of arrow
  headwidth=al, # in points
  facecolor='k')
  kwargs = dict(  
  xycoords='axes fraction',
  textcoords='offset points',
  arrowprops= arrowprops,
   )
  
  ax.annotate("",(1,0),xytext=(-al,0), **kwargs) # bottom spine arrow
  ax.annotate("",(0,1),xytext=(0,-al), **kwargs) # left spin arrow
  
  # hide the top and right spines
  [sp.set_visible(False) for sp in ax.spines['top'],ax.spines['right']]
  
  #hide the right and top tick marks
  ax.yaxis.tick_left()
  ax.xaxis.tick_bottom()
  
  x = np.linspace(-5,5,50)
  ax.plot(x, np.sin(x))
  
  # adjust the view a little bit
  ax.set_xlim(-5,5)
  ax.set_ylim(-1.1,1.1)
  plt.draw()

I'm not familiar with how SAGE exposes matplotlib functionality,
though, since the syntax you used differs from how matplotlib is
utilized.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<>

signature.asc
Description: Digital signature
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] hide labels

2011-02-06 Thread Paul Ivanov
Francesco Montesano, on 2011-02-04 17:01,  wrote:
> Dear all again,
> 
> I've tried to play with it again, but I couldn't find a
> solution for the problem.  For clarity I report an example of
> what each of the subplots looks like:

Hi Francesco,

thanks for the clarification, here are two ways to get the look
you want. I added some comments to help you understand what was
going on before. (The resulting figure is attached, just in case).

import numpy as np
import matplotlib.pyplot as plt
mean=np.array([-0.9206394, -0.90127456, -0.91983625, -0.97765539, -1.02991184,
-1.02267017, -0.97730167, -0.93715172, -0.94324653, -0.92884379])
stddev= np.array([0.16351397,0.15075966,0.13413909,0.15404823,0.13559582, 
0.13109754,0.12128598,0.11589682,0.11921571,0.10866761])

ax = plt.figure().add_axes([0.1,0.1,0.8,0.8])
ax.errorbar(np.arange(10,20)/100., mean, yerr=stddev)

ax.set_xlim([0.095, 0.195])

lab = ax.get_ymajorticklabels()
plt.draw() # ticks only get text assigned during a call to draw
print lab
for i in lab: 
print i # note that \u2212 is a unicode minus sign

# this work for the first draw - relies on l.get_text() returning
# nothing for labels which aren't used/drawn - which isn't the
# case in general after panning and zooming interactively
shown_lab = [l for l in lab if l.get_text()]
shown_lab[0].set_visible(False)
shown_lab[-1].set_visible(False)

## alternative solution without extra draw(). more robust, can be
## used even after initial draw.
#ymin,ymax = ax.get_ylim()
#tl = ax.yaxis.get_majorticklocs()
#lab[(tlymax).sum()-1].set_visible(False)

## hybrid of the two.
#ymin,ymax = ax.get_ylim()
#tl = ax.yaxis.get_majorticklocs()
#shown_lab = [l for l,t  in zip(lab,tl) if t>ymin and thttp://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
<>

signature.asc
Description: Digital signature
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


  1   2   >