[Matplotlib-users] TypeError: unsupported operand type(s) for +: 'NoneType' and 'float' on 1.2.1

2013-04-16 Thread Christophe Pettus
After upgrading to 1.2.1 from 1.1, I'm getting an exception on the below-noted 
line; any thoughts what might have changed?

  File /Users/xof/Documents/Dev/tuneup/reports/tables.py, line 60, in 
table_sizes
dbar = ax.barh(ind, data_size, width, linewidth=0, color='blue', 
label='Main Data')
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/axes.py,
 line 5021, in barh
orientation='horizontal', **kwargs)
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/axes.py,
 line 4901, in bar
self.add_patch(r)
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/axes.py,
 line 1570, in add_patch
self._update_patch_limits(p)
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/axes.py,
 line 1588, in _update_patch_limits
xys = patch.get_patch_transform().transform(vertices)
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/patches.py,
 line 581, in get_patch_transform
self._update_patch_transform()
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/patches.py,
 line 577, in _update_patch_transform
bbox = transforms.Bbox.from_bounds(x, y, width, height)
  File 
/Users/xof/Documents/Dev/environments/tuneup/lib/python2.6/site-packages/matplotlib/transforms.py,
 line 786, in from_bounds
return Bbox.from_extents(x0, y0, x0 + width, y0 + height)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

The code is:

# preamble code collecting data

ind = np.arange(len(table_name))

width = 0.35

fig = plot.figure(figsize=DEFAULT_FIGURE_SIZE)
ax = fig.add_subplot(111, axisbg='#fafafa', alpha=0.9)

ax.set_title('Largest Tables')

ax.set_xlabel('Size (log scale)')

ax.set_xscale('log')
ax.grid(True)

ax.xaxis.set_major_formatter(FuncFormatter(magnitude_ticks))

dbar = ax.barh(ind, data_size, width, linewidth=0, color='blue', 
label='Main Data')  # exception here
ibar = ax.barh(ind, index_toast_size, width, left=data_size, linewidth=0, 
color='red', label='Toast/Indexes')
ax.set_yticks(ind + width/2)
ax.set_yticklabels(table_name, fontproperties=xx_small_font)

ax.legend(loc='lower right', prop=x_small_font)

plot.tight_layout()

plot.savefig(REPORT_DIR_PATH + '/table_sizes.pdf')

plot.close()

--
-- Christophe Pettus
   x...@thebuild.com


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


[Matplotlib-users] Horizontal bar chart with log x-axis, no filled boxes

2012-01-12 Thread Christophe Pettus
I'm running into something odd in Matplotlib 1.1.  In drawing a horizontal bar 
chart (barh), if the x-axis scale is set to log, the rectangles are not drawn 
and filled; I just get small ticks at the right-hand position where the 
rectangle should end.  Interestingly, if I add a second, stacked barh to the 
same axes, that second set of rectangles draws fine, even though the first does 
not.

If I simply comment out the call setting the x axis to log, it works properly.

Any thoughts?
--
-- Christophe Pettus
   x...@thebuild.com


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


Re: [Matplotlib-users] Horizontal bar chart with log x-axis, no filled boxes

2012-01-12 Thread Christophe Pettus

On Jan 12, 2012, at 7:38 AM, Benjamin Root wrote:
 Does everything work correctly if it is vertical?  In other words, use bar() 
 and set the y-axis to log scale? An example script would be useful.

No, it doesn't appear to work as a vertical bar chart, either.

I've attached a test case below.  The results I get running it with the X-axis 
as log are:

http://thebuild.com/matlabtest/matlabtest-log.pdf

Commenting out the call to ax.set_xscale('log') gives me:

http://thebuild.com/matlabtest/matlabtest.pdf

Thanks!

--

import numpy as np
import matplotlib
from matplotlib.font_manager import FontProperties

import random

matplotlib.use('PDF')

import matplotlib.pyplot as plot

small_font = FontProperties()
small_font.set_size('xx-small')

ind = np.arange(20)

label = [ str(r) for r in ind ]
data1 = [ float(random.random()*1) for r in ind ]
data2 = [ float(random.random()*1) for r in ind ]

width = 0.25

fig = plot.figure()
ax = fig.add_subplot(111)

ax.set_title('Table Title')
ax.set_xlabel('X Label')

ax.barh(ind, data1, width, linewidth=0, color='blue')
ax.barh(ind, data2, width, left=data1, linewidth=0, color='yellow')
ax.set_yticks(ind + width/2)
ax.set_yticklabels(label, fontproperties=small_font)
ax.set_xscale('log')

plot.savefig('matlabtest-log.pdf')

--
-- Christophe Pettus
   x...@thebuild.com


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


Re: [Matplotlib-users] Horizontal bar chart with log x-axis, no filled boxes

2012-01-12 Thread Christophe Pettus

On Jan 12, 2012, at 9:31 AM, Benjamin Root wrote:

 D'oh!  Of course, I missed that tiny little detail.  Hmm, so the 
 auto-detection would have been useless in this case because the scale of the 
 axes was set after the fact.
 
 Maybe the log kwarg should be in a more prominent location in the docstring?

Moving the call to set_xscale('log') to before the calls to barh fixes the 
problem nicely... thank you!

--
-- Christophe Pettus
   x...@thebuild.com


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


[Matplotlib-users] Figure area size questions

2012-01-12 Thread Christophe Pettus
My apologies for two totally noob questions, but I can't quite seem to find 
these in the docs; a pointer would be great...

1. I would like to position a legend outside of the main plot area.  The 
positioning part works great, but the legend is clipped to the pre-existing 
figure dimensions; how can I expand the figure size horizontally to allow for 
the legend?   (And is there any way of auto-sizing the figure to include all of 
the stuff within it?)

2. In the horizontal bar chart I previously mentioned, the labels on the ticks 
on the Y-axis are clipped on the left side, as they are too long to fit into 
the pre-existing space.  What's the best way of allowing more space for the 
tick labels, either by contracting the chart itself or expanding the figure?

Thanks in advance,
--
-- Christophe Pettus
   x...@thebuild.com


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


Re: [Matplotlib-users] Figure area size questions

2012-01-12 Thread Christophe Pettus

On Jan 12, 2012, at 10:18 AM, Benjamin Root wrote:

 fig.savefig('foobar.png, bbox_inches='tight', pad_inches=0.25, 
 bbox_extra_artists=[leg])

[...]

 In mpl v1.1.0, we introduced a function called tight_layout which should 
 help with such things.  Admittedly, it would be nice if tight_layout did 
 something similar to bbox_inches='tight' and accept a list of additional 
 artist objects to consider, but it does not do that right now.

Both of those worked wonderfully... thanks very much!

--
-- Christophe Pettus
   x...@thebuild.com


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