フィルターのクリア

Double y-axis plot

2 ビュー (過去 30 日間)
David du Preez
David du Preez 2017 年 6 月 1 日
編集済み: dpb 2017 年 6 月 1 日
Hi I have a 495x4 matrix. In column 1 are datenum values, column 2,3 and 4 contain data. I want to plot the data from all 3 columns on one plot. The data from column 2 and 3 should be for the y-axis on the left and the data from column 4 for the y-axis on the right. I should therefore have 3 lines on the plot.
I know it is possible to plot 2 lines with plotyy. How would I plot 3 lines ? Is it possible to do this a different way ?
I am using MATLAB 2011b
  4 件のコメント
Adam
Adam 2017 年 6 月 1 日
You can add two lines on a single axes easily enough using
doc hold
whether or not you have another line on a different axes that happens to be in the same location.
Doing it yourself the more difficult part is just dealing with getting the axis ticks on the right side and not having both grids on at the same time etc.
dpb
dpb 2017 年 6 月 1 日
編集済み: dpb 2017 年 6 月 1 日
Use plotyy, the pre-HG2 yyaxis

サインインしてコメントする。

採用された回答

dpb
dpb 2017 年 6 月 1 日
"column 1 are datenum values, ... column 2 and 3 ... on the left and ... column 4 on the right"
Nothing to it... :)
[hAx,hL1,hL2]=plotyy(data(:,1),data(:,2:3),data(:,1),data(:,4));
set(hAx(2),'xtick','[]) % just don't show but one x axis ticks, etc., ...
linkaxes(hAx,'x') % and link the two so stay in synch on limits, etc., ...
datetick(hAx,'x','keeplimits') % and turn to date format
May need to change format and number ticks, etc., to match the data but that's the starting point

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by