Shading a delimited area in a contour plot

3 ビュー (過去 30 日間)
Federico Naos
Federico Naos 2023 年 11 月 9 日
回答済み: Voss 2023 年 11 月 9 日
Hi,
I am looking for ways which I could shade part of a countour plot with marks. Perhaps the visual cues below could help to understand the problem:
E = 23;
F = 0:0.01:0.3;
K = round(6:0.2:20, 2);
[X, Y] = meshgrid(F, K);
RedFreq = (E * X) ./ Y;
figure;
contourf(X, Y, RedFreq);
% clabel(heatmap);
colormap('sky'); % Set colormap (e.g., 'jet', 'hot', 'cool', etc.)
colorbar; % Display colorbar
xline(0.1, 'Color', 'red', 'LineStyle', '--', 'LineWidth', 1.25);
xline(0.25, 'Color', 'red', 'LineStyle', '--', 'LineWidth', 1.25);
% xregion(0, 0.1, FaceColor="b",EdgeColor=[0.4 0 0.7])
% colorbar; % Display colorbar
grid off
hold off
The result I get is the following:
I would like to achieve the something like this:
That is, the region up to the vertical line in 0.1 would be shaded by these little dotted marks and I would also like to add that region to the legend.

採用された回答

Voss
Voss 2023 年 11 月 9 日
Maybe something like this. Adapt as needed.
E = 23;
F = 0:0.01:0.3;
K = round(6:0.2:20, 2);
[X, Y] = meshgrid(F, K);
RedFreq = (E * X) ./ Y;
figure;
contourf(X, Y, RedFreq);
hold on
Npts = 70;
xx = 0.1*rand(1,Npts);
yl = ylim();
yy = yl(1)+(yl(2)-yl(1))*rand(1,Npts);
h = plot(xx,yy,'s','Color',[0.5 0.5 0.5],'MarkerFaceColor',[0.5 0.5 0.5]);
% clabel(heatmap);
colormap('sky'); % Set colormap (e.g., 'jet', 'hot', 'cool', etc.)
colorbar; % Display colorbar
xline(0.1, 'Color', 'red', 'LineStyle', '--', 'LineWidth', 1.25);
xline(0.25, 'Color', 'red', 'LineStyle', '--', 'LineWidth', 1.25);
% xregion(0, 0.1, FaceColor="b",EdgeColor=[0.4 0 0.7])
% colorbar; % Display colorbar
grid off
hold off
legend(h,'Legend')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by