BillyJean
BillyJean

Reputation: 1587

How to fix axis mismatch between streamslice and imagesc plot?

I am trying to plot the streamlines (vx, vy), velocity along x and y of a data set on top of a imagesc of the vz, velocity along z. The data set and the streamline-plot is shown in this MWE:

x=[0    0.0125    0.0250    0.0375    0.0500,
     0    0.0125    0.0250    0.0375    0.0500,
     0    0.0125    0.0250    0.0375    0.0500,
     0    0.0125    0.0250    0.0375    0.0500,
     0    0.0125    0.0250    0.0375    0.0500];

 y=[0         0         0         0         0,
0.0125    0.0125    0.0125    0.0125    0.0125,
0.0250    0.0250    0.0250    0.0250    0.0250,
0.0375    0.0375    0.0375    0.0375    0.0375,
0.0500    0.0500    0.0500    0.0500    0.0500];

vx=[0.0009   -0.0019   -0.0058   -0.0040   -0.0028,
0.0012    0.0159    0.1207    0.1465    0.0985,
0.0007    0.0018   -0.0367    0.2432   -0.0053,
0.0004    0.0920    0.1796    0.3807    0.0338,
-0.0006    0.1708    0.1764    0.2567    0.1256];

vy=[0.0002    0.0000   -0.0001   -0.0001   -0.0001,
-0.0003   -0.0156   -0.0076   -0.0251   -0.0433,
-0.0008   -0.0113   -0.0218   -0.0519   -0.0720,
-0.0006   -0.0091   -0.0326   -0.0778   -0.1087,
-0.0003   -0.0026   -0.0025   -0.0416   -0.1048];


vz=[0.0002    0.0000   -0.0001   -0.0001   -0.0001,
-0.0003   -0.0156   -0.0076   -0.0251   -0.0433,
-0.0008   -0.0113   -0.0218   -0.0519   -0.0720,
-0.0006   -0.0091   -0.0326   -0.0778   -0.1087,
-0.0003   -0.0026   -0.0025   -0.0416   -0.1048];

close all
clc


figure(1)
imagesc([0 0.05], [0 0.05], vx)
colorbar

figure(2)
imagesc([0 0.05], [0 0.05], vy)
colorbar

figure(3)
streamslice(x, y, vx, vy)

However, when I inspect figure 3 and compare it to figure 1 and 2, there is clearly something off. In imagesc the axes are basically x pointing vertically downwards and y pointing to the right but in the streamlines the axes are as usual, y up and x to the right. Is there a way to match the streamline-axes with that of imagesc so I can combine to two plots?

Upvotes: 1

Views: 146

Answers (1)

Robert Seifert
Robert Seifert

Reputation: 25242

You actually don't want to use imagesc, because you don't have pixels. You're looking for surf with view from above:

figure(1)
surf(x,y,vx)
view(0,90)
colorbar

figure(2)
surf(x,y,vy),
view(0,90)
colorbar

figure(3)
streamslice(x, y, vx, vy)

Maybe there is some transposing of matrices or turning of view required to get everything perfect.

Upvotes: 1

Related Questions