
二次元グラフとそれに対応したカラーバーを表示させる方法
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
二次元グラフをplotする際にカラーバーを表示させたいのですが,調べてもカラーバーを三つめの変数として用いるものだけで,二次元グラフの値をそのままカラーバーとして表す方法を探しております.(下記のように)
0 Commenti
Risposte (1)
Akira Agata
il 20 Lug 2020
imagesc を使ってデータをヒートマップとして可視化するのはいかがでしょうか?
ご参考までに、簡単な例を作成してみました。
% Sample Data
x = linspace(0,2*pi);
y = 0.01 + sin(x).^2;
% Visualize the data
figure
ax1 = subplot(2,1,1);
semilogy(x,y);
ax2 = subplot(2,1,2);
imagesc(x,1,y)
ax2.ColorScale = 'log';
ax2.YTick = [];
linkaxes([ax1 ax2],'x')

2 Commenti
Akira Agata
il 30 Lug 2020
なるほど、x軸も対数にする必要があるのですね。
あいにく imagesc で表示するとx軸の対数化が困難なので、別の方法を試してみました。
下記のように、surf 関数で3次元表示したあと、真上(z軸のプラス側)から見下ろす形にして ColorScaleとYScaleを対数化する方法はいかがでしょうか?
(ついでに、上側のプロットも loglog 関数でプロットするようにしました)
% Sample Data
x = linspace(0.01,2*pi);
y = 0.01 + sin(x).^2;
% Prepare for surf plot
[xGrid, yGrid] = meshgrid(x,[0 1]);
zGrid = [y; y];
% Visualize the data
figure
ax1 = subplot(2,1,1);
loglog(x,y);
ax2 = subplot(2,1,2);
surf(xGrid,yGrid,zGrid,'EdgeColor','none')
view(2)
ax2.XLim = ax1.XLim;
ax2.XScale = 'log';
ax2.YTick = [];
ax2.ColorScale = 'log';
grid off;
box on;

Vedere anche
Categorie
Scopri di più su データ分布プロット 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!