X and Y axis alignment
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Teoman Selcuk
am 3 Dez. 2021
Beantwortet: Awais Saeed
am 3 Dez. 2021
How would I be able to make a bar graph with the colours of Y values over 30 blue and the colors of Y values under 30 red. I would also like to name to place a title (title) that is bold and has a font of 16px and a Y and X axis with the names(y_axis, x_axis ) plot on the bar graph how would I be able to do those?
X = categorical({'Small','Medium','Large','Extra Large'});
X = reordercats(X,{'Small','Medium','Large','Extra Large'});
Y = [10 21 33 52];
Y_over = find(Y>30)
Y_under=find(Y<30)
y_axis = 'Y plots'
x_axis = 'X plots'
title = 'Comparing Y and X over intervals'
bar(X,Y)
0 Kommentare
Akzeptierte Antwort
Awais Saeed
am 3 Dez. 2021
Something like this?
X = categorical({'Small','Medium','Large','Extra Large'});
X = reordercats(X,{'Small','Medium','Large','Extra Large'});
Y = [10 21 33 52];
ylabel('y-axis','FontSize',12)
xlabel('x-axis','FontSize',12)
title('Comparing Y and X over intervals','FontSize',16);
% threshold value
threshold = 30;
% plot bar one by one
figure(1)
hold on
for ii = 1:1:length(X)
b = bar(X(ii), Y(ii));
if (Y(ii) >= threshold)
set(b, 'FaceColor', 'r');
else
set(b, 'FaceColor', 'b');
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!