How to set axis background color of inset image?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 5 de Ag. de 2023
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.
Respuesta aceptada
Voss
el 5 de Ag. de 2023
Editada: Voss
el 5 de Ag. de 2023
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;
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!