insert one of bar graph "inside" the other
5 ビュー (過去 30 日間)
古いコメントを表示
Hello! I have two bar graphs. I would like to insert one of these graphs "inside" the other. Is it possible to do this?
For example like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1448442/image.png)
0 件のコメント
採用された回答
Star Strider
2023 年 8 月 2 日
編集済み: Star Strider
2023 年 8 月 2 日
EDIT — (2 Aug 2023 at 17:29)
Added ‘Example’.
Example (using ‘CountArray_S’) —
LD1 = load(websave('CountArray_S','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1448127/CountArray_S.mat'));
CountArray_S = LD1.CountArray_S;
Lv1 = ismember(CountArray_S(:,1), 65:74); % Select 'x'-Values For Second 'ases'
figure
ax1 = axes('Position',[0.1 0.1 0.7 0.7]);
ax2 = axes('Position',[0.30 0.35 0.48 0.40]);
hbh(1) = barh(ax1,CountArray_S(:,1), CountArray_S(:,2), 'FaceColor','r', 'EdgeColor','none');
hbh(2) = barh(ax2,CountArray_S(Lv1,1), CountArray_S(Lv1,2), 'FaceColor','r', 'EdgeColor','none');
Make appropriate changes to get the desired result.
.
4 件のコメント
Star Strider
2023 年 8 月 3 日
In this instance, the axes that the labels apply to must be explicitly stated.
I created axis labels for both axes here in the event that you may also want them for the zoomed axes —
load CountArray_A.mat
load CountArray_A_zoom.mat
x_A = CountArray_A(:,1).';
y_A = CountArray_A(:,2);
figure();
ax1 = axes('Position',[0.1 0.1 0.7 0.7]);
ax2 = axes('Position',[0.3 0.5 0.5 0.3]);
graph_A = barh(ax1,x_A,y_A,'FaceColor',[1 0 0],'EdgeColor','none');
name_A = "analysis A";
% legend({name_A},'Location','southeast','Orientation','horizontal')
x_A_zoom = CountArray_A_zoom(:,1).';
y_A_zoom = CountArray_A_zoom(:,2);
% figure();
graph_A_zoom = barh(ax2,x_A_zoom,y_A_zoom,'FaceColor',[1 0 0],'EdgeColor','none');
xlabel(ax1,'Repetition', 'FontSize', 13)
ylabel(ax1,'Numbers', 'FontSize', 13)
xlabel(ax2,'Repetition Zoomed', 'FontSize', 8)
ylabel(ax2,'Numbers Zoomed', 'FontSize', 8)
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!