insert one of bar graph "inside" the other
1 次查看(过去 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:
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!