How to make filled contour plot
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (2)
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().
0 comentarios
Ver también
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!