plot with contourf and define limits for x and y axis
45 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello
I have a plot by contourf, my problem is that I need the x and y axis to be with the same scale but my x values have smaller limits, and there is no values after some point (as in pic) so i need to add some points with level 0 (zero values) so that he empty part be blue.
Could you help me with that?
the U, V and JPDF data values are attached
contourf(U,V,JPDF,12,'edgecolor','none')
colorbar
caxis([0 0.3]);
hold on
plot([0 0],[-3 3],'k--',[-3 3],[0 0],'k--')
xlabel('$u`/\sqrt{\overline{u`^2}}$','interpreter','latex','FontSize',12)
ylabel('$v`/\sqrt{\overline{v`^2}}$','interpreter','latex','FontSize',12)
ax = gca; % current axes
ax.FontSize = 15;
ay = gca; % current axes
ay.FontSize = 15;
hold off
axis([-2.5 2.5 -2.5 2.5])
0 comentarios
Respuesta aceptada
Voss
el 15 de Mayo de 2022
load V.mat
load U.mat
load JPDF.mat
Add an extra column of appropriate values to U, V, and JPDF:
U(:,end+1) = 2.5;
V(:,end+1) = V(:,end);
JPDF(:,end+1) = min(JPDF(:));
figure(); % separate figures for demonstration
contourf(U,V,JPDF,12,'edgecolor','none')
colorbar
caxis([0 0.3]);
hold on
plot([0 0],[-3 3],'k--',[-3 3],[0 0],'k--')
xlabel('$u`/\sqrt{\overline{u`^2}}$','interpreter','latex','FontSize',12)
ylabel('$v`/\sqrt{\overline{v`^2}}$','interpreter','latex','FontSize',12)
ax = gca; % current axes
ax.FontSize = 15;
hold off
axis([-2.5 2.5 -2.5 2.5])
Alternatively, you can achieve the same effect by setting the color of the axes to be the first color in the colormap (i.e., the color of the minimum value of the contour):
figure(); % separate figures for demonstration
load V.mat % restore original data
load U.mat
load JPDF.mat
contourf(U,V,JPDF,12,'edgecolor','none')
colorbar
caxis([0 0.3]);
hold on
plot([0 0],[-3 3],'k--',[-3 3],[0 0],'k--')
xlabel('$u`/\sqrt{\overline{u`^2}}$','interpreter','latex','FontSize',12)
ylabel('$v`/\sqrt{\overline{v`^2}}$','interpreter','latex','FontSize',12)
ax = gca; % current axes
ax.FontSize = 15;
hold off
axis([-2.5 2.5 -2.5 2.5])
cmap = get(ax,'Colormap');
set(ax,'Color',cmap(1,:));
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Colormaps 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!