File Exchange Pick of the Week

July 20th, 2007

Colored 3-d bar plots

bar4y.jpg

As I mention quite frequently, the best way to become Pick of the Week is to write code that solves a problem that I am having or a problem I think many other people are having. That is how I found bar4viaColor. The customer I was working with wanted to show some Z data that varied as a function of X and Y.

Normally, this would be a MESH or SURF plot.

mesh.jpg
surf.jpg

However, the twist was they did not want to interpolate between the known data points. This would point to BAR3.

bar3y.jpg

The final complication was that the height of the bar should dictate the color of the bar. This is possible, but not easy with BAR3. I just knew someone would have written the code to do this and posted it to MATLAB Central. I was right: bar4viaColor.

2 Responses to “Colored 3-d bar plots”

  1. Luigi replied on :

    Hi Doug,
    Would you be able to post the files you used to generate the plots above?
    Thanks!

  2. Doug replied on :

    I used

    >>[x,y,z] = peaks;

    for the dataset, then just used each of the commands in their simplest form, ie

    surf(x,y,z)

    Check the titles of the figures to see the command I used.

    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.