Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Bug in Matlab when plotting 3D bar graphs?

Subject: Bug in Matlab when plotting 3D bar graphs?

From: Iwan Toknow

Date: 19 Feb, 2009 16:26:01

Message: 1 of 2

Hi,

I'm not sure if I'm making a mistake or if Matlab does have a bug when it comes to plotting 3D bar graphs. Try out the following:

x1 = [0.9991 0.9996 0.9998 1.0 0.9997 0.9995 0.9993];
bar3(x1)

All ok up to now. Only problem is that all the bars seem of equal height since they're all close to 1.

So we try to change the axes:
axis([0.6 1.4 0 8 0.999 1])

Now look at the 3D bar graph. You'll see that it actually leaks out from the bottom!!

Any idea why this happens? Is this a bug in Matlab or am I missing something here?

Thanks!
Sam

Subject: Bug in Matlab when plotting 3D bar graphs?

From: Yuri Geshelin

Date: 19 Feb, 2009 17:46:01

Message: 2 of 2

"Iwan Toknow" <iwan2no_removethis_@hotmail.com> wrote in message <gnk16p$e1k$1@fred.mathworks.com>...
> Hi,
>
> I'm not sure if I'm making a mistake or if Matlab does have a bug when it comes to plotting 3D bar graphs. Try out the following:
>
> x1 = [0.9991 0.9996 0.9998 1.0 0.9997 0.9995 0.9993];
> bar3(x1)
>
> All ok up to now. Only problem is that all the bars seem of equal height since they're all close to 1.
>
> So we try to change the axes:
> axis([0.6 1.4 0 8 0.999 1])
>
> Now look at the 3D bar graph. You'll see that it actually leaks out from the bottom!!
>
> Any idea why this happens? Is this a bug in Matlab or am I missing something here?
>
> Thanks!
> Sam

Hi,

I don't think it's a matlab bug. It's the way matlab automatically chooses the limits.

Try bar3(x1-.999) instead, without typing axis(....)

Is this better?

Of course, the z-axis may now look weird, but you didn't tell us what you want it to look like.

Anyway, this is easy to change by resetting Zticks and zticklabels.

Yuri

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us