[Matplotlib-users] AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

2013-10-11 Thread Nils Wagner
Hi all,

I tried to add a colorbar to a bar plot

coolwarm = cm =  plt.get_cmap('coolwarm')
values = range(100)
cNorm  = colors.Normalize(vmin=0, vmax=values[-1])
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=coolwarm)
colours = []
for value in values:
colorVal = scalarMap.to_rgba(value)
colours.append(colorVal)

fig = plt.figure()
ax  = fig.add_subplot(111,projection='3d')
hist,bin_edges = np.histogram(efratio,bins=100,range=(0.,1.),density=False)
width = 0.7*(bin_edges[1]-bin_edges[0])
center = (bin_edges[:-1]+bin_edges[1:])/2
heatmap = ax.bar(center, hist, zs=z, zdir='y', align = 'center', width =
width,color=colours)
plt.colorbar(heatmap)





mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

How can I fix the problem ?

Nils
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

2013-10-11 Thread Eric Firing
On 2013/10/10 8:52 PM, Nils Wagner wrote:
 Hi all,

 I tried to add a colorbar to a bar plot

 coolwarm = cm =  plt.get_cmap('coolwarm')
 values = range(100)
 cNorm  = colors.Normalize(vmin=0, vmax=values[-1])
 scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=coolwarm)
 colours = []
 for value in values:
  colorVal = scalarMap.to_rgba(value)
  colours.append(colorVal)

 fig = plt.figure()
 ax  = fig.add_subplot(111,projection='3d')
 hist,bin_edges = np.histogram(efratio,bins=100,range=(0.,1.),density=False)
 width = 0.7*(bin_edges[1]-bin_edges[0])
 center = (bin_edges[:-1]+bin_edges[1:])/2
 heatmap = ax.bar(center, hist, zs=z, zdir='y', align = 'center', width =
 width,color=colours)
 plt.colorbar(heatmap)





  mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
 AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

This is because it is not an instance of ScalarMappable, which is what 
colorbar() requires as its argument.

 How can I fix the problem ?

Use scalarMap as the argument instead of heatmap.  I think you will need 
to provide either the cax or the ax kwarg in addition.

examples/api/colorbar_only.py might also be helpful.

Eric

 Nils



 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk



 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

2013-10-11 Thread Nils Wagner
plt.colorbar(scalarMap,ax=ax) results in

cm.py, line 309, in autoscale_None
raise TypeError('You must first set_array for mappable')
TypeError: You must first set_array for mappable

Nils



On Fri, Oct 11, 2013 at 9:51 AM, Eric Firing efir...@hawaii.edu wrote:

 On 2013/10/10 8:52 PM, Nils Wagner wrote:
  Hi all,
 
  I tried to add a colorbar to a bar plot
 
  coolwarm = cm =  plt.get_cmap('coolwarm')
  values = range(100)
  cNorm  = colors.Normalize(vmin=0, vmax=values[-1])
  scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=coolwarm)
  colours = []
  for value in values:
   colorVal = scalarMap.to_rgba(value)
   colours.append(colorVal)
 
  fig = plt.figure()
  ax  = fig.add_subplot(111,projection='3d')
  hist,bin_edges =
 np.histogram(efratio,bins=100,range=(0.,1.),density=False)
  width = 0.7*(bin_edges[1]-bin_edges[0])
  center = (bin_edges[:-1]+bin_edges[1:])/2
  heatmap = ax.bar(center, hist, zs=z, zdir='y', align = 'center', width =
  width,color=colours)
  plt.colorbar(heatmap)
 
 
 
 
 
   mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
  AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

 This is because it is not an instance of ScalarMappable, which is what
 colorbar() requires as its argument.
 
  How can I fix the problem ?

 Use scalarMap as the argument instead of heatmap.  I think you will need
 to provide either the cax or the ax kwarg in addition.

 examples/api/colorbar_only.py might also be helpful.

 Eric
 
  Nils
 
 
 
 
 --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
 from
  the latest Intel processors and coprocessors. See abstracts and register
 
 
 http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
 
 
 
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 



 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
 from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] AttributeError: 'BarContainer' object has no attribute 'autoscale_None'

