plot with contourf and define limits for x and y axis

75 views (last 30 days)
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])

Accepted Answer

Voss
Voss on 15 May 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,:));

More Answers (0)

Categories

Find more on Colormaps 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!