How to just plot the data inside the minimum and maximum values in a figure?
9 次查看(过去 30 天)
显示 更早的评论
Hello,
I have 2 figures, From the frst figure I calculated the minimum and maximum y values from each x bin and then plotted these minimum and maximum values as dashed black line over second figure. My code:
y1 = y;
y1(isnan(z))= nan;
x1 = x(1,:);
minvalues = zeros(1,16);
maxvalues = zeros(1,16);
for k = 1:16
x2 = x1(:,k);
minvalues(k) = min(y1(:,k));
maxvalues(k) = max(y1(:,k));
end
plot(ax,x1,minvalues, '--k', 'Linewidth', 2)
plot(ax,x1,maxvalues, '--k', 'Linewidth', 2)
My second figure looks like this, I just want to plot data which is inside this boundary (minimum and maximum values). Outside area should be white. How can I do this? Thank you
2 个评论
Walter Roberson
2023-12-10
Do I understand correctly that you have another array, that is not x or y or z, that is being used to form the color portion of the plot? If so then are you using pcolor() or surf() or image() or imagesc() or something else to display that array at present?
回答(1 个)
Image Analyst
2023-12-10
Not sure what you mean but you can use xlim and ylim to set the ranges that are visible inside the plot box.
Regarding making some part of the graph white, we're also not sure how you're getting that colored gradient background. Are you plotting to a graph, or over (on top of) a digital image?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
6 个评论
Image Analyst
2023-12-11
nBin = 100;
Bin1 = logspace(-1, 2, nBin+1);
Bin2 = logspace(-1, 2, nBin+1);
[x, y] = meshgrid(Bin1, Bin2);
z_contour = Model1(x, y); %Contours are not displayed here
z_color = Model2(z_contour, x, y);
fig = figure;
set(fig, 'defaultFigureRenderer', 'painters')
set(fig, 'unit', 'centimeters', 'position', [50 10 13 11]);
ratio = fig.Position(3)/fig.Position(4);
axPos = [0.1 0.1 0.7 0.7*ratio];
ax = axes(fig, 'Position', axPos);
pc = pcolor(ax, x, y, z_color);
pc.EdgeColor = 'none';
ax.CLim = [-30 -15];
colormap(jet);
ax.XLim = [0.1 100];
ax.YLim = [0.1 1000];
plot(ax,x1,minvalues, '--k', 'Linewidth', 2) %I got Minimum and Maximum values from the lines of code I posted in my question
plot(ax,x1,maxvalues, '--k', 'Linewidth', 2)
How are YOU getting past that point?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!