Re: [Matplotlib-users] example of pareto chart

2012-09-24 Thread Paul Hobson
> On Mon, Sep 24, 2012 at 12:21 AM, Paul Tremblay 
> wrote:
>>
>> Here is my example of a Pareto chart.
>>
>> For an explanation of a Pareto chart:
>>
>> http://en.wikipedia.org/wiki/Pareto_chart
>>
>> Could I get this chart added to the matplolib gallery?
>>
>>
>> Thanks
>>
>> Paul
>>

> On 9/24/12 4:40 PM, Benjamin Root wrote:
> Your code looks overly complicated.  You shouldn't have to be doing the
> connection to the ylim_changed event, I don't think.  I think your main
> problem is that you are calling ax1.plot instead of ax2.plot.
>
> I am not against adding more examples to the gallery, but this would have to
> be cleaned up before it gets included.
>
> Ben Root

On Mon, Sep 24, 2012 at 5:50 PM, Paul Tremblay  wrote:
> I took my example from the matplotlib pages itself:
>
> http://matplotlib.org/examples/api/fahrenheit_celcius_scales.html
>
> If you know a better way, please show me.
>
> P.

Paul,

That example is an overly complicated template for making a pareto chart.

Here's how I'd do it:

# data
defects = [0, 32, 22, 15, 5, 2]
labels = ['', 'vertical', 'horizontal', 'behind', 'left area', 'other']

# axes
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()

# plotting
ax1.bar(np.arange(len(defects))-0.4, defects, zorder=0, alpha=0.5)
ax2.plot(np.cumsum(defects), linestyle='-', color='k', linewidth=2, zorder=5)

# formatting
ax1.set_xticks(np.arange(len(defects)))
ax1.set_xticklabels(labels)
ax1.set_ylabel('Defects')
ax2.set_ylabel('Percentage')
plt.show()

--
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] example of pareto chart

2012-09-24 Thread Paul Tremblay
By the way, I had done the chart differently to begin with. But this code
requires more lines, more imports, and is more complex. (Without
plt.gca().yaxis or the formatter, the graph will not come out.)

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MaxNLocator
defects = [32, 22, 15, 5, 2]
labels = ['vertical', 'horizontal', 'behind', 'left area', 'other']
the_sum = sum(defects)
the_cumsum = np.cumsum(defects)
ind = np.arange(len(defects))
width = .98
x = ind + .5 * width
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
rects = ax1.bar(ind, defects, width=width)
ax1.set_ylim(ymax=the_sum)
ax2.set_ylim(ymax=the_sum)
plt.gca().yaxis.set_major_locator( MaxNLocator(nbins = 6) )
line, = ax2.plot(x, the_cumsum)
ax1.set_xticks(ind+ .5 * width)
ax1.set_xticklabels(labels)
def to_percent(x, pos):
return round(x/the_sum, 1) * 100
formatter = FuncFormatter(to_percent)
ax2.yaxis.set_major_formatter(formatter)
ax1.set_ylabel('Defects')
ax2.set_ylabel('Percentage')
plt.show()


On Mon, Sep 24, 2012 at 8:50 PM, Paul Tremblay wrote:

>  I took my example from the matplotlib pages itself:
>
> http://matplotlib.org/examples/api/fahrenheit_celcius_scales.html
>
> If you know a better way, please show me.
>
> P.
>
>
> On 9/24/12 4:40 PM, Benjamin Root wrote:
>
>
>
> On Mon, Sep 24, 2012 at 12:21 AM, Paul Tremblay 
> wrote:
>
>> Here is my example of a Pareto chart.
>>
>> For an explanation of a Pareto chart:
>>
>> http://en.wikipedia.org/wiki/Pareto_chart
>>
>> Could I get this chart added to the matplolib gallery?
>>
>>
>> Thanks
>>
>> Paul
>>
>>
> Your code looks overly complicated.  You shouldn't have to be doing the
> connection to the ylim_changed event, I don't think.  I think your main
> problem is that you are calling ax1.plot instead of ax2.plot.
>
> I am not against adding more examples to the gallery, but this would have
> to be cleaned up before it gets included.
>
> 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] example of pareto chart

