Re: [Matplotlib-users] Problem with text bounding box

2012-09-04 Thread Eric Firing
On 2012/09/03 8:33 PM, Jakob Gager wrote:
> On 09/03/2012 08:57 PM, Eric Firing wrote:
>> It looks like you can either use the _get_layout() method (which
>> requires that you specify the renderer), or, if you know the text object
>> will be among the last 50 for which _get_layout() has been called, you
>> can use txt1.cached[txt1.get_prop_typ()].
>>
>>>
>>> Is there a different way to achieve a fitted text object?
>>
>> Not that I know of; but someone else may have a suggestion.
>>
>> Eric
>
> Many thanks for the quick and valuable return. I now use the _get_layout() 
> method and
> it works like a charm :)
>
> Just replaced:
> sf1 = 6*72./txt1.cached.items()[0][1][1][0][1][0]
> with:
> sf1 = 6*72./txt1._get_layout('GTKAgg')[1][0][1][0]

Jakob,

What is actually happening here is that the first two lines of 
_get_layout() are equivalent to the second method I suggested (that's 
where I got the idea for that method), and the renderer argument is 
never being used. This is good, because the renderer argument would have 
to be a renderer instance, not the string name of a backend.

There is also the caution that the leading underscore means 
_get_layout() is intended for internal mpl use only, and subject to 
change without notice. So, with some future version of mpl, you may need 
to change your code again.

Eric


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


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


Re: [Matplotlib-users] Problem with text bounding box

2012-09-04 Thread Jakob Gager
On 09/04/2012 09:13 AM, Eric Firing wrote:
> On 2012/09/03 8:33 PM, Jakob Gager wrote:
>> On 09/03/2012 08:57 PM, Eric Firing wrote:
>>> It looks like you can either use the _get_layout() method (which
>>> requires that you specify the renderer), or, if you know the text object
>>> will be among the last 50 for which _get_layout() has been called, you
>>> can use txt1.cached[txt1.get_prop_typ()].
>>>
>>> Eric
>>
>> Many thanks for the quick and valuable return. I now use the _get_layout() 
>> method and
>> it works like a charm :)
>>
>> Just replaced:
>> sf1 = 6*72./txt1.cached.items()[0][1][1][0][1][0]
>> with:
>> sf1 = 6*72./txt1._get_layout('GTKAgg')[1][0][1][0]
>
> Jakob,
>
> What is actually happening here is that the first two lines of
> _get_layout() are equivalent to the second method I suggested (that's
> where I got the idea for that method), and the renderer argument is
> never being used. This is good, because the renderer argument would have
> to be a renderer instance, not the string name of a backend.
>
> There is also the caution that the leading underscore means
> _get_layout() is intended for internal mpl use only, and subject to
> change without notice. So, with some future version of mpl, you may need
> to change your code again.
>
> Eric
>
Hi Eric,

does this mean you would suggest to use txt1.cached[txt1.get_prop_tup()] to be 
on the save side for 
future versions? I'm aware of the leading underscore notation, however, the 
txt.cached dictionary has 
changed as well (without leading underscore and notice?), therefore, slight 
modifications in the scrips
cannot be precluded anyway.

Regarding the renderer argument...
I first thought about passing a renderer instance to the _get_layout method, 
but as I had no clue where 
to get this instance from. So I simply tried with the backend name and luckly 
it worked :).

Thanks again, and have a nice day!
Jakob

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


Re: [Matplotlib-users] Problem with text bounding box

2012-09-04 Thread Eric Firing
On 2012/09/03 9:36 PM, Jakob Gager wrote:
> On 09/04/2012 09:13 AM, Eric Firing wrote:
>> On 2012/09/03 8:33 PM, Jakob Gager wrote:
>>> On 09/03/2012 08:57 PM, Eric Firing wrote:
 It looks like you can either use the _get_layout() method (which
 requires that you specify the renderer), or, if you know the text object
 will be among the last 50 for which _get_layout() has been called, you
 can use txt1.cached[txt1.get_prop_typ()].

 Eric
>>>
>>> Many thanks for the quick and valuable return. I now use the _get_layout() 
>>> method and
>>> it works like a charm :)
>>>
>>> Just replaced:
>>> sf1 = 6*72./txt1.cached.items()[0][1][1][0][1][0]
>>> with:
>>> sf1 = 6*72./txt1._get_layout('GTKAgg')[1][0][1][0]
>>
>> Jakob,
>>
>> What is actually happening here is that the first two lines of
>> _get_layout() are equivalent to the second method I suggested (that's
>> where I got the idea for that method), and the renderer argument is
>> never being used. This is good, because the renderer argument would have
>> to be a renderer instance, not the string name of a backend.
>>
>> There is also the caution that the leading underscore means
>> _get_layout() is intended for internal mpl use only, and subject to
>> change without notice. So, with some future version of mpl, you may need
>> to change your code again.
>>
>> Eric
>>
> Hi Eric,
>
> does this mean you would suggest to use txt1.cached[txt1.get_prop_tup()] to 
> be on the save side for
> future versions? I'm aware of the leading underscore notation, however, the 
> txt.cached dictionary has
> changed as well (without leading underscore and notice?), therefore, slight 
> modifications in the scrips
> cannot be precluded anyway.

