필터 지우기
필터 지우기

Adding XTickLabels to grouped individual bar graphs and plot on hold

조회 수: 4 (최근 30일)
Abdulllah
Abdulllah 2022년 7월 15일
답변: RAGHUNATHRAJU DASHARATHA 2022년 9월 20일
I have two types of plots.
1) In fist case I need to label individual bar graphs in the grouped bar plot. Here is the example
a=[4.54545454545455,88.6363636363636,27.2727272727273,77.2727272727273,54.5454545454545;31.8181818181818,61.3636363636364,38.6363636363636,68.1818181818182,54.5454545454545;54.5454545454545,61.3636363636364,59.0909090909091,54.5454545454545,50;68.1818181818182,27.2727272727273,56.8181818181818,34.0909090909091,50;90.9090909090909,11.3636363636364,68.1818181818182,15.9090909090909,40.9090909090909];
b=[0.400000000000000,0.550000000000000,0.700000000000000,0.850000000000000,1;1.39000000000000,1.54000000000000,1.69000000000000,1.84000000000000,1.99000000000000;2.34000000000000,2.49000000000000,2.64000000000000,2.79000000000000,2.94000000000000;3.36000000000000,3.51000000000000,3.66000000000000,3.81000000000000,3.96000000000000;4.29000000000000,4.44000000000000,4.59000000000000,4.74000000000000,4.89000000000000];
figure,
hold on
for i=1:5
bar(b(i,:),a(:,i))
end
figure,
hold on
for i=1:3
plot(b(i,:),a(:,i))
end
For the bar plot, I like to lable on the horizontal as shown in figure, the numbers are stored in an other matrix, say b
2) Similarly, I also want to XTickLables using values in b for the line plot.

답변 (1개)

RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA 2022년 9월 20일
As per my understanding you want to add XTickLabels to grouped individual bar graphs and plot
I would like to demonstrate it using your code with some changes
a=[4.54545454545455,88.6363636363636,27.2727272727273,77.2727272727273,54.5454545454545;31.8181818181818,61.3636363636364,38.6363636363636,68.1818181818182,54.5454545454545;54.5454545454545,61.3636363636364,59.0909090909091,54.5454545454545,50;68.1818181818182,27.2727272727273,56.8181818181818,34.0909090909091,50;90.9090909090909,11.3636363636364,68.1818181818182,15.9090909090909,40.9090909090909];
b=[0.400000000000000,0.550000000000000,0.700000000000000,0.850000000000000,1;1.39000000000000,1.54000000000000,1.69000000000000,1.84000000000000,1.99000000000000;2.34000000000000,2.49000000000000,2.64000000000000,2.79000000000000,2.94000000000000;3.36000000000000,3.51000000000000,3.66000000000000,3.81000000000000,3.96000000000000;4.29000000000000,4.44000000000000,4.59000000000000,4.74000000000000,4.89000000000000];
figure,
hold on
for i=1:5
bar(b(i,:),a(:,i))
end
p=[b(1,:) ,b(2,:), b(3,:) ,b(4,:) ,b(5,:)];
xticks(gca,p)
text(0.5 , -12 ,'Text 1','FontSize',12)
text(1.5 , -12 ,'Text 2','FontSize',12)
text(2.5 , -12 ,'Text 3','FontSize',12)
text(3.5 , -12 ,'Text 4','FontSize',12)
text(4.5 , -12 ,'Text 5','FontSize',12)
figure,
hold on
for i=1:3
plot(b(i,:),a(:,i))
end
p=[b(1,:) ,b(2,:), b(3,:) ];
xticks(gca,p)
text(0.5 , -12 ,'Text 1','FontSize',12)
text(1.5 , -12 ,'Text 2','FontSize',12)
text(2.5 , -12 ,'Text 3','FontSize',12)
text(3.5 , -12 ,'Text 4','FontSize',12)
text(4.5 , -12 ,'Text 5','FontSize',12)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by