How to set axis background color of inset image?
11 次查看(过去 30 天)
显示 更早的评论
I want the region of an inset figure that contains the actual axis information to be solid white so that reference lines on the main figure don't get confused.
Currently my code and the output looks like this:
A = [30,480;30,250;40,250;8,60;120,366;32.5,665;12.5,237.5;60,450;110,380;61,305;122,610;37,226;120,492];
B = [80 60; 100 80; 122 110; 83 175; 310 139.5];
AR = A(:,1)./A(:,2);
figure()
scatter(A(:,2),A(:,1),80,'filled','o','MarkerEdgeColor','black','LineWidth',1)
hold on
scatter(B(:,2),B(:,1),85,'filled','^','MarkerFaceColor','#A2142F','MarkerEdgeColor','black','LineWidth',1)
ax = gca;
ax.XAxis.FontSize = 14;
ax.YAxis.FontSize = 14;
xlabel('Width (m)');
ylabel('Height (m)');
legend('Lava Domes','Lava Spines','Location','best','FontSize',14);
pos = get(ax,'Position');
inset = axes('Parent',gcf,'Position',[0.5900 0.25 0.2948 0.4300]);
hold(inset);
histogram(AR,'FaceColor','#0072BD','EdgeColor',[0 0 0],'FaceAlpha',1)
xlabel('Aspect Ratio (H/W)','FontSize',14);
ylabel('Count','FontSize',14);
inset.XAxis.FontSize = 12;
inset.YAxis.FontSize = 12;
As you can see, the number labels of the axes overlap the data, is there a way to make the background of the axes solid white so that it sits on top of the data? I have tried changing the axis colour but that only changes the colour of the text, not the actual background. The only thing I can think of is placing a rectangle and having the histogram on top of that.
Thanks!
2 个评论
Image Analyst
2023-8-5
Doing that may cover some data points. I think plotting an inset over a graph beneath it is just confusing. Personally, as a consumer of your data, I'd rather see two separate graphs.
采纳的回答
Voss
2023-8-5
编辑:Voss
2023-8-5
You can create a panel, and put the inset axes in it. (Of course, the panel may obscure some data points.)
Something like this:
A = [30,480;30,250;40,250;8,60;120,366;32.5,665;12.5,237.5;60,450;110,380;61,305;122,610;37,226;120,492];
B = [80 60; 100 80; 122 110; 83 175; 310 139.5];
AR = A(:,1)./A(:,2);
figure()
scatter(A(:,2),A(:,1),80,'filled','o','MarkerEdgeColor','black','LineWidth',1)
hold on
scatter(B(:,2),B(:,1),85,'filled','^','MarkerFaceColor','#A2142F','MarkerEdgeColor','black','LineWidth',1)
ax = gca;
ax.XAxis.FontSize = 14;
ax.YAxis.FontSize = 14;
xlabel('Width (m)');
ylabel('Height (m)');
legend('Lava Domes','Lava Spines','Location','best','FontSize',14);
inset_panel = uipanel( ...
'Parent',gcf, ...
'Position',[0.5405 0.15 0.3804 0.5276], ...
'BackgroundColor','w', ...
'BorderType','none');
inset = axes('Parent',inset_panel,'OuterPosition',[0 0 1 1]);
hold(inset);
histogram(AR,'FaceColor','#0072BD','EdgeColor',[0 0 0],'FaceAlpha',1)
xlabel('Aspect Ratio (H/W)','FontSize',14);
ylabel('Count','FontSize',14);
inset.XAxis.FontSize = 12;
inset.YAxis.FontSize = 12;
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!