How to shift streamslice() plot into background?

4 Ansichten (letzte 30 Tage)
Sarah Kessler
Sarah Kessler am 25 Mai 2023
Kommentiert: Sarah Kessler am 26 Mai 2023
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?

Antworten (1)

Dave B
Dave B am 26 Mai 2023
Bearbeitet: Dave B am 26 Mai 2023
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')

Kategorien

Mehr zu Vector Fields finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by