2013-10-11 Thread Sterling Smith
Nils,

I tried to run your example, but there are some variables which are undefined.  
Can you post a self contained revision of your example?

-Sterling

On Oct 11, 2013, at 1:34AM, Nils Wagner wrote:

 plt.colorbar(scalarMap,ax=ax) results in
 
 cm.py, line 309, in autoscale_None
 raise TypeError('You must first set_array for mappable')
 TypeError: You must first set_array for mappable
 
 Nils
 
 
 
 On Fri, Oct 11, 2013 at 9:51 AM, Eric Firing efir...@hawaii.edu wrote:
 On 2013/10/10 8:52 PM, Nils Wagner wrote:
  Hi all,
 
  I tried to add a colorbar to a bar plot
 
  coolwarm = cm =  plt.get_cmap('coolwarm')
  values = range(100)
  cNorm  = colors.Normalize(vmin=0, vmax=values[-1])
  scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=coolwarm)
  colours = []
  for value in values:
   colorVal = scalarMap.to_rgba(value)
   colours.append(colorVal)
 
  fig = plt.figure()
  ax  = fig.add_subplot(111,projection='3d')
  hist,bin_edges = np.histogram(efratio,bins=100,range=(0.,1.),density=False)
  width = 0.7*(bin_edges[1]-bin_edges[0])
  center = (bin_edges[:-1]+bin_edges[1:])/2
  heatmap = ax.bar(center, hist, zs=z, zdir='y', align = 'center', width =
  width,color=colours)
  plt.colorbar(heatmap)
 
 
 
 
 
   mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
  AttributeError: 'BarContainer' object has no attribute 'autoscale_None'
 
 This is because it is not an instance of ScalarMappable, which is what
 colorbar() requires as its argument.
 
  How can I fix the problem ?
 
 Use scalarMap as the argument instead of heatmap.  I think you will need
 to provide either the cax or the ax kwarg in addition.
 
 examples/api/colorbar_only.py might also be helpful.
 
 Eric
 
  Nils
 
 
 
  --
  October Webinars: Code for Performance
  Free Intel webinars can help you accelerate application performance.
  Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most 
  from
  the latest Intel processors and coprocessors. See abstracts and register 
  http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
 
 
 
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problems using Matplotlib from a GTK app

2013-10-11 Thread Skip Montanaro
I want to use matplotlib as a component of a larger, event-driven GTK
app. That means pylab.show is (I think) not the way to go, as it
starts up its own event loop which doesn't return. I've tried to clear
and plot in my event handler, but my plot is never displayed.

My initialization code looks like this:

matplotlib.use(GtkAgg)

self.figure = matplotlib.figure.Figure()
self.plot = self.figure.add_subplot(111)
self.plot.set_axisbelow(True)
self.figure.tight_layout()

My event handler computes a new set of points (about a dozen x/y
pairs) and plots them:

points = ... generate a list of (x, y) tuples ...
print points
self.plot.clear()
self.plot.plot([x for x, y in points], [y for x, y in points])

Every time my event handler is called, it prints the points (I see
them in my xterm), but the plot is never drawn.

I looked at this example:

http://matplotlib.org/examples/user_interfaces/embedding_in_gtk2.html

but it does something with a key press handler that seems very
artificial, and not at all like how my application will interact with
its environment.  Can someone point me to the correct spot in the
documentation or some examples that don't require the user to type at
the application?

Thanks,

Skip

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problems using Matplotlib from a GTK app

2013-10-11 Thread Sterling Smith
Skip,

Here are some lines from an application I have written.

from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg

In the setup:
self.canvas = FigureCanvasGTKAgg(self.figure)
self.canvas.set_size_request(600,600)
self.canvas.show()
#Pack the canvas in a parent container
self.vbox0.pack_start(self.canvas, True, True)

At the event where I want the plot to update:
self.canvas.draw()

For a faster responding application, be sure to check out the matplotlib 
animation examples with blitting, as I built my application without that 
knowledge, and haven't found the time to go back and fix it...

