How to shift streamslice() plot into background?
2 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Dave B
on 26 May 2023
Edited: Dave B
on 26 May 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')
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!