[matplotlib-devel] Contributed example

2011-07-08 Thread Nicolas Rougier


Hi,


I've been playing with matplotlib to check if it can produce graphics like:

http://www.thebuzzmedia.com/wp-content/uploads/2010/03/anandtech-nvidia-geforce-480-ati-benchmark2.png


Here is the result:
http://www.loria.fr/~rougier/tmp/benchmark.png

and the script (as attachment)

I do not know if it's worth adding it to examples ?



Nicolas


#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -
# Copyright (C) 2011  Nicolas P. Rougier
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
# * Neither the name of the glumpy Development Team nor the names of its
#   contributors may be used to endorse or promote products derived from this
#   software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# -
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches

# --
# Data to be represented

products = ['Vendor A - Product A', 'Vendor A - Product B', 'Vendor A - Product C',
'Vendor B - Product A', 'Vendor B - Product B', 'Vendor B - Product C',
'Vendor C - Product A', 'Vendor C - Product B', 'Vendor C - Product C']

values = np.random.uniform(10,60,len(products))

# --

# Choose some nice colors
matplotlib.rc('axes', facecolor = '#6E838A')
matplotlib.rc('axes', edgecolor = '#737373')
matplotlib.rc('axes', linewidth = 1)
matplotlib.rc('ytick', direction='out')
matplotlib.rc('xtick', direction='out')
matplotlib.rc('figure.subplot', left=0.25)

# Make figure background the same colors as axes
fig = plt.figure(figsize=(12,8), facecolor='#6E838A')

# Remove left and top axes spines
axes = plt.subplot(1,1,1)
axes.spines['right'].set_color('none')
axes.spines['top'].set_color('none')
axes.xaxis.set_ticks_position('bottom')
axes.yaxis.set_ticks_position('left')

# Adjust yticks to the number of products
plt.yticks(np.arange(len(products)+1), [])

# Set tick labels color to white
for label in axes.get_xticklabels()+axes.get_yticklabels():
label.set_color('white')

# Set tick labels line width to 1
for line in axes.get_xticklines() + axes.get_yticklines():
line.set_linewidth(1)

# Set axes limits
ymin, ymax = 0, len(products)
xmin, xmax = 0, 60
plt.xlim(xmin,xmax)
plt.ylim(ymin,ymax)

# Start with blue colormap
cmap = plt.cm.Blues

for i, label in enumerate(products):

# Alternate band of light background
if not i%2:
#X = [[(1,1,1,.5)]]
#axes.imshow(X, extent=(0,xmax, i,i+1))
p = patches.Rectangle(
(0, i), xmax, 1, fill=True, transform=axes.transData,
lw=0, facecolor='w', alpha=.1)
axes.add_patch(p)


# Product name left to the axes
plt.text(-.5, i+0.5, label, color="white", 
 horizontalalignment='right', verticalalignment='center')

# Plot the bar with gradient (1 to .65)
value = values[i]
X = np.array([1,.65]).reshape((1,2))
axes.imshow(X,extent=(0,value,i+.25,i+.75),cmap=cmap, vmin=0, vmax=1)
plt.text(value-0.5, i+0.5, '%.1f' % value, color="white", 
 horizontalalignment='right', verticalalignment='center')

# Change colormap every 3 values
if i >= 2: cmap = plt.cm.Greens
if i >= 5: cmap = plt.cm.Reds

# Set a nice figure aspect
axes.set_aspect(4.5)

# Write some title & subtitle
plt.text(1, 10.0, "Vendor benchmarks", color="1.0", fontsize=16)
plt.text(1,  9.7, "(higher is better)", color="0.75", fontsize=12)

# Done
plt.savefig('benchmark.png', facecolor='#6E838A')
plt.show()
--
All of the data generated in your IT infrastructure is serious

Re: [matplotlib-devel] Fix for issue #135

2011-07-08 Thread Benjamin Root
On Friday, July 8, 2011, Maximilian Trescher  wrote:
> Hi,
>
>> I would avoid drange because
>> I believe numpy will soon be implementing such a function and I
>> wouldn't want the possible confusion that comes from that.
>
> what do you mean with "avoiding drange"? You wouldn't use it in your
> code? Or do you suggest, matplotlib should not have the function "drange"?
>

I mean that matplotlib probably shouldn't have drange (although, this
is just IMHO).

> I have yet another question: Does someone know, why matplotlib.dates
> calculates dates in floats, where 1 = 1day?
> I think with Long integers without floating point much of the
> rounding-issues could be avoided.

We are most certainly "doing it wrong" as the current code was merely
a hack due to the lack of such features in numpy.  The next numpy
release should have this, but we will still need the current hacks for
a little while longer due to support for previous versions of numpy.

Maybe we ought to look into some sort of logic that would utilize
numpy's drange if it is available and fall back to ours otherwise?

