等高線のラベルを指数​表示にするにはどうす​ればいいですか?

x=linspace(1,3,30);
y=linspace(1,3,30);
[X Y]=meshgrid(x,y);
Z=(X.^2+Y.^2)*1e3;
contour(X,Y,Z,'ShowText','on')
上記コードで画像のような等高線をプロットしたとします。 このときラベルを指数表示(例:4000->4.0x10^3) にするにはどうすればいいでしょうか。

 Risposta accettata

Akira Agata
Akira Agata il 30 Gen 2018

3 voti

等高線のラベルを付ける位置をマウスで指定する必要がありますが、たとえば下記のようにするとラベルを指数表示にすることができます。
x = linspace(1,3,30);
y = linspace(1,3,30);
[X Y] = meshgrid(x,y);
Z = (X.^2+Y.^2)*1e3;
[C,h] = contour(X,Y,Z);
t = clabel(C,h,'manual')
set(t,'BackgroundColor',[1 1 1]);
for kk = 1:numel(t)
t(kk).String = sprintf('%.2e',t(kk).UserData);
end

1 Commento

yuya inatomi
yuya inatomi il 30 Gen 2018
ありがとうございます!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!