You are right; although it lacks the underscore, I doubt the "cached" 
attribute and the "get_prop_tup()" method were intended for anything but 
internal use.  There is no safe solution!

>
> Regarding the renderer argument...
> I first thought about passing a renderer instance to the _get_layout method, 
> but as I had no clue where
> to get this instance from. So I simply tried with the backend name and luckly 
> it worked :).

That's the advantage of the txt1.cached[] approach; it doesn't require 
you to supply a bogus but unused argument.  It's probably what I would pick.

In any case, I'm glad you are back in business.

Eric

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


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


Re: [Matplotlib-users] strange behaviour with fill_between

2012-09-04 Thread Francesco Montesano
Dear Eric,

sorry for the delay in replying, and thanking: I forgot the mail after
reading it.

2012/8/30 Eric Firing :
> On 2012/08/27 5:10 AM, Francesco Montesano wrote:
>> Dear matplotlibers,
>>
>> I encountered a bug (?) in fill_between when using logarithmic scales and
>> the last part of y and yerr arrays as set to zero: a diagonal stripe going 
>> from
>> the rightmost non zero value to the first value is drawn.
>> It's visible in the right panel of the attached figure, while is not
>> present if the plot is linear (left panel).
>> If xaxis is log and yaxis is linear the plot is correctly drawn.
>>
>> I'm using mpl.__version__ = '1.1.1rc' under Kubuntu 12.04 with Python 2.7.3
>>
>> The plot has been created with the script below.
>>
>> Is this a bug or am I missing something?
>
> I don't think it is exactly a bug, but I don't know why the fill region
> is appearing as it does.  The underlying problem is that fill_between is
> doing what it is told to do without knowing that it is going to be
> plotted on a log axis.
I think that also most of the other plotting functions (e.g. errorbar)
do not know about the scale used on the axis, but they behave
correctly. Am I right?


> A good workaround is to change your call to fill_between to look like this:
> positive = y - yerr > 0
> ax2.fill_between( x,y-yerr,y+yerr, where=positive, color='b', alpha=0.4)
>
> Alternatively, you could use np.clip to put a floor under y - yerr and y
> + yerr.

The workaround works fine, but I dare say that it's not THE solution.
I think that the problem lies in the way PolyCollection is drawn when
y=yerr=0 (and probably also if y+- yerr <=0) if the yaxis is log. I
have no clue where to look in the source to go deeper in the problem.

cheers,
Fra

> Eric
>
>>
>> Cheers
>> Francesco
>>
>>
>> # error_fill_between.py ##
>> import matplotlib.pyplot as plt
>> import numpy as np
>>
>> #values to plot
>> x = np.linspace( 1, 10, num=100 )
>> y = np.exp( -x**2 )
>> y[50:] = 0
>> yerr = y* np.random.rand(100)
>>
>> #figure
>> fig = plt.figure()
>>
>> ax1 = fig.add_subplot(121)  #first axes: linear
>> ax1.errorbar( x,y,yerr, c='r' )
>> ax1.fill_between( x,y-yerr,y+yerr, color='b', alpha=0.4 )
>>
>> ax2 = fig.add_subplot(122)  #second axes: logarithmic
>> ax2.errorbar( x,y,yerr, c='r' )
>> ax2.fill_between( x,y-yerr,y+yerr, color='b', alpha=0.4 )
>> ax2.set_xscale( "log" )
>> ax2.set_yscale( "log" )
>>
>> plt.show()
>> ## end script  #
>>
>>
>>
>> --
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>
>>
>>
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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


Re: [Matplotlib-users] animation framework problem

2012-09-04 Thread Benjamin Root
On Mon, Sep 3, 2012 at 4:26 PM, Gyro Funch  wrote:

> Hi,
>
> I am trying to create a multi-subplot animation with based loosely
> on the animation example code, subplots.py, at
> http://matplotlib.sourceforge.net/examples/animation/subplots.html
>
> A simplified version of the full code is shown at this gist:
> https://gist.github.com/3613113
>
> I am having problems getting the code to function properly. If I run
> it as is, the figure appears, but no animation is done. Apparently
> the setup code is called, but the code to change the frames is not.
> If I comment out the call to the setup code, the method to update
> the frame is called once, and that is it.
>
> I would appreciate any help and insights that you can provide.
>
> Thank you very much.
>
> -g
>
>
>
Confirmed.  I do not see any immediate reason why your code doesn't work.
I suggest filing an issue on our github site.

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


