[Matplotlib-users] Improve the error message or introduce support for colors as RGS tuples

2012-04-13 Thread Martin Mokrejs
Hi,
  I am trying to improve my code where I cannot find out why matplotlib-1.1.0 
does not
support colors specified as RG tuples. Here is an example.



import numpy as np
import matplotlib.pyplot as plt

_nums = [160.0, 160.0, 160.0, 95.0, 160.0, 160.0]
_colors = [(0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 
0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255), 
(0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 
0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255)]
_legends = ['foo', 'foo', 'foo', 'blah', 'foo', 'foo']

plt.hist(_nums, histtype='bar', align='mid', color=_colors, log=False, 
label=_legends)

plt.show()


The above code gives me:

  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 2332, in 
hist
ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, 
histtype, align, orientation, rwidth, log, color, label, **kwargs)
  File "/usr/lib64/python2.7/site-packages/matplotlib/axes.py", line 7598, in 
hist
raise ValueError("color kwarg must have one color per dataset")
ValueError: color kwarg must have one color per dataset


Mainly, I am suggesting the error message to be improved and to write out how 
many
items were in data, color and legend iterables passed to the function. That 
would help
in some cases albeit not with this example. That needs some other fix. ;)

I would like that one can also pass in a list of HTML-like colors, e.g. 
'F0F8FF' or 0xF0F8FF
would be valid.

Thanks for your comments,
Martin

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Improve the error message or introduce support for colors as RGS tuples

2012-04-13 Thread Martin Mokrejs


Martin Mokrejs wrote:
> Hi,
>   I am trying to improve my code where I cannot find out why matplotlib-1.1.0 
> does not
> support colors specified as RG tuples. Here is an example.
> 
> 
> 
> import numpy as np
> import matplotlib.pyplot as plt
> 
> _nums = [160.0, 160.0, 160.0, 95.0, 160.0, 160.0]

Grr. This was the trick:

_nums = [[160.0], [160.0], [160.0], [95.0], [160.0], [160.0]]

What a wasteful list creation. :(


> _colors = [(0.5019607843137255, 0.0, 0.5019607843137255), 
> (0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 
> 0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255), 
> (0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 
> 0.5019607843137255)]
> _legends = ['foo', 'foo', 'foo', 'blah', 'foo', 'foo']
> 
> plt.hist(_nums, histtype='bar', align='mid', color=_colors, log=False, 
> label=_legends)
> 
> plt.show()
> 
> 
> The above code gives me:
> 
>   File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 2332, 
> in hist
> ret = ax.hist(x, bins, range, normed, weights, cumulative, bottom, 
> histtype, align, orientation, rwidth, log, color, label, **kwargs)
>   File "/usr/lib64/python2.7/site-packages/matplotlib/axes.py", line 7598, in 
> hist
> raise ValueError("color kwarg must have one color per dataset")
> ValueError: color kwarg must have one color per dataset
> 
> 
> Mainly, I am suggesting the error message to be improved and to write out how 
> many
> items were in data, color and legend iterables passed to the function. That 
> would help

Would it tells me my problem is not with color but with data points life would 
be much easier. ;)


> in some cases albeit not with this example. That needs some other fix. ;)
> 
> I would like that one can also pass in a list of HTML-like colors, e.g. 
> 'F0F8FF' or 0xF0F8FF
> would be valid.

Sorry, meant also '#F0F8FF', but now I have verified that they do work already:

_colors = ['b', 'b', 'b', 'r', 'b', 'b']
_colors = ['#C0C0C0', '#C0C0C0', '#C0C0C0', '#80', '#C0C0C0', '#C0C0C0']
_colors = [(0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 
0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255), 
(0.5019607843137255, 0.0, 0.5019607843137255), (0.5019607843137255, 0.0, 
0.5019607843137255), (0.5019607843137255, 0.0, 0.5019607843137255)]

