How to plot only non-zero positive values in a bar3 graph?

This should be trivial but I can't figure it out. I have an NxM matrix, which I am plotting as a bar3 graph. All of them have the same colour (blue), and when a value in the matrix is zero, there is a blue square at the z=0 value, with black edges.
I would like to plot it in a way that the zero values are not plotted. Actually, it would be even better if the black edges of the square (the frame) would be plotted but the inside would be white (i.e. the square would not be filled with blue).
Is there any way to do this?
I attached a picture of how it looks now.

6 commentaires

Post your code
Well, it's not like I have a code that doesn't work, I simply don't know how to do this. All there is in my code is this:
axes(handles.bins) %the handle of the axes I'm plotting to
bar3(RM,'b') %RM is the matrix, numbers are within [0;100000]
set(gca,'XTickLabel',binM) %binM is linearly spaced
set(gca,'YTickLabel',binR) %binR is linearly spaced
What happens if you replace RM w/
RM(RM==0)=NaN;
? Does bar3 then automagically do _the_right_thing_ (tm) by effectively hiding the zeros?
Unfortunately NaN appears as a filled square at z=0, too. The same way as 0 values do.
Well, it was a thought that bar might ignore NaNs as does plot...
Too bad. No further ideas other than figuring out how to set the patch values vs the level. My use has been minimal and what attempts have made previously were mostly unsuccessful--I don't fully understand how the patch color map assignment thingie works...
I opened the bar3.m which calls the makebars.m function and in that one I found the part that replaces all NaN values with zeros.
k = find(isnan(y));
if ~isempty(k), y(k) = 0; end
I also tried to simply remove this part but didn't do the trick. I don't understand how exactly these functions work, I just hope there is a simpler way to do this.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by