Re: [Matplotlib-users] animation framework problem

2012-09-04 Thread gyro funch
On 2012-09-04 10:53 AM, Benjamin Root wrote:
> 
> On Mon, Sep 3, 2012 at 4:26 PM, Gyro Funch  > wrote:
> 
> Hi,
> 
> I am trying to create a multi-subplot animation with based loosely
> on the animation example code, subplots.py, at
> http://matplotlib.sourceforge.net/examples/animation/subplots.html
> 
> A simplified version of the full code is shown at this gist:
> https://gist.github.com/3613113
> 
> I am having problems getting the code to function properly. If I run
> it as is, the figure appears, but no animation is done. Apparently
> the setup code is called, but the code to change the frames is not.
> If I comment out the call to the setup code, the method to update
> the frame is called once, and that is it.
> 
> I would appreciate any help and insights that you can provide.
> 
> Thank you very much.
> 
> -g
> 
> 
> 
> Confirmed.  I do not see any immediate reason why your code doesn't
> work.  I suggest filing an issue on our github site.
> 
> Ben Root
> 

Thanks for the feedback.

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

-g

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


[Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

2012-09-04 Thread Paul Tremblay
The following Python code:

>>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)

Produces this error with Python 3.2:

Traceback (most recent call last):
  File "scripts/audit_reports_weekly.py", line 150, in 
ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
  File
"/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
line 6741, in fill_between
y1 = ma.masked_invalid(self.convert_yunits(y1))
  File
"/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
line 2241, in masked_invalid
condition = ~(np.isfinite(a))
TypeError: ufunc 'isfinite' not supported for the input types, and the
inputs could not be safely coerced to any supported types according to the
casting rule ''safe''


[Decimal('3619.900530366609820157812617'), .]

If I change the list from type Decimal to type float, then I don't get the
error. Likewise, if I use Python 2.7, I also don't get an error.

After reading over the error message, I realize that this error really
results because of numpy, not matplotlib. But I'll go ahead and post this
message, in case you are unaware of the problem.
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

2012-09-04 Thread Benjamin Root
On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay wrote:

>
> The following Python code:
>
> >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>
> Produces this error with Python 3.2:
>
> Traceback (most recent call last):
>   File "scripts/audit_reports_weekly.py", line 150, in 
> ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>   File
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> line 6741, in fill_between
> y1 = ma.masked_invalid(self.convert_yunits(y1))
>   File
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> line 2241, in masked_invalid
> condition = ~(np.isfinite(a))
> TypeError: ufunc 'isfinite' not supported for the input types, and the
> inputs could not be safely coerced to any supported types according to the
> casting rule ''safe''
>
>
> [Decimal('3619.900530366609820157812617'), .]
>
> If I change the list from type Decimal to type float, then I don't get the
> error. Likewise, if I use Python 2.7, I also don't get an error.
>
> After reading over the error message, I realize that this error really
> results because of numpy, not matplotlib. But I'll go ahead and post this
> message, in case you are unaware of the problem.
>
>
Just a quick note, mpl v1.1.x is not officially supported for py3k.  The
upcoming release of v1.2.0 will be the first official release with such
support.

That being said, it probably would be a good idea to make sure where the
bug lies for this one (numpy or matplotlib).  Which version of numpy are
you using?

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


Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

2012-09-04 Thread Eric Firing
On 2012/09/04 9:09 AM, Benjamin Root wrote:
>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay  > wrote:
>
>
> The following Python code:
>
>  >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>
> Produces this error with Python 3.2:
>
> Traceback (most recent call last):
>File "scripts/audit_reports_weekly.py", line 150, in 
>  ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>File
> 
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> line 6741, in fill_between
>  y1 = ma.masked_invalid(self.convert_yunits(y1))
>File
> 
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> line 2241, in masked_invalid
>  condition = ~(np.isfinite(a))
> TypeError: ufunc 'isfinite' not supported for the input types, and
> the inputs could not be safely coerced to any supported types
> according to the casting rule ''safe''
>
>
> [Decimal('3619.900530366609820157812617'), .]
>
> If I change the list from type Decimal to type float, then I don't
> get the error. Likewise, if I use Python 2.7, I also don't get an error.
>
> After reading over the error message, I realize that this error
> really results because of numpy, not matplotlib. But I'll go ahead
> and post this message, in case you are unaware of the problem.
>
>
> Just a quick note, mpl v1.1.x is not officially supported for py3k.  The
> upcoming release of v1.2.0 will be the first official release with such
> support.
>
> That being said, it probably would be a good idea to make sure where the
> bug lies for this one (numpy or matplotlib).  Which version of numpy are
> you using?