Ben Root

--
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-d2d-c2
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Contributed example

2011-07-08 Thread Gökhan Sever
I think this illustration deserves its places amongst the mpl gallery
--probably somewhere towards the very beginning.

Thanks for the well documented code Nicolas.
On Fri, Jul 8, 2011 at 2:09 AM, Nicolas Rougier wrote:

>
>
> Hi,
>
>
> I've been playing with matplotlib to check if it can produce graphics like:
>
>
> http://www.thebuzzmedia.com/wp-content/uploads/2010/03/anandtech-nvidia-geforce-480-ati-benchmark2.png
>
>
> Here is the result:
> http://www.loria.fr/~rougier/tmp/benchmark.png
>
> and the script (as attachment)
>
> I do not know if it's worth adding it to examples ?
>
>
>
> Nicolas
>
>
>
>
> --
> 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-d2d-c2
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>


-- 
Gökhan
--
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-d2d-c2___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [Matplotlib-users] broken demo

2011-07-08 Thread Benjamin Root
On Sun, Jun 26, 2011 at 9:05 PM, Benjamin Root  wrote:

> On Sunday, June 26, 2011, Warren Weckesser
>  wrote:
> >
> >
> > On Sun, Jun 26, 2011 at 7:44 PM, Benjamin Root  wrote:
> >
> >
> > On Sunday, June 26, 2011, Carl Karsten  wrote:
> >> http://matplotlib.sourceforge.net/examples/api/radar_chart.html
> >>
> >> "Exception occurred rendering plot."
> >>
> >
> > Without more information, we can't help you.  What version of
> > matplotlib are you using? On what OS?  How did you install it?  Do the
> > tests pass?  And which backend?
> >
> >
> > That error is what shows up on the web page when you follow the link.
> >
> > Warren
> >
> >
>
> Ah, indeed it is.  I apologize for misunderstanding, what is odd is
> that the demo didn't work, but the mpl logo rendered fine.
>
> Who was it that uploaded the recent rebuild of the docs?
>
> Ben Root
>

I just had an epiphany and figured out what is causing this.  It looks like
that any example that uses the "if __name__ == '__main__' :" idiom is
failing to produce an image.  Some others that have the same issue are:

http://matplotlib.sourceforge.net/examples/api/sankey_demo.html
http://matplotlib.sourceforge.net/examples/api/hinton_demo.html
http://matplotlib.sourceforge.net/examples/api/logo2.html (it has a link,
but no image on the page)
http://matplotlib.sourceforge.net/examples/misc/multiprocess.html
http://matplotlib.sourceforge.net/examples/pylab_examples/arrow_demo.html

and many others (can be found by grepping for "__main__" in the examples
folder).

On a local build of the docs from master, axes_grid has two demos that also
fail to produce images for the docs.  They look to be new demos.

I wonder if this is being caused (or at least the errors hidden by) the new
multiprocessing approach for the doc-build.  Anybody have any thoughts on
how to deal with this?  I consider this a release-stopper.

Ben Root
--
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-d2d-c2___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Contributed example

2011-07-08 Thread Chris Petrich
I agree, very instructional example.
As for the width of the tick lines, line 78
line.set_linewidth(1)
should probably read
line.set_markeredgewidth(1)
though.

Chris

> Date: Fri, 8 Jul 2011 16:18:52 -0600
> From: G?khan Sever 
> Subject: Re: [matplotlib-devel] Contributed example
> To: Nicolas Rougier 
> Cc: matplotlib development list
>        
> Message-ID:
>        
> Content-Type: text/plain; charset="utf-8"
>
> I think this illustration deserves its places amongst the mpl gallery
> --probably somewhere towards the very beginning.
>
> Thanks for the well documented code Nicolas.
> On Fri, Jul 8, 2011 at 2:09 AM, Nicolas Rougier 
> wrote:
>
>>
>>
>> Hi,
>>
>>
>> I've been playing with matplotlib to check if it can produce graphics like:
>>
>>
>> http://www.thebuzzmedia.com/wp-content/uploads/2010/03/anandtech-nvidia-geforce-480-ati-benchmark2.png
>>
>>
>> Here is the result:
>> http://www.loria.fr/~rougier/tmp/benchmark.png
>>
>> and the script (as attachment)
>>
>> I do not know if it's worth adding it to examples ?
>>
>>
>>
>> Nicolas
>>
>>
>>
>>
>> --
>> 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-d2d-c2
>> ___
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>>
>
>
> --
> G?khan
> -- next part --
> An HTML attachment was scrubbed...
>
> --
>
> --
> 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-d2d-c2
>
> --
>
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>
> End of Matplotlib-devel Digest, Vol 62, Issue 3
> ***

--
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-d2d-c2
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel