Plot 2D surface with z axis as colored bar
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
I'm trying to write a code to plot the attached figure. Basically, my X values will vary between 2.99 and 3.23 with corresponding Z values varied from 3.3 to 3.7, while my Y values is not important here. My main idea is to present the variation in Z values as a colored map. I am wondering if anyone has an idea on how to draw such plot.
0 comentarios
Respuestas (1)
Star Strider
el 5 de Sept. de 2019
Example —
M = peaks(20); % Data For Plot
figure
[c,h] = contourf(M);
h.LineStyle = 'none';
or:
figure
subplot(2,1,1)
[c,h] = contourf(M);
h.LineStyle = 'none';
Ax1 = gca;
sp1 = Ax1.Position;
Ax1.Position = sp1 + [0 0 -0.1 0];
subplot(2,1,2)
[c,h] = contourf(M);
h.LineStyle = 'none';
Ax2 = gca;
sp2 = Ax2.Position;
Ax2.Position = sp2 + [0 0 -0.1 0];
hc2 = colorbar;
hcp2 = hc2.Position;
hc2.Position = hcp2 + [0.15 0 0 hcp2(4)*1.4]
2 comentarios
Star Strider
el 5 de Sept. de 2019
You need to use a different interpolation method:
zz = griddata(x, y, z, xx, yy, 'v4');
The 'nearest' method will also work.
If you want to use any other method, you need to set the NaN values (that comprise all except the diagonal of ‘zz’ with all the other methods) to some definite numerical value, for example:
zz = griddata(x, y, z, xx, yy);
zz(isnan(zz)) = 0;
Experiment to get the result you want.
Ver también
Categorías
Más información sobre Spline Postprocessing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!