![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/365941/image.jpeg)
What information is conveyed by the different colors in Matlab's contourf( ) data plots?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Noob
il 24 Set 2020
Modificato: Abdolkarim Mohammadi
il 24 Set 2020
Hi,
Matlab has a contourf( ) function, which I used a little bit last night to plot the level sets of say,
Z = f(x,y) = x*cos(y)
I called the contour function using one of Mathworks examples, so I used
contourf(X,Y,Z,10)
axis equal
on an evenly-spaced x-y meshgrid.
What do the various colors represent in the contourf( ) plot?
There's no labeling, like, say, a colormap would provide.
My motivation to plot a function's level sets is to then overlay it with plots of convergent sequences xn (maybe with an "x" marker), converging to roots of the function (using some simple methods like gradient-descent and Newton's method that I've been playing with). Namely, I notice that two algorithms may converge to different roots, when starting from the same initial guess -- so I think it would be interesting to visualize this difference and get better intuition for the geometric aspects of various root-finding algorithms.
Thanks,
0 Commenti
Risposta accettata
Abdolkarim Mohammadi
il 24 Set 2020
Modificato: Abdolkarim Mohammadi
il 24 Set 2020
You can turn on the ShowText property of the contour, or add the color bar:
x = linspace (-5, 5, 51);
y = linspace (-5, 5, 51);
[X,Y] = meshgrid (x, y);
Z = X .* cos(Y);
contourf (X, Y, Z, 'ShowText', 'on');
colorbar ();
axis ('equal');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/365941/image.jpeg)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Contour Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!