Should this be considered a bug?  Or should we say that we don't support 
Decimal inputs?  If we are going to support Decimal inputs, then we need 
to put in filters to force conversion to float.  Do you want to have to 
check every entry in every list input to see if it Decimal?

Eric

>
> Ben Root


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


Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

2012-09-04 Thread Benjamin Root
On Tue, Sep 4, 2012 at 3:24 PM, Eric Firing  wrote:

> On 2012/09/04 9:09 AM, Benjamin Root wrote:
> >
> >
> > On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay  > > wrote:
> >
> >
> > The following Python code:
> >
> >  >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
> >
> > Produces this error with Python 3.2:
> >
> > Traceback (most recent call last):
> >File "scripts/audit_reports_weekly.py", line 150, in 
> >  ax.fill_between(dates, lower, upper, facecolor='gray',
> alpha=0.5)
> >File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> > line 6741, in fill_between
> >  y1 = ma.masked_invalid(self.convert_yunits(y1))
> >File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> > line 2241, in masked_invalid
> >  condition = ~(np.isfinite(a))
> > TypeError: ufunc 'isfinite' not supported for the input types, and
> > the inputs could not be safely coerced to any supported types
> > according to the casting rule ''safe''
> >
> >
> > [Decimal('3619.900530366609820157812617'), .]
> >
> > If I change the list from type Decimal to type float, then I don't
> > get the error. Likewise, if I use Python 2.7, I also don't get an
> error.
> >
> > After reading over the error message, I realize that this error
> > really results because of numpy, not matplotlib. But I'll go ahead
> > and post this message, in case you are unaware of the problem.
> >
> >
> > Just a quick note, mpl v1.1.x is not officially supported for py3k.  The
> > upcoming release of v1.2.0 will be the first official release with such
> > support.
> >
> > That being said, it probably would be a good idea to make sure where the
> > bug lies for this one (numpy or matplotlib).  Which version of numpy are
> > you using?
>
> Should this be considered a bug?  Or should we say that we don't support
> Decimal inputs?  If we are going to support Decimal inputs, then we need
> to put in filters to force conversion to float.  Do you want to have to
> check every entry in every list input to see if it Decimal?
>
> Eric
>
>
Looking at the message, it is saying that the np.isfinite() function fails
on Decimal inputs.  From our perspective, a Decimal input should look just
the same as integer and floats (following the duck-typing paradigm).
Therefore, I think this problem lies squarely at the feet of numpy.
However, I am doubtful of just how quickly to expect this issue to be
solved by them.

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


Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

2012-09-04 Thread Eric Firing
On 2012/09/04 9:09 AM, Benjamin Root wrote:
>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay  > wrote:
>
>
> The following Python code:
>
>  >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>
> Produces this error with Python 3.2:
>
> Traceback (most recent call last):
>File "scripts/audit_reports_weekly.py", line 150, in 
>  ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>File
> 
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> line 6741, in fill_between
>  y1 = ma.masked_invalid(self.convert_yunits(y1))
>File
> 
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> line 2241, in masked_invalid
>  condition = ~(np.isfinite(a))
> TypeError: ufunc 'isfinite' not supported for the input types, and
> the inputs could not be safely coerced to any supported types
> according to the casting rule ''safe''
>
>
> [Decimal('3619.900530366609820157812617'), .]
>
> If I change the list from type Decimal to type float, then I don't
> get the error. Likewise, if I use Python 2.7, I also don't get an error.
>
> After reading over the error message, I realize that this error
> really results because of numpy, not matplotlib. But I'll go ahead
> and post this message, in case you are unaware of the problem.
>
>
> Just a quick note, mpl v1.1.x is not officially supported for py3k.  The
> upcoming release of v1.2.0 will be the first official release with such
> support.
>
> That being said, it probably would be a good idea to make sure where the
> bug lies for this one (numpy or matplotlib).  Which version of numpy are
> you using?

To clarify my previous message: I think we will remain mostly at the 
mercy of numpy, which may change from version to version, to determine 
what we can handle.  Apart from registered unit types, we fall back on 
numpy, typically masked_invalid, to handle inputs.  If we really want to 
handle Decimal reliably, then it probably has to be done within the 
units framework.

Eric


>
> Ben Root


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


Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

