필터 지우기
필터 지우기

insert one of bar graph "inside" the other

조회 수: 2 (최근 30일)
Alberto Acri
Alberto Acri 2023년 8월 2일
댓글: Star Strider 2023년 8월 3일
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:

채택된 답변

Star Strider
Star Strider 2023년 8월 2일
편집: Star Strider 2023년 8월 2일
See for example Position Multiple Axes in Figure in the axes documentation for one way to do this.
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
Alberto Acri
Alberto Acri 2023년 8월 3일
Hi @Star Strider. I would like to apply the text on the x and y axis to 'graph_A' and not to 'graph_A_zoom'. I've tried but it either applies it to 'graph_A_zoom' or it doesn't fit (but it doesn't give me an error). Could you tell me how to make it visible on 'graph_A'?
xlabel('Repetition', 'FontSize', 13)
ylabel('Numbers', 'FontSize', 13)
Star Strider
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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by