# How to shift streamslice() plot into background?

4 visualizzazioni (ultimi 30 giorni)
Sarah Kessler il 25 Mag 2023
Commentato: Sarah Kessler il 26 Mag 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
% 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?
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Dave B il 26 Mag 2023
Modificato: Dave B il 26 Mag 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
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')
##### 1 CommentoMostra NessunoNascondi Nessuno
Sarah Kessler il 26 Mag 2023
Thanks, it works now!

Accedi per commentare.

### Categorie

Scopri di più su Vector Fields in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by