How to draw negative values on bar when it contains negative values
Mostra commenti meno recenti
if my data have negative values
I want to draw the bar values uniformly on the top of the bar chart, like the numbers above 0 on the way, and the values below 0 are all drawn inside the bar chart
clear all ; clc ;clf
yyy = [1 2 3 4 ; 2 3 -4 5 ; -6 -10 5 7 ; -1 -5 8 7]
x = [1:4]
bar1 = bar(x,yyy)
hAx=gca; % get a variable for the current axes handle
% hAx.XTickLabel=str; % label the ticks
hT=[]; % placeholder for text object handles
for i=1:length(bar1) % iterate over number of bar objects
hT=[hT text(bar1(i).XData+bar1(i).XOffset,bar1(i).YData,num2str(bar1(i).YData.','%.3f'), ...
'VerticalAlignment','bottom','horizontalalign','center')];
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Bar Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