-Sterling

On Oct 11, 2013, at 9:25AM, Skip Montanaro wrote:

 I want to use matplotlib as a component of a larger, event-driven GTK
 app. That means pylab.show is (I think) not the way to go, as it
 starts up its own event loop which doesn't return. I've tried to clear
 and plot in my event handler, but my plot is never displayed.
 
 My initialization code looks like this:
 
matplotlib.use(GtkAgg)

self.figure = matplotlib.figure.Figure()
self.plot = self.figure.add_subplot(111)
self.plot.set_axisbelow(True)
self.figure.tight_layout()
 
 My event handler computes a new set of points (about a dozen x/y
 pairs) and plots them:
 
points = ... generate a list of (x, y) tuples ...
print points
self.plot.clear()
self.plot.plot([x for x, y in points], [y for x, y in points])
 
 Every time my event handler is called, it prints the points (I see
 them in my xterm), but the plot is never drawn.
 
 I looked at this example:
 
 http://matplotlib.org/examples/user_interfaces/embedding_in_gtk2.html
 
 but it does something with a key press handler that seems very
 artificial, and not at all like how my application will interact with
 its environment.  Can someone point me to the correct spot in the
 documentation or some examples that don't require the user to type at
 the application?
 
 Thanks,
 
 Skip
 
 --
 October Webinars: Code for Performance
 Free Intel webinars can help you accelerate application performance.
 Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
 the latest Intel processors and coprocessors. See abstracts and register 
 http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Any progress on binary installer for OSX?

2013-10-11 Thread Matthew Brett
Hi,

On Thu, Oct 3, 2013 at 1:33 PM, Matthew Brett matthew.br...@gmail.com wrote:
 Hi,

 On Thu, Oct 3, 2013 at 1:29 PM, Russell E. Owen ro...@uw.edu wrote:
 In article
 CAH6Pt5q=z_macay-dgroz38jimo6uclv+amxkxhvt+qoe+c...@mail.gmail.com,
  Matthew Brett matthew.br...@gmail.com
  wrote:

 Hi,

 On Thu, Oct 3, 2013 at 5:59 AM, Michael Droettboom
 md...@stsci.edu wrote:
  Matthew Terry, as part of his Mac testing project, has done a great deal 
  of
  reconnaissance on this.
 
  https://github.com/matplotlib/mpl_mac_testing
 
  I know he was looking into statically linking some of the C dependencies
  (freetype, libpng etc.) as a way to make the installer more robust to
  different environments.

 Thanks - that looks like a useful testing grid.

 Are there any near-term plans for something like a .dmg or .mpkg or
 .pkg installer?

 Building a binary installer with statically linked libraries is not
 terribly hard (see
 http://www.astro.washington.edu/users/rowen/BuildingMatplotlibForMac.htm
 l). There are two problem:
 - As of 1.3.0 mpl does not include python-dateutil, pytz or six (for
 good reasons) and that makes it harder to make a really usable binary
 installer. This interacts with the next problem:
 - For unknown reasons running the 1.3.0 installer breaks existing
 installations of python-dateutil if those packages were installed using
 an older mpl binary installer.

 The missing packages can be added to the binary installer after it is
 produced by bdist_mpkg by post-processing the mpkg. That would take care
 of the second issue for most users (who would use the default
 installation and get everything). I have not had time to deal with that.
 Thus I never uploaded an official binary installer for 1.3.0 and stopped
 providing them. Matthew Terry has taken over that task.

 Aha - yes - postprocessing the mpkg would be pretty easy.

 So - I guess I should just build the installer myself and post it for
 testing?  Is that the best way forward?

OK - after a lot of blood, sweat and tears:

http://nipy.bic.berkeley.edu/practical_neuroimaging/matplotlib-1.3.1-py2.7-macosx10.6.mpkg.zip

- a standalone binary installer for matplotlib 1.3.1, including:

tornado
pyparsing
python-dateutil
pytz
six

Please do test.

It imports on my machines (10.6, 10.7 * 2, 10.8), I am just running the tests.