So this was all about *data* points to be wrapped in iterables. :((

Martin

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Looking for additional help about moving a legend

2012-04-13 Thread Benjamin Root
On Fri, Apr 13, 2012 at 2:21 AM, Jonathan Bruck  wrote:

> Thanks for a response, but unfortunately it doesn't seem to work. I have
> some sample code on pastebin http://pastebin.com/W6JmbCsz in case the
> following does not email out well
>
> # -*- coding: utf-8 -*-
> """
> Created on Thu Apr 12 11:16:03 2012
>
> Using the current stable version of pythonxy on Windows 7 32bit
> Author: Jonathan
>
>
> Notice how the figure box is not placed correctly, effectively missing the
> legend entirely
> """
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> x = np.arange(-2*np.pi, 2*np.pi, 0.1)
> fig = plt.figure(1, figsize=(8,6))
> ax = fig.add_subplot(111)
> ax.plot(x, np.sin(x), label='Sine')
> ax.plot(x, np.cos(x), label='Cosine')
> ax.plot(x, np.arctan(x), label='Inverse tan')
> handles, labels = ax.get_legend_handles_labels()
> lgd = ax.legend(handles, labels, loc=9, bbox_to_anchor=(0.5,-0.1))
> ax.grid('on')
> #fig.tight_layout()
> fig.savefig('samplefigure', bbox_extra_artists=(lgd,), bbox='tight')
>
>
>
I apologize, it was bbox_inches='tight', not bbox='tight'.  Because savefig
has to be able to take arbitrary kwargs that get passed down to the
backends, it does not check for incorrect kwargs.

Ben Root
--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Matplotlib and Cpp

2012-04-13 Thread Ignas Anikevicius
Dear all,

I was wondering if it is possible to use matplotlib from C++ directly
and I have found an example on how to do this on StackOverflow:

http://stackoverflow.com/questions/2509156/anyone-knows-a-matplotlib-equivalent-in-c-or-c

However, my question is about piping. Where could I find any tutorials
on how to pipe data directly to matplotlib so that I would not need to
right it to a file and then read it?

Also, does matplotlib benefit from usage of cython and if it does, are
there any things I should know before just trying to compile a
matplotlib script with cython?

All best,
Ignas A.

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] corrupt pdf of histogram

2012-04-13 Thread Jouni K . Seppänen
Jouni K. Seppänen  writes:

> I have a suggested fix for this at
> https://github.com/matplotlib/matplotlib/pull/817 

This is now merged into the v1.1.x branch, from which the fix should
propagate to the upcoming release.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Focus in OSX

2012-04-13 Thread Elliot Saba
Confirmed, when I installed my python as a framework, (With homebrew, `brew
install python --framework`) the focus now works properly.
-E

On Thu, Apr 12, 2012 at 7:57 PM, Chris Laumann  wrote:

> Actually I don't know about the apple supplied python, but I believe
> enthoughts python is installed as a framework.
>
> C
>
>
>
> On Apr 12, 2012, at 8:53 PM, Michiel de Hoon  wrote:
>
> > --- On Wed, 4/11/12, Zachary Pincus  wrote:
> >> Hopefully someone who knows more about the OS X backend can
> >> comment here...
> >
> > It sounds like the Python you are using is not installed as a framework.
> Using the --enable-framework flag when compiling Python.
> >
> > -Michiel.
> >
> >
> --
> > For Developers, A Lot Can Happen In A Second.
> > Boundary is the first to Know...and Tell You.
> > Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> > http://p.sf.net/sfu/Boundary-d2dvs2
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> --
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Inconsistent Saving of Figures With Hatching

2012-04-13 Thread Patrick Marsh
Greetings,

I've noticed an issue when trying to create hatched plots. When I try
to create hatched plots with dashed lines, I get inconsistent behavior
between matplotlib.pyplot.show() and matplotlib.pyplot.savefig(). The
show() command will correctly (in terms of what I want) display the
hatched area as a dashed line, whereas savefig() will save an image
with the edge contour dashed, but the hatching as solid lines.

A self contained example script can be found here:
https://gist.github.com/2378109

For those who just want to see figures as to what I'm talking about
they can be found at the following.
What I want: http://www.patricktmarsh.com/tmp/correct_example.png
What I get: http://www.patricktmarsh.com/tmp/incorrect_example.png

What I want: http://www.patricktmarsh.com/tmp/correct_web.png
What I get: 
http://www.patricktmarsh.com/wp-content/gallery/2012images/20060406_day2_color.png


Thanks for any help!
Patrick
---
Patrick Marsh
Ph.D. Candidate / Liaison to the HWT
School of Meteorology / University of Oklahoma
Cooperative Institute for Mesoscale Meteorological Studies
National Severe Storms Laboratory
http://www.patricktmarsh.com

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Focus in OSX

2012-04-13 Thread Michiel de Hoon
OK, that is good to know.
The Apple-supplied python is not installed as a framework; I don't know for the 
Enthought distribution.
Anyway, the MacOSX backend checks whether your Python is installed as a 
framework, and it issues a warning if it is not installed as a framework. For 
your non-framework python, was this warning issued?

Best,
-Michiel.

--- On Fri, 4/13/12, Elliot Saba  wrote:

From: Elliot Saba 
Subject: Re: [Matplotlib-users] Focus in OSX
To: "Chris Laumann" 
Cc: "Michiel de Hoon" , 
"matplotlib-users@lists.sourceforge.net" 

Date: Friday, April 13, 2012, 4:57 PM

Confirmed, when I installed my python as a framework, (With homebrew, `brew 
install python --framework`) the focus now works properly.-E

On Thu, Apr 12, 2012 at 7:57 PM, Chris Laumann  
wrote:


Actually I don't know about the apple supplied python, but I believe enthoughts 
python is installed as a framework.





C







On Apr 12, 2012, at 8:53 PM, Michiel de Hoon  wrote:



> --- On Wed, 4/11/12, Zachary Pincus  wrote:

>> Hopefully someone who knows more about the OS X backend can

>> comment here...

>

> It sounds like the Python you are using is not installed as a framework. 
> Using the --enable-framework flag when compiling Python.

>

> -Michiel.

>

> --

> For Developers, A Lot Can Happen In A Second.

> Boundary is the first to Know...and Tell You.

> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!

> http://p.sf.net/sfu/Boundary-d2dvs2

> ___

> Matplotlib-users mailing list

> Matplotlib-users@lists.sourceforge.net

> https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--

For Developers, A Lot Can Happen In A Second.

Boundary is the first to Know...and Tell You.

Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!

http://p.sf.net/sfu/Boundary-d2dvs2

___

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users