plotyy
がの異なる左右のyaxesを使用して、2つの通常のプロットをプロットするためのコマンドですが、私はあなたがそれをやろうとして何ができるとは思いません。 (すなわち、棒グラフで2つのプロットを混合する)。しかし、plotyy
は文字通り、同じ位置に2つの軸を重ね合わせてシースルーを作る単純なケースです。だから一般的に同じアプローチを使うことができます。
この(プラスいくつかの余分なキラキラ)を達成するために再加工された上でここにあなたの例です:
x = [1, 2, 3, 4, 5]; labels = ["Data 1"; "Data 2"; "Data 3"; "Data 4"; "Data 5"];
y1 = [137, 15, 2, 3, 37]; y2 = [43, 1, 67, 97, 41]; y3 = [0, .2, .3, .104, .09];
ax_left = axes('position', [0.15, 0.12, 0.7, 0.82]); % manually positioned
plot (x, y1, 'r-', 'linewidth', 3); hold on
plot (x, y2, 'g:', 'linewidth', 3); hold off
set (ax_left, ...
'fontsize', 16, 'fontweight', 'bold', 'labelfontsizemultiplier', 1.2, ...
'color', 'none', ... % makes 'background' see-through
'box', 'off', ... % prevents left axis ticks in the right axis
'xlim', [0, 6], 'ylim', [0, 150], 'xtick', x, 'xticklabel', labels);
xlabel('Version'); ylabel('Left Y-Axis');
ax_right = axes('position', [0.15, 0.12, 0.7, 0.82]); % same position as above
bar (x, y3, 0.5, 'facecolor', [0, 0.5, 1]); % nice narrow light blue columns
set (ax_right, ...
'fontsize', 16, 'fontweight', 'bold', 'labelfontsizemultiplier', 1.2, ...
'yaxislocation', 'right', ...
'ycolor', [0, 0.5, 1], ... % same nice light blue color as bar chart
'box', 'off', 'xlim', [0, 6], 'ylim', [0, 0.35], 'xtick', []);
ylabel('Data');
% ensure axes are stacked in the order you want them to appear (bottom to top)
axes(ax_right);
axes(ax_left);
更新... yyaxisはオクターブで正しい関数ではありません。しかし、私はまだ私が持っているデータで動作するようにplotyy関数を作る方法が不明です。 –
あなたは 'plotyy'関数を探していますか? –
私は、私が間違っていたことを理解しました。私はplotyy関数で変数を正しく設定していませんでした。 –