How to shift streamslice() plot into background?

조회 수: 3 (최근 30일)
Sarah Kessler
Sarah Kessler 2023년 5월 25일
댓글: Sarah Kessler 2023년 5월 26일
Hello, I want to plot the magnetic field of a body and used the streamslice() function therefore. In addition to that, I want to plot a slice of the body as well using plot() of points and a vector denoting the magnetic reference field B0 with quiver()
figure();
% plot magnetic field
s = streamslice(X, Z, Y, Bax_res, Baz_res, Bay_res, [], [], 1);
set(s, 'Color', "#0072BD");
hold on;
% plot points of triangulations of all body parts
plot(all_trs.TR1.Points(:,1), all_trs.TR1.Points(:,3), '.-', 'Color', gs(10,:), 'LineWidth',2);
hold on;
plot(all_trs.TR3.Points(:,1), all_trs.TR3.Points(:,3), '.-', 'Color', gs(6,:), 'LineWidth',2);
hold on;
plot(all_trs.TR2.Points(:,1), all_trs.TR2.Points(:,3), '.-', 'Color', gs(4,:), 'LineWidth',2);
hold on;
plot(all_trs.TR4.Points(:,1), all_trs.TR4.Points(:,3), '.-', 'Color', gs(2,:), 'LineWidth',2);
hold on;
% get B0
quiver(x1,z1,dx,dz,'ColorMode','manual','Color','#EDB120','LineWidth',2,'MaxHeadSize',1);
% colorbar
J = customcolormap([0 1], {'#000000','#FFFFFF'});
hcb = colorbar;
colormap(J);
My problem is, that streamslice() always lands at the top of the plot but I want to have it at the back. I tried things like adding uistack(s,'bottom') or the solution provided here https://de.mathworks.com/matlabcentral/answers/30212-how-to-bring-a-plot-to-the-front-or-back-among-multiple-plots but streamslice() always stays in the front. Is there any other way to move it to the back?

답변 (1개)

Dave B
Dave B 2023년 5월 26일
편집: Dave B 2023년 5월 26일
I think the issue you're running into here is this last argument you're passing into streamslice. The 1 there is causing the lines to be plotted at z = 1, and your plots/quiver are going at z = 0 (by default). You can fix this by just specifying 0 instead of 1 for this argument.
Reproduction of the problem you see:
figure
load wind
streamslice(x,y,z,u,v,w,[],[],1);
hold on
plot(xlim,ylim,'LineWidth',5,'Color','r')
Visualization to show why it's happening:
figure
streamslice(x,y,z,u,v,w,[],[],1);
hold on
plot(xlim,ylim,'LineWidth',5,'Color','r')
grid
view(3)
Simple solution:
figure
streamslice(x,y,z,u,v,w,[],[],0);
hold on
plot(xlim,ylim,'LineWidth',5,'Color','r')

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by