2012-09-24 Thread Paul Tremblay

I took my example from the matplotlib pages itself:

http://matplotlib.org/examples/api/fahrenheit_celcius_scales.html

If you know a better way, please show me.

P.

On 9/24/12 4:40 PM, Benjamin Root wrote:



On Mon, Sep 24, 2012 at 12:21 AM, Paul Tremblay 
mailto:paulhtremb...@gmail.com>> wrote:


Here is my example of a Pareto chart.

For an explanation of a Pareto chart:

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

Could I get this chart added to the matplolib gallery?


Thanks

Paul


Your code looks overly complicated.  You shouldn't have to be doing 
the connection to the ylim_changed event, I don't think.  I think your 
main problem is that you are calling ax1.plot instead of ax2.plot.


I am not against adding more examples to the gallery, but this would 
have to be cleaned up before it gets included.


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] Qt4/PySide memory leak

2012-09-24 Thread Christoph Gohlke
On 9/24/2012 3:32 PM, David Honcik wrote:
> I've run into a large memory leak using Matplotlib with PySide and the
> Qt4 back end.  I'm using :
> Python 3.2
> Numpy 1.6.2
> Pyside 1.1.1 (qt474)
> Matplotlib 1.2 (first the Capetown Group port to Python 3, then 1.2 RC2)
> on Windows XP 32 bit
> I've tried using the Python 2.7 branch of all of the above and don't see
> the problem.  I don't see the problem with the Tk back end.  I don't see
> the problem with the Qt4 back end and PyQt4.  Only with the above
> mentioned versions and using the Qt4 back end with PySide.
> The following script will reproduce the problem :
> 
> import matplotlib
> matplotlib.use('Qt4Agg')
> matplotlib.rcParams['backend.qt4']='PySide'
> import pylab
> arrayX = []
> arrayY = []
> for nIndex in range(0, 100):
> arrayX.append(nIndex)
> arrayY.append(nIndex)
> Figure = matplotlib.pyplot.figure(1)
> Axes = Figure.add_axes([ 0.05, 0.05, 0.95, 0.95])
> Axes.plot(arrayX,
> arrayY,
> color  = "blue",
> marker = "o",
>markersize = 5.0)
> Axes.set_xlim(arrayX[0], arrayX[len(arrayX) - 1])
> Axes.set_ylim(arrayY[0], arrayY[len(arrayY) - 1])
> matplotlib.pyplot.show()
> 
> I run the above, grab the lower right sizing handle on the plot window
> and start resizing the window.  Watching the python process in task
> manager, each resize leaks a noticeable amount of memory.  A few minutes
> of this will get process memory up to ~2.5 GB. At that point it crashes.
> I'm new here, am I in the right place?
>

I can reproduce this exactly, also with pyside 1.1.2 and an empty plot. 
Looks like QtGui.QImage is leaking.

import matplotlib
matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PySide'
from matplotlib import pyplot
pyplot.plot()
pyplot.show()

--
Christoph


--
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] A pie chart with rotated text labels

2012-09-24 Thread Martin Mokrejs
Hi Ben,

Benjamin Root wrote:
> 
> 
> On Monday, September 24, 2012, Martin Mokrejs wrote:
> 
> Hi,
>   I have pie charts with relatively long texts assigned to each slice of 
> the pie.
> The text is drawn horizontally. Instead, I would like to have it rotated 
> at the
> same angle as the slice itself (i.e. centered at the "axis" of the 
> slice). In this
> way the text would not overlap other text of adjacent slices (or at least 
> if the
> text starts far enough from the pie).
> 
> The example below is a bit over-twisted but I really want to be able to 
> read at
> least a portion of those ['my text4', 'my text5', 'my text6', 'my text7'] 
> legends.
> 
>  
> Hmmm, this might be a decent feature to add to pie().  Although, I wonder if 
> a legend would better suit your needs?

The problem is that some of my pie charts have dozens of slices or very varying 
width.
The legend would take just too much space and moreover, there is not that many 
colors
easily distinguishable by eye so a person would have a hard time to find which 
item in
the legend corresponds to some slice in the chart.

