insert one of bar graph "inside" the other
조회 수: 2 (최근 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에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!