필터 지우기
필터 지우기

How to just plot the data inside the minimum and maximum values in a figure?

조회 수: 4 (최근 30일)
Zhou Ci
Zhou Ci 2023년 12월 10일
댓글: Image Analyst 2023년 12월 11일
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
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?
Zhou Ci
Zhou Ci 2023년 12월 11일
Yes exactly I am using pcolor, here is my complete code:
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)

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
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
Zhou Ci
Zhou Ci 2023년 12월 11일
Model1 and Model2 are 2 equations used to predict Temperature and radius using linear regression model.
Image Analyst
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
Unrecognized function or variable 'Model1'.
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 CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by