2012-09-04 Thread Drain, Theodore R (343P)
Isn't that what the unit system is for?  It allows users to use whatever 
objects they want and register conversions to/from MPL types.  If Decimal is a 
common use-case, then perhaps MPL should provide those converters but the user 
would (and probably should) still need to activate them.


From: Eric Firing [efir...@hawaii.edu]
Sent: Tuesday, September 04, 2012 12:24 PM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of 
matplotlib (numpy error)

On 2012/09/04 9:09 AM, Benjamin Root wrote:
>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay  > wrote:
>
>
> The following Python code:
>
>  >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>
> Produces this error with Python 3.2:
>
> Traceback (most recent call last):
>File "scripts/audit_reports_weekly.py", line 150, in 
>  ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>File
> 
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> line 6741, in fill_between
>  y1 = ma.masked_invalid(self.convert_yunits(y1))
>File
> 
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> line 2241, in masked_invalid
>  condition = ~(np.isfinite(a))
> TypeError: ufunc 'isfinite' not supported for the input types, and
> the inputs could not be safely coerced to any supported types
> according to the casting rule ''safe''
>
>
> [Decimal('3619.900530366609820157812617'), .]
>
> If I change the list from type Decimal to type float, then I don't
> get the error. Likewise, if I use Python 2.7, I also don't get an error.
>
> After reading over the error message, I realize that this error
> really results because of numpy, not matplotlib. But I'll go ahead
> and post this message, in case you are unaware of the problem.
>
>
> Just a quick note, mpl v1.1.x is not officially supported for py3k.  The
> upcoming release of v1.2.0 will be the first official release with such
> support.
>
> That being said, it probably would be a good idea to make sure where the
> bug lies for this one (numpy or matplotlib).  Which version of numpy are
> you using?

Should this be considered a bug?  Or should we say that we don't support
Decimal inputs?  If we are going to support Decimal inputs, then we need
to put in filters to force conversion to float.  Do you want to have to
check every entry in every list input to see if it Decimal?

Eric

>
> Ben Root


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


Re: [Matplotlib-users] Limit data for plot Basemap

2012-09-04 Thread Benjamin Root
On Fri, Aug 24, 2012 at 12:21 PM, John Bluee  wrote:

> I have lat and lon as coordinates and to each point a value. So far I use
> contourf to plot.
>
>
Sorry for not getting back to you sooner.  May I suggest the following:

values = np.ma.masked_outside(values, -1e-8, 1e-9, copy=False)
values = np.ma.masked_inside(values, -1e-14, 1e14, copy=False)

And then contourf the masked values array.  Any places where the values are
masked will be blank.

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


Re: [Matplotlib-users] Legend Marker Color Bug

2012-09-04 Thread Sterling Smith
On Aug 31, 2012, at 11:29AM, Goyo wrote:

> 2012/8/30 Sterling Smith :
> 
>> Thank you for taking the time to consider my question.  I'm sorry that I 
>> didn't pose my question correctly.  I should have said: 'Consider the 
>> _results_ of the following script:'  I originally tried to attach the 
>> results I obtained, which showed no change in color for the markers in the 
>> legend, while the line connecting the markers in the legend did change color.
> 
> Actualy your question is correctly posted but I misread it. Calling
> set_color changes only the line color, not the markers. This is
> expected and documented behavoir. There are separate methods for the
> markers:
> 
> line[0].set_markerfacecolor
> line[0].set_markeredgecolor
> 
> See 
> http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D
> 
> Regards
> 
> Goyo

Goyo,

Again I thank you for taking time to look into this.  You are correct that 
there are separate functions for setting the marker properties vs the line 
properties.  However, I have tried your solution, and it does not work.  Given 
the following code:

import pylab
pylab.plot(pylab.linspace(0,1,100),label='Test',marker='o',ls='')
pylab.plot(pylab.linspace(0,1,100),label='Test2',marker='o',ls='-')
leg=pylab.legend(loc='best')
line=leg.get_lines()
line[0].set_markerfacecolor('black')
line[1].set_markerfacecolor('black')
pylab.draw()

I still do not get black markers.  Furthermore, if you try to make a new legend 
with the result of leg.get_lines(), you will get lines without markers, which 
leads me to the conclusion I stated in my previous email (which you did not 
copy)
>> I suspect that this is because the legend marker is drawn separately from 
>> the legend line to accommodate the numpoints argument of the legend 
>> functions.  Then the question is how to access these markers if they are 
>> separate from the line2d objects in the legend.  I didn't even see them in 
>> the children of the legend [legend.get_children()].


Thanks,
Sterling


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


[Matplotlib-users] 1.1.1 fails to build on Linux

2012-09-04 Thread Roy Crihfield
Attempting to install matplotlib with easy_install for python 3.2.3 on
Linux (3.5.3-1-ARCH) fails like so.

