How can one adjust the format of the numbers displayed on a contour plot using clabel and a vector specifying the levels of the contours?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have Reduced my code to this simple form. My code actually calculates the vector V that sets the contours in an evenly spaced way no matter what. Well equal area way to be exact. How can I control the format of the numbers displayed in the labels? IE e,g,f, precision of 3 etc.... The code below provides the form XXXXX.XXXXXX but I want say x.xxe^x in the labels on the contour plot for example. I have tried to find a tick or label but didn't see them available in the get / set command for contour / clabel which is how I would have approached this for other axis objects like colorbar.
clear all, clc, format short eng, format compact,
a=linspace(0,100,100);
[X,Y] = meshgrid(a,a);
Z = X.^2 .*Y.^2;
V =[60.6005e+003 405.3483e+003 1.2596e+006 2.9207e+006 5.7763e+006,...
10.6068e+006 18.7857e+006 34.3230e+006];
figure(1)
clf
grid on, hold on,
[C,h] = contour(X,Y,Z,V,'-k');
clabel(C,h,V,'LabelSpacing',1000),
hold off,
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 11 Okt. 2012
text_handles = clabel(...) returns the handles of text objects created by clabel. The UserData properties of the text objects contain the contour values displayed. If you call clabel without the h argument, text_handles also contains the handles of line objects used to create the '+' symbols.
So to get the format you want, call clabel and record the handles, then loop through the handles fetching the UserData, formatting that number as desired, and set() the String property of the text handle to the new string, possibly also setting the Interpreter property as well if you want to use LaTeX superpositioning for the exponents.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!