Adding XTickLabels to grouped individual bar graphs and plot on hold
7 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!