I have the freetype2 and numpy packages as you can see, and I have
tried building from source with the same results.


Processing matplotlib-1.1.1.tar.gz
Writing /tmp/easy_install-quuxcl/matplotlib-1.1.1/setup.cfg
Running matplotlib-1.1.1/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-quuxcl/matplotlib-1.1.1/egg-dist-tmp-4wc3xh
basedirlist is: ['/usr/local', '/usr']

BUILDING MATPLOTLIB
matplotlib: 1.1.1
python: 3.2.3 (default, Apr 23 2012, 23:14:44)  [GCC 4.7.0
20120414 (prerelease)]
  platform: linux2

REQUIRED DEPENDENCIES
 numpy: 1.6.2
 freetype2: 15.0.9

OPTIONAL BACKEND DEPENDENCIES
libpng: 1.5.12
   Tkinter: no
* TKAgg requires Tkinter
  Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to "import gtk" in your build/install environment
   Mac OS X native: no
Qt: no
   Qt4: no
PySide: no
 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
  datetime: present, version unknown
  dateutil: 2.1
  pytz: 2012d

OPTIONAL USETEX DEPENDENCIES
dvipng: no
   ghostscript: 9.06
 latex: no
   pdftops: 0.20.3

[Edit setup.cfg to suppress the above messages]

pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends',
'matplotlib.backends.qt4_editor', 'matplotlib.projections',
'matplotlib.testing', 'matplotlib.testing.jpl_units',
'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d',
'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1',
'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri',
'matplotlib.delaunay']
warning: no files found matching 'KNOWN_BUGS'
warning: no files found matching 'INTERACTIVE'
warning: no files found matching 'MANIFEST'
warning: no files found matching '__init__.py'
warning: no files found matching 'examples/data/*'
warning: no files found matching 'lib/mpl_toolkits'
warning: no files found matching 'LICENSE*' under directory 'license'
src/ft2font.cpp: In member function ‘Py::Object
FT2Image::py_draw_rect(const Py::Tuple&)’:
src/ft2font.cpp:241:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:242:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:243:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:244:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp: In member function ‘Py::Object
FT2Image::py_draw_rect_filled(const Py::Tuple&)’:
src/ft2font.cpp:284:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:285:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:286:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:287:15: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp: In member function ‘Py::Object
FT2Image::py_as_str(const Py::Tuple&)’:
src/ft2font.cpp:308:49: error: ‘PyString_FromStringAndSize’ was not
declared in this scope
src/ft2font.cpp: In member function ‘Py::Object
FT2Image::py_get_width(const Py::Tuple&)’:
src/ft2font.cpp:432:12: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp: In member function ‘Py::Object
FT2Image::py_get_height(const Py::Tuple&)’:
src/ft2font.cpp:441:12: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp: In constructor ‘Glyph::Glyph(FT_FaceRec_* const&,
FT_GlyphRec_* const&, size_t)’:
src/ft2font.cpp:452:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:453:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:454:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:455:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:456:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:457:35: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:458:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:460:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:461:29: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:467:16: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:468:16: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:469:16: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:470:16: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp: In constructor ‘FT2Font::FT2Font(std::string)’:
src/ft2font.cpp:933:32: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:936:32: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:937:32: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:938:32: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:939:32: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:940:32: error: ‘Int’ is not a member of ‘Py’
src/ft2font.cpp:944:25: error: ‘Int’ is not a member of ‘Py’
sr

Re: [Matplotlib-users] 1.1.1 fails to build on Linux

2012-09-04 Thread Michael Droettboom
matplotlib 1.1.1 does not support Python 3.x.  You will need to build 
from git master for the time being.  We should also have a 1.2rc out in 
the next weeks which will support Python 3.


On 09/04/2012 07:09 PM, Roy Crihfield wrote:

Attempting to install matplotlib with easy_install for python 3.2.3 on Linux 
(3.5.3-1-ARCH) fails like so.

I have the freetype2 and numpy packages as you can see, and I have tried 
building from source with the same results.



Processing matplotlib-1.1.1.tar.gz
Writing /tmp/easy_install-quuxcl/matplotlib-1.1.1/setup.cfg
Running matplotlib-1.1.1/setup.py -q bdist_egg --dist-dir 
/tmp/easy_install-quuxcl/matplotlib-1.1.1/egg-dist-tmp-4wc3xh
basedirlist is: ['/usr/local', '/usr']

BUILDING MATPLOTLIB
 matplotlib: 1.1.1
 python: 3.2.3 (default, Apr 23 2012, 23:14:44)  [GCC 4.7.0
 20120414 (prerelease)]
   platform: linux2

