ramp shaped bars?

I am a newbie Python programmer trying to make 3d barplots like
http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html this
one on the Matplotlib site.

When I run the demo source (python bars3d_demo.py) it works fine. I then
changed the way xs and ys are assigned, to
  xs = np.array([1.,2.,3.]) # was xs = np.arange(20)
  ys = np.array([1.,2.,3.]) # was ys = np.random.rand(20)
  ax.bar(xs, ys, zs=1, zdir='y', color='r', alpha=0.8)
  (ditto for two other data sets)

Now the bars are triangles. The right side of each bar is of the correct
height, but the left side of each bar starts at zero.

Python version 2.6.5
Matplotlib version 1.0.1
Ubuntu 10.04

Thanks in advance!

Complete source of my (misbehaving) program:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
xs = np.array([1.,2.,3.])
ys = np.array([1.,2.,3.])
ax.bar(xs, ys, zs=1, zdir='y', color='r', alpha=0.8)

ys = np.array([1.,4.,9.])
ax.bar(xs, ys, zs=2, zdir='y', color='r', alpha=0.8)

ys = np.array([2.,1.,2.])
ax.bar(xs, ys, zs=3, zdir='y', color='r', alpha=0.8)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')

plt.show()

···


View this message in context: http://old.nabble.com/ramp-shaped-bars--tp31236873p31236873.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Here's another data point. My guess is this is a bug with Axes3D: I
can recreate the problem with 3 bars, but with >4 bars everything
works okay. On my setup, with exactly 4 bars, the leftmost edge of the
bars doesn't get a border, so something possibly related is going on
there too.

Angus.

···

On 25 March 2011 07:31, jford14685 <jford14685@...287...> wrote:

I am a newbie Python programmer trying to make 3d barplots like
http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html this
one on the Matplotlib site.

When I run the demo source (python bars3d_demo.py) it works fine. I then
changed the way xs and ys are assigned, to
xs = np.array([1.,2.,3.]) # was xs = np.arange(20)
ys = np.array([1.,2.,3.]) # was ys = np.random.rand(20)
ax.bar(xs, ys, zs=1, zdir='y', color='r', alpha=0.8)
(ditto for two other data sets)

Now the bars are triangles. The right side of each bar is of the correct
height, but the left side of each bar starts at zero.

--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh

Well, what do you know? For once, the call of the noob, "Hey! there must be a bug" speaks truth.
Thanks, Angus! I added a little code to duplicate the last point until the array length is at least 5, and everything looks just fine.

···

On 03/25/2011 01:10 PM, Angus McMorland wrote:

On 25 March 2011 07:31, jford14685<jford14685@...287...> wrote:

I am a newbie Python programmer trying to make 3d barplots like
http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html this
one on the Matplotlib site.

When I run the demo source (python bars3d_demo.py) it works fine. I then
changed the way xs and ys are assigned, to
  xs = np.array([1.,2.,3.]) # was xs = np.arange(20)
  ys = np.array([1.,2.,3.]) # was ys = np.random.rand(20)
  ax.bar(xs, ys, zs=1, zdir='y', color='r', alpha=0.8)
  (ditto for two other data sets)

Now the bars are triangles. The right side of each bar is of the correct
height, but the left side of each bar starts at zero.

Here's another data point. My guess is this is a bug with Axes3D: I
can recreate the problem with 3 bars, but with>4 bars everything
works okay. On my setup, with exactly 4 bars, the leftmost edge of the
bars doesn't get a border, so something possibly related is going on
there too.

Angus.

Would you mind filing a bug for this in the issue tracker?

Mike

···

________________________________________
From: Jim Ford [jford14685@...287...]
Sent: Friday, March 25, 2011 11:25 AM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] ramp shaped bars?

Well, what do you know? For once, the call of the noob, "Hey! there must
be a bug" speaks truth.
Thanks, Angus! I added a little code to duplicate the last point until
the array length is at least 5, and everything looks just fine.

On 03/25/2011 01:10 PM, Angus McMorland wrote:

On 25 March 2011 07:31, jford14685<jford14685@...287...> wrote:

I am a newbie Python programmer trying to make 3d barplots like
http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html this
one on the Matplotlib site.

When I run the demo source (python bars3d_demo.py) it works fine. I then
changed the way xs and ys are assigned, to
  xs = np.array([1.,2.,3.]) # was xs = np.arange(20)
  ys = np.array([1.,2.,3.]) # was ys = np.random.rand(20)
  ax.bar(xs, ys, zs=1, zdir='y', color='r', alpha=0.8)
  (ditto for two other data sets)

Now the bars are triangles. The right side of each bar is of the correct
height, but the left side of each bar starts at zero.

Here's another data point. My guess is this is a bug with Axes3D: I
can recreate the problem with 3 bars, but with>4 bars everything
works okay. On my setup, with exactly 4 bars, the leftmost edge of the
bars doesn't get a border, so something possibly related is going on
there too.

Angus.

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options