I think this is the only way out. ;-)

Martin
BTW: A percentage in black color on a blue slice is hardly readable. Could 
pie() also
change a font foreground color if the background is too dark in those few 
slices? Say
to white? ;-))

--
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] A pie chart with rotated text labels

2012-09-24 Thread Benjamin Root
On Monday, September 24, 2012, Martin Mokrejs wrote:

> Hi,
>   I have pie charts with relatively long texts assigned to each slice of
> the pie.
> The text is drawn horizontally. Instead, I would like to have it rotated
> at the
> same angle as the slice itself (i.e. centered at the "axis" of the slice).
> In this
> way the text would not overlap other text of adjacent slices (or at least
> if the
> text starts far enough from the pie).
>
> The example below is a bit over-twisted but I really want to be able to
> read at
> least a portion of those ['my text4', 'my text5', 'my text6', 'my text7']
> legends.
>
>
Hmmm, this might be a decent feature to add to pie().  Although, I wonder
if a legend would better suit your needs?

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


[Matplotlib-users] A pie chart with rotated text labels

2012-09-24 Thread Martin Mokrejs
Hi,
  I have pie charts with relatively long texts assigned to each slice of the 
pie.
The text is drawn horizontally. Instead, I would like to have it rotated at the
same angle as the slice itself (i.e. centered at the "axis" of the slice). In 
this
way the text would not overlap other text of adjacent slices (or at least if the
text starts far enough from the pie).

The example below is a bit over-twisted but I really want to be able to read at
least a portion of those ['my text4', 'my text5', 'my text6', 'my text7'] 
legends.

import pylab
F = pylab.gcf()
F.set_size_inches(17, 17)
ax_pie = pylab.axes([0.30, 0.30, 0.4, 0.4])
_data = [0.17, 0.23, 0.599, 0.001, 0.003, 0.003, 0.003]
_colors=['red', 'green', 'blue', 'black', 'white', 'yellow', 'violet']
_labels=['my text1', 'my text2', 'my text3', 'my text4', 'my text5', 'my 
text6', 'my text7']
ax_pie.pie(_data, colors=_colors, labels=_labels, labeldistance=1.5, 
autopct='%1.1f%%')
pylab.axis('equal')
pylab.title("blah")
pylab.show()


  I tried to search for some example of this or documentation of the pie 
function
but it seems it is either not possible or not documented. ;-)


Some relatively close matches I found:

http://matplotlib.sourceforge.net/examples/pylab_examples/text_rotation.html 
(this
could maybe help but I do not know at what angle is each slice rendered by 
pylab.pie())

http://matplotlib.sourceforge.net/examples/pylab_examples/text_rotation_relative_to_line.html
(maybe this would work if all text should be drawn at a SAME angle but that is 
not what I want)

Some other shots:
http://stackoverflow.com/questions/9220933/plotting-a-pie-chart-in-matplotlib-at-a-specific-angle-with-the-fracs-on-the-wed

http://guutaranoheya.web.fc2.com/math/matplotlib_ex.html (search for "rotation")

Thank you for your help,
Martin

--
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] Qt4/PySide memory leak

2012-09-24 Thread David Honcik
I've run into a large memory leak using Matplotlib with PySide and the
Qt4 back end.  I'm using :
 
Python 3.2
Numpy 1.6.2
Pyside 1.1.1 (qt474)
Matplotlib 1.2 (first the Capetown Group port to Python 3, then 1.2 RC2)
 
on Windows XP 32 bit
 
 
I've tried using the Python 2.7 branch of all of the above and don't see
the problem.  I don't see the problem with the Tk back end.  I don't see
the problem with the Qt4 back end and PyQt4.  Only with the above
mentioned versions and using the Qt4 back end with PySide.
 
The following script will reproduce the problem :
 

import matplotlib
 
matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PySide'

import pylab
 
arrayX = []
arrayY = []
for nIndex in range(0, 100):
arrayX.append(nIndex)
arrayY.append(nIndex)
 