REQUIRED DEPENDENCIES
  numpy: 1.6.2
  freetype2: 15.0.9

OPTIONAL BACKEND DEPENDENCIES
 libpng: 1.5.12
Tkinter: no
 * TKAgg requires Tkinter
   Gtk+: no
 * Building for Gtk+ requires pygtk; you must be able
 * to "import gtk" in your build/install environment
Mac OS X native: no
 Qt: no
Qt4: no
 PySide: no
  Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
   datetime: present, version unknown
   dateutil: 2.1
   pytz: 2012d

OPTIONAL USETEX DEPENDENCIES
 dvipng: no
ghostscript: 9.06
  latex: no
pdftops: 0.20.3

[Edit setup.cfg to suppress the above messages]

pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 
'matplotlib.backends.qt4_editor', 'matplotlib.projections', 
'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 
'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 
'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 
'matplotlib.tri', 'matplotlib.delaunay']
warning: no files found matching 'KNOWN_BUGS'
warning: no files found matching 'INTERACTIVE'
warning: no files found matching 'MANIFEST'
warning: no files found matching '__init__.py'
warning: no files found matching 'examples/data/*'
warning: no files found matching 'lib/mpl_toolkits'
warning: no files found matching 'LICENSE*' under directory 'license'
src/ft2font.cpp: In member function 'Py::Object FT2Image::py_draw_rect(const 
Py::Tuple&)':
src/ft2font.cpp:241:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:242:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:243:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:244:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp: In member function 'Py::Object FT2Image::py_draw_rect_filled(const 
Py::Tuple&)':
src/ft2font.cpp:284:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:285:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:286:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:287:15: error: 'Int' is not a member of 'Py'
src/ft2font.cpp: In member function 'Py::Object FT2Image::py_as_str(const 
Py::Tuple&)':
src/ft2font.cpp:308:49: error: 'PyString_FromStringAndSize' was not declared in 
this scope
src/ft2font.cpp: In member function 'Py::Object FT2Image::py_get_width(const 
Py::Tuple&)':
src/ft2font.cpp:432:12: error: 'Int' is not a member of 'Py'
src/ft2font.cpp: In member function 'Py::Object FT2Image::py_get_height(const 
Py::Tuple&)':
src/ft2font.cpp:441:12: error: 'Int' is not a member of 'Py'
src/ft2font.cpp: In constructor 'Glyph::Glyph(FT_FaceRec_* const&, FT_GlyphRec_* 
const&, size_t)':
src/ft2font.cpp:452:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:453:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:454:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:455:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:456:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:457:35: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:458:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:460:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:461:29: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:467:16: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:468:16: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:469:16: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:470:16: error: 'Int' is not a member of 'Py'
src/ft2font.cpp: In constructor 'FT2Font::FT2Font(std::string)':
src/ft2font.cpp:933:32: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:936:32: error: 'Int' is not a member of 'Py'
src/ft2font.cpp:937:32: error: 

Re: [Matplotlib-users] Legend Marker Color Bug

2012-09-04 Thread Jae-Joon Lee
On Wed, Sep 5, 2012 at 6:05 AM, Sterling Smith  wrote:
> I still do not get black markers.  Furthermore, if you try to make a new 
> legend with the result of leg.get_lines(), you will get lines without 
> markers, which leads me to the conclusion I stated in my previous email 
> (which you did not copy)
>>> I suspect that this is because the legend marker is drawn separately from 
>>> the legend line to accommodate the numpoints argument of the legend 
>>> functions.  Then the question is how to access these markers if they are 
>>> separate from the line2d objects in the legend.  I didn't even see them in 
>>> the children of the legend [legend.get_children()].

This is correct. To support legend handle like --o-- (i.e., no markers
at the ends), lines and markers are drawn as a separate artist. You
may use something like,

line[0]._legmarker.set_markerfacecolor('black')
line[1]._legmarker.set_markerfacecolor('black')

I, personally, recommend you to use a proxy artist.

http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

For example,

You may do something like

import pylab
pylab.plot(pylab.linspace(0,1,100),marker='o',ls='')
pylab.plot(pylab.linspace(0,1,100),marker='o',ls='-')

# creates artists for legend purpose only
l1, = pylab.plot(pylab.linspace(0,1,100), 'ko-')
l2, = pylab.plot(pylab.linspace(0,1,100), 'ko')
# remove them from the axes.
l1.remove()
l2.remove()

leg=pylab.legend([l1, l2], ["Test 1", "Test 2"], loc='best')

Regards,

-JJ

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


Re: [Matplotlib-users] Problems with rasterizing multiple elements

2012-09-04 Thread Jae-Joon Lee
I recommend you to use LineCollection as it is rasterized as a single image.

