CONTOURF AS PATCH COMMAND
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mooner Land
el 29 de Oct. de 2019
Comentada: Mooner Land
el 1 de Nov. de 2019
Hello,
I have 3 column matrix. I want to plot contourf but plot shape is wrong. When i try with patch command shape is true. How can i do this with contourf? Here is example picture.
here is my patch figure code:
a=load('xyz.txt');
x=a(:,1);
y=a(:,2);
m1=a(:,3);
cor=[x y];
ff=reshape( 1:length(cor), 4, length(cor)/4)';
fig = figure;
pm=patch('Faces',ff,'Vertices',cor,'FaceVertexCData',m1,'FaceColor','interp','Selected','on');
colormap(flipud(jet(20)))
shading interp
colorbar
set(pm, 'edgecolor','black','LineWidth',0.5)
grid on
grid minor
3 comentarios
Respuesta aceptada
Walter Roberson
el 30 de Oct. de 2019
What you observe is expected for griddata() and other scattered interpolants. You do not have data in a number of areas, but you ask for the values in those areas, so griddata() interpolates from the existing points. By asking for data in those areas but wanting blanks there, you are implicitly saying that lack of data in an area should be treated as-if data were there and was NaN there -- but that somehow the system should know to insert those implicit nans locally, and be smart about it. For example in the place where you have two rectangles touching diagonally, you do not want interpolation between the two rectangles, even though some of those points are closer together than some of the points in the bounds that you do want to influence interpolation.
You will need to segment your data into distinct regions and grid them separately.
For the case you loaded the file for, probably the easiest would be to use an editor to divide into parts.
If you had a number of similar files to process, you can do some processing based upon clustering such as k-means, or using nearest-neighbor-with-cutoff approaches, but automatically dividing out touching diagonal boxes is probably going to take more thought.
7 comentarios
Walter Roberson
el 1 de Nov. de 2019
You could do a morphological dilation on "isnan()" of the array in order to disconnect areas that barely touch.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!