How to shift streamslice() plot into background?

4 visualizzazioni (ultimi 30 giorni)
Sarah Kessler
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()
% 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;
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 but streamslice() always stays in the front. Is there any other way to move it to the back?

Risposte (1)

Dave B
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:
load wind
hold on
Visualization to show why it's happening:
hold on
Simple solution:
hold on


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