For example,

from matplotlib.collections import LineCollection
d = [np.array([ts[0], ys1]).T for ys1 in ys]

lc = LineCollection(d, color='r', lw=0.5, alpha=0.5,
rasterized=True)
ax.add_collection(lc)


ax.set_xlim(0, 7)
ax.set_ylim(-1, 1)


If you need to stick to plot command somehow, you need to create your
own artist.
There is a similar example,

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

Take a look at the FilteredArtistList class. Your draw method should
be something like

def draw(self, renderer):
renderer.start_rasterizing()
for a in self._artist_list:
a.draw(renderer)
renderer.stop_rasterizing()


IHTH,

-JJ


On Wed, Aug 22, 2012 at 2:45 AM, Peter St. John  wrote:
> Hi Everyone,
>
> I'm having problems when rasterizing many lines in a plot using the
> rasterized=True keyword using the pdf output.
> Some version info:
> matplotlib version 1.1.1rc
> ubuntu 12.04
> python 2.7.3
>
>
> Here's a basic example that demonstrates my problem:
> # Import matplotlib to create a pdf document
> import matplotlib
> matplotlib.use('Agg')
> from matplotlib.backends.backend_pdf import PdfPages
> pdf = PdfPages('rasterized_test.pdf')
>
> import matplotlib.pylab as plt
>
> # some test data
> import numpy as np
> ts = np.linspace(0,2*np.pi,100) * np.ones((200,100))
> ts += (np.linspace(0, np.pi, 200)[np.newaxis] * np.ones((100,200))).T
> ys = np.sin(ts)
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(ts[0], ys.T, color='r', lw=0.5, alpha=0.5, rasterized=True)
> pdf.savefig()
>
> pdf.close()
>
>
>
> Essentially, I have a lot (200 in this case) of closely overlapping lines
> which makes the resulting figure (not rasterized) overly difficult to load.
> I would like to rasterize these lines, such that the axis labels (and other
> elements of the plot, not shown) remain vectors while the solution
> trajectories are flattened to a single raster background. However, using the
> code above, the image still takes a long time to load since each trajectory
> is independently rasterized, resulting in multiple layers. (If I open the
> resulting pdf with a program like inkscape, I can manipulate each trajectory
> independently.)
>
> Is it possible to flatten all of the rasterized elements into a single
> layer, so the pdf size would be greatly reduced?
>
> Thanks,
> --Peter
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

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


Re: [Matplotlib-users] Fwd: zoomed in detail box

2012-09-04 Thread Jae-Joon Lee
On Mon, Aug 20, 2012 at 10:50 PM, darkside  wrote:
> I am using zoomed_inset_axes, but the default position overlaps the yticks
> and the parent axe ticks, so I am trying:
> axins = zoomed_inset_axes(ax,
> 3,bbox_to_anchor(0.5,1),bbox_transform=ax.figure.transFigure, loc=2)

This is supposed to work, and my quick test did work. Can you post a
complete but simple exampl?

Regards,

-JJ

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


Re: [Matplotlib-users] FancyBBox set_width

2012-09-04 Thread Jae-Joon Lee
On Sun, Aug 19, 2012 at 3:41 PM, Peter Combs  wrote:
> It seems like draw()ing the text object will reset the size of the BBox...
> Any idea how to fix this? At the moment, I'm experimenting with continually
> drawing, polling the get_width() method, and when it's too small, adding in
> spaces around the text field, but that seems both not to work reliably, and
> be an incredibly boneheaded way to go about it.
>
> I'm using matplotlib v. 1.1.0 if that makes a difference.
>
>
> --\
> |text  >
> --/
> not
> --\
> | text >
> --/

A recommended way of doing this is to make a custom BoxStyle,


from matplotlib.patches import BoxStyle
class MyRArrow(BoxStyle.RArrow):
def transmute(self, x0, y0, width, height, mutation_size):
# mutation_size is a fontsize in pixel scale.
total_width = mutation_size*10
dw = (total_width-width)*.5
p = BoxStyle.RArrow.transmute(self, x0-dw, y0, total_width, height,
  mutation_size)

return p

ax = subplot(111)
txtobj = ax.text(0.5, 0.5, 'text', ha="center",
 bbox=dict(boxstyle=MyRArrow()))

txtobj = ax.text(0.5, 0.3, 'long text', ha="center",
 bbox=dict(boxstyle=MyRArrow()))


However, BoxStyle does not know of the axes/figure/renderer, i.e., you
cannot make its width to some fraction of figure width, for example.
If this is what you want, you may need to derive from FancyBboxPatch
as Daniel Hyams suggested.

Regards,

-JJ

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