![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174808/image.png)
Only plot top part of 3D bar
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am plotting the results of cross correlation on a bar3 figure. At times, a lot of the values are 'close' to each other, so instead of plotting the bars over the entire range of scores, I'd like to limit the plot to just between the minimum and maximum values of the correlation. When I set the ZLim property, the z-axis scale is correctly set, but the bars themselves extend through the bottom of the chart (trying to find 0). How do I limit the size of the bars themselves?
%for the sake of this question, lets assume the correlation returns
x = 0.9 + (1-0.9).*rand(10,10);
inputs = 1:5:51;
figure
h = bar3(x);
set(gca, 'XTickLabel',inputs);
set(gca, 'YTickLabel',inputs);
set(gca, 'XTick',1:length(inputs));
set(gca, 'YTick',1:length(inputs));
set(gca, 'XLim', [0 length(inputs)+1]);
set(gca, 'YLim', [0 length(inputs)+1]);
set(gca, 'ZLim', [min(min(x)) max(max(x))]);
colorbar
0 Commenti
Risposta accettata
Star Strider
il 19 Apr 2014
I suggest:
% Create the ‘xt’ variable:
xt = x - min(min(x));
% Change the ‘bar3’ call to:
h = bar3(xt);
% Add these lines to your code after the ‘bar3’ call:
ztiks = floor(linspace(min(min(x)), max(max(x)), 6)*101)/100;
set(gca, 'ZTickLabel', ztiks');
% Delete or comment-out this line:
set(gca, 'ZLim', [min(min(x)) max(max(x))]);
I got this plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174808/image.png)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Distribution Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!