I'm building from a waf build that should be replicable:

https://github.com/matthew-brett/mpl-osx-binaries

On a 10.6 and a 10.8 machine I get a couple of test errors, log attached:

ERROR: matplotlib.tests.test_backend_pgf.test_pathclip
ERROR: matplotlib.tests.test_backend_pgf.test_mixedmode

One (clean) 10.7 passes, another 10.7 machine gives the same errors as
above plus 2 ghostscript errors.

Cheers,

Matthew

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Any progress on binary installer for OSX?

2013-10-11 Thread Matthew Brett
Hi,

On Fri, Oct 11, 2013 at 9:29 PM, Matthew Brett matthew.br...@gmail.com wrote:
 Hi,

 On Thu, Oct 3, 2013 at 1:33 PM, Matthew Brett matthew.br...@gmail.com wrote:
 Hi,

 On Thu, Oct 3, 2013 at 1:29 PM, Russell E. Owen ro...@uw.edu wrote:
 In article
 CAH6Pt5q=z_macay-dgroz38jimo6uclv+amxkxhvt+qoe+c...@mail.gmail.com,
  Matthew Brett matthew.br...@gmail.com
  wrote:

 Hi,

 On Thu, Oct 3, 2013 at 5:59 AM, Michael Droettboom
 md...@stsci.edu wrote:
  Matthew Terry, as part of his Mac testing project, has done a great deal 
  of
  reconnaissance on this.
 
  https://github.com/matplotlib/mpl_mac_testing
 
  I know he was looking into statically linking some of the C dependencies
  (freetype, libpng etc.) as a way to make the installer more robust to
  different environments.

 Thanks - that looks like a useful testing grid.

 Are there any near-term plans for something like a .dmg or .mpkg or
 .pkg installer?

 Building a binary installer with statically linked libraries is not
 terribly hard (see
 http://www.astro.washington.edu/users/rowen/BuildingMatplotlibForMac.htm
 l). There are two problem:
 - As of 1.3.0 mpl does not include python-dateutil, pytz or six (for
 good reasons) and that makes it harder to make a really usable binary
 installer. This interacts with the next problem:
 - For unknown reasons running the 1.3.0 installer breaks existing
 installations of python-dateutil if those packages were installed using
 an older mpl binary installer.

 The missing packages can be added to the binary installer after it is
 produced by bdist_mpkg by post-processing the mpkg. That would take care
 of the second issue for most users (who would use the default
 installation and get everything). I have not had time to deal with that.
 Thus I never uploaded an official binary installer for 1.3.0 and stopped
 providing them. Matthew Terry has taken over that task.

 Aha - yes - postprocessing the mpkg would be pretty easy.

 So - I guess I should just build the installer myself and post it for
 testing?  Is that the best way forward?

 OK - after a lot of blood, sweat and tears:

 http://nipy.bic.berkeley.edu/practical_neuroimaging/matplotlib-1.3.1-py2.7-macosx10.6.mpkg.zip

 - a standalone binary installer for matplotlib 1.3.1, including:

 tornado
 pyparsing
 python-dateutil
 pytz
 six

 Please do test.

 It imports on my machines (10.6, 10.7 * 2, 10.8), I am just running the tests.

 I'm building from a waf build that should be replicable:

 https://github.com/matthew-brett/mpl-osx-binaries

 On a 10.6 and a 10.8 machine I get a couple of test errors, log attached:

 ERROR: matplotlib.tests.test_backend_pgf.test_pathclip
 ERROR: matplotlib.tests.test_backend_pgf.test_mixedmode

 One (clean) 10.7 passes, another 10.7 machine gives the same errors as
 above plus 2 ghostscript errors.

python3.3 installer, same errors as 2.7 for OSX 10.8:

http://nipy.bic.berkeley.edu/practical_neuroimaging/matplotlib-1.3.1-py3.3-macosx10.6.mpkg.zip

I've attached the log this time (for 2.7, it's similar for 3.3)

Best,

Matthew


mpl.log.bz2
Description: BZip2 compressed data
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60134071iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users