Figure = matplotlib.pyplot.figure(1)
Axes = Figure.add_axes([ 0.05, 0.05, 0.95, 0.95])
 
Axes.plot(arrayX,
  arrayY,
  color  = "blue",
  marker = "o",
  markersize = 5.0)
 
Axes.set_xlim(arrayX[0], arrayX[len(arrayX) - 1])
Axes.set_ylim(arrayY[0], arrayY[len(arrayY) - 1])
 
matplotlib.pyplot.show()


 
I run the above, grab the lower right sizing handle on the plot window
and start resizing the window.  Watching the python process in task
manager, each resize leaks a noticeable amount of memory.  A few minutes
of this will get process memory up to ~2.5 GB.  At that point it
crashes.
 
I'm new here, am I in the right place?
--
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] example of pareto chart

2012-09-24 Thread Benjamin Root
On Mon, Sep 24, 2012 at 12:21 AM, Paul Tremblay wrote:

> Here is my example of a Pareto chart.
>
> For an explanation of a Pareto chart:
>
> http://en.wikipedia.org/wiki/Pareto_chart
>
> Could I get this chart added to the matplolib gallery?
>
>
> Thanks
>
> Paul
>
>
Your code looks overly complicated.  You shouldn't have to be doing the
connection to the ylim_changed event, I don't think.  I think your main
problem is that you are calling ax1.plot instead of ax2.plot.

I am not against adding more examples to the gallery, but this would have
to be cleaned up before it gets included.

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


[Matplotlib-users] set_clip_mask() single polygon for multiple subplots

2012-09-24 Thread Scott Henderson
I'd like to use the same patch to clip two images that share the same 
axes, and extract values from the un-clipped region of both arrays. 
Unfortunately this seems harder than expected. Code & questions below, 
Thanks!

from matplotlib.patches import Polygon
import matplotlib.pyplot as plt
from numpy import random

poly = patches.Circle((5,5), radius=3, fill=False, ec='none')

fig = plt.figure()
ax = fig.add_subplot(121)
ax.autoscale_view(0,0,0)
test = random.rand(10,10)
im = ax.imshow(test)

test1 = random.rand(10,10)
# How to prevent automatic axis scaling?
ax1 = fig.add_subplot(122, sharex=ax, sharey=ax)
im1 = ax1.imshow(test1)

ax.add_patch(poly)
im.set_clip_path(poly)

# Doesn't work b/c poly vertices auto-transformed to display coords by 
add_patch?
ax1.add_patch(poly)
im1.set_clip_path(poly)

# How to extract non-clipped values instead of full array?
clipped_data = im.get_array()

plt.show()


--
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] matplotlib 1.2.0rc2 is available

2012-09-24 Thread Michael Droettboom

matplotlib 1.2.0rc2 is available!

This is the culmination of many months of hard work.  1.2.0 is the first 
release to support Python 3.x, and drops support for Python 2.5 and 
earlier.  A more detailed list of changes is available here:


http://matplotlib.org/1.2.0/users/whats_new.html

For the first time, downloads are being made available through github, 
and not through sourceforge, so the release and binaries can be 
downloaded here:


https://github.com/matplotlib/matplotlib/downloads 



(Due to a compiler difference, we do not have binaries for 32-bit OS-X, 
but we hope to have them available soon.)


Documentation for the new release is available here:

http://matplotlib.org/1.2.0/ 



(The main matplotlib.org site will continue to host the documentation 
for 1.1.1 until the final 1.2.0 release).


Go forth, download, kick the tires, and let us know what breaks! (Either 
here or on the github issue tracker).


Cheers,
Mike
--
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] Image as marker and axes "equal" aspect ratio

2012-09-24 Thread Andrea Gavana
On 22 September 2012 16:57, Jae-Joon Lee wrote:
> I recommend you to use OffsetImage. Here is an example of how one can
> use OffsetImage.
>
> http://matplotlib.org/examples/pylab_examples/demo_annotation_box.html
>
> And attached is the modified version of the original script.

Thank you JJ, I wasn't aware of OffsetImage. It works perfectly now,
thanks again.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

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