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

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 commentaires

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?
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)

Connectez-vous pour commenter.

Réponses (1)

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 commentaires

I have 2 figures. My first figure looks like this
Here I took the minimum and maximum y value from each x bin and then plotted them over second figure (Black dashed lines). So, now from the second figure I just want to plot values which are inside these black dashed lines (which will actually correspond to the data in my figure 1). I don't need values/data to be displayed outside the black dashed lines. Data is same in both figures, number of bins and how I dispalyed it is different.
If the dashed black lines are essentially the boundary of what you call Figure 1 in your last comment, then just plot those points in figure 1 and plot the boundary around it. I still don't know why you think you're having stuff outside the boundary plotted, and I don't understand how you got that smooth gradient of color.
I used pcolor
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)
'I still don't know why you think you're having stuff outside the boundary plotted'
For my second figure I just want the area inside black dashed lines, not outside one. If you look at the black dashed lines pattern and data plotted in figure 1 you will see it's same. For the second figure I applied linear regression to predict some variables and then plotted it. this color here represents Temperature
I can't run the code. What is Model1 and Model2?
Model1 and Model2 are 2 equations used to predict Temperature and radius using linear regression model.
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?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Tags

Question posée :

le 10 Déc 2023

Commenté :

le 11 Déc 2023

Community Treasure Hunt

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

Start Hunting!

Translated by