How to make filled contour plot

6 次查看(过去 30 天)
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?

回答(2 个)

Russel Burgess
Russel Burgess 2021-3-8
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 2021-3-9
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?

类别

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