複数の x 軸と y 軸があるチャートのマーカー表示

2 vues (au cours des 30 derniers jours)
riku
riku le 18 Juil 2019
複数の x 軸と y 軸があるチャートを作成した際に、描画コマンドとしてlineを使用しているのですが、線でしか表示されず、マーカーを表示させたいですが、エラーが出てしまい出来ない状態です。複数の x 軸と y 軸があるチャートを作成するためにはplotは使えないようなので困っています。
  4 commentaires
madhan ravi
madhan ravi le 18 Juil 2019
Can you provide the missing variable datas too?
riku
riku le 18 Juil 2019
Sorry, It's secert.

Connectez-vous pour commenter.

Réponse acceptée

Kazuya
Kazuya le 20 Juil 2019
うまくいかない状況を共有できれば解決も速いと思います。使用するデータに依存する現象だと難易度かなりあがります。
以下、乱数で適当プロットしてみましたが、マーカーの表示も問題ありませんでした。
R2019a で試しましたが、バージョンによるんでしょうか・・。
エラーがでるとのことですが、どんなエラーメッセージですか?
figure
frequency = rand(10,1);
height = rand(10,1);
line(frequency,height,'Color','b','LineWidth',2,'Marker','x');
grid(gca,'minor');
ax1 = gca;
ax1.XColor = 'b';
ax1.YColor = 'b';
set(gca,'FontSize',20);
xlabel('周波数[Hz]','FontSize',20);
ylabel('高度[km]','FontSize',20);
% xlim([0 3000]);
ylim([0,1])
ax1_pos = ax1.Position;
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
ondo = rand(10,1);
line(ondo,height+1,'Parent',ax2,'Color','r','LineWidth',2,'Marker','o');
ax2.XColor = 'r';
ax2.YColor = 'r';
set(gca,'FontSize',20);
xlabel('温度[K]','FontSize',20);
ylabel('高度[km]','FontSize',20);
ylim([1,2])

Plus de réponses (1)

Etsuo Maeda
Etsuo Maeda le 25 Juil 2019
Kazuyaさんに便乗しまして、plot関数を使った複数軸プロットの方法をご紹介しておきます。
プロット系の関数は実行時にaxesのプロパティをリセットしてしまいます。
予めNextPlotプロパティをreplacechildrenにしておくか、plotしてからaxesのプロパティを調整するようにしておけば、plot関数を使った複数軸プロットが実現できます。
ドキュメンテーション「グラフの Figure および座標軸の準備」
untitled.png
xL = 1:10;
yL = sin(xL);
xR = -xL;
yR = sin(xR);
f = figure;
axL = axes('Parent', f);
axL.NextPlot = 'replacechildren';
axL.XColor = 'b';
axL.YColor = 'b';
axL.Box = 'off';
axL.Color = 'g';
myPos = axL.Position;
axR = axes('Parent', f, 'Position', myPos);
axR.NextPlot = 'replacechildren';
axR.XColor = 'r';
axR.YColor = 'r';
axR.Box = 'off';
axR.XAxisLocation = 'top';
axR.YAxisLocation = 'right';
axR.Color = 'none';
hL = plot(axL, xL, yL, 'bo-', 'MarkerFaceColor', 'b', 'MarkerSize', 8);
hR = plot(axR, xR, yR, 'ro-', 'MarkerFaceColor', 'r', 'MarkerSize', 18);
legend([hL, hR], 'Left', 'Right')
HTH

Community Treasure Hunt

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

Start Hunting!