How to make filled contour plot

6 visualizaciones (últimos 30 días)
mukesh bisht
mukesh bisht el 8 de Mzo. de 2021
Respondida: mukesh bisht el 9 de Mzo. de 2021
I want to plot a filled contour for the following case: I have a column vector A= [1; 1; 2; 1; 2; 2; 1; 2; 1; 2] containing two size particles (1&2). Over the time, the values in the vector A get segreggated i.e. after some time interval(discrete) vector becomes A = [1;1;1;1;1;2;2;2;2;2]. Now I want a filled contour plot for this time dependent segregation with value 2 represented by blue color and value 1 represented by orange color. How to do it?

Respuestas (2)

Russel Burgess
Russel Burgess el 8 de Mzo. de 2021
Assuming you have many values of A across time, you could do this by assembling them into a matrix to be fed into contourf(), then use colormap() to set the colours. For example, if the matrix of A changing over time is (each row is a new value of A in time):
A = [1 1 2 1 2 2 1 2 1 2; ...
1 1 2 1 2 2 1 1 2 2; ...
1 1 1 2 2 1 2 1 2 2; ...
1 1 1 2 2 1 1 2 2 2; ...
1 1 1 2 1 1 2 2 2 2; ...
1 1 1 1 2 1 2 2 2 2; ...
1 1 1 1 1 2 2 2 2 2]';
Then you can plot this out by:
contourf(A, 1);
colormap([1 0.5 0; 0 0 1]);
The second argument to contourf() specifies to use only one contour (so, two regions). The arguments to colourmap() specify the RGB colours - in this case orange for the lowest value and blue for the highest. You can feed values for the x/y axes into contourf() in the same way as contour().

mukesh bisht
mukesh bisht el 9 de Mzo. de 2021
I am getting this type of contour. But i want that the colours do not appear in patches instead a mixed colour (orange & blue) as if the colours are flowing with time. How to do that?

Categorías

Más información sobre Contour 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!

Translated by