How to obtain such a plot?

1 次查看(过去 30 天)
Giacomo Tabarelli
Giacomo Tabarelli 2020-10-25
编辑: dpb 2020-10-26
I want to obtain the following plot.
I have 4 matrices I would say one for each line. In the matrices there are zeros and ones. Each matrix define a subset of the plane. They hinted me to use contourf command in MATLAB but I cannot obtain the exact result. First of all I tried to sum the matrices but then I understand that with this tecnique there will be two areas with the same values and so the same color. Then I tried with the hold on but since contourf plot has only colors with alpha = 1, it shows me only the last contourf plot and not the previuos ones.
My target is to replicate as near as I can the above plot in MATLAB. Any hits? Thanks in advance.
  2 个评论
dpb
dpb 2020-10-25
Attach the data...first guess w/o really seeing what is in each would be to scale the four regions and then sum...presuming the areas of each array cover the full space identically.
Giacomo Tabarelli
Giacomo Tabarelli 2020-10-25
编辑:Giacomo Tabarelli 2020-10-25
The matrices cover all the space identically. I attach the data. Also attach my code. Another thing I cannot understand is why I have two white areas if they have different values?

请先登录,再进行评论。

采纳的回答

dpb
dpb 2020-10-25
contourf(X,Y,rhosS+2*rhoEm+3*rhoImPl+4*rhoPl)
yields
You can set colors as wish...just need to scale the overlapping portions of the images to make them have different levels.
What is this a representation of, out of curiosity? Your data don't follow the pattern of the example exactly, but similar. This ends up with five unique areas by the automagic contour lines drawn...outside the upper right yellow region, that is.
  4 个评论
dpb
dpb 2020-10-26
编辑:dpb 2020-10-26
Z=rhosS+2*rhoEm+4*rhoImPl+8*rhoPl; % using pow2 weighting avoid overlapping
[M,hC]=contourf(X,Y,Z);
colormap(cmap)
caxis([min(Z(:)) max(Z(:))])
yields
I can't explain why caxis doesn't cover the range by default.
dpb
dpb 2020-10-26
As for the lines, that can be done -- follow the link in the contourf doc to the "Contour Properties" page and it shows how there.
I gotta run now, can come check in later on...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by