how to plot more than 2 data sets onto one figure with two y-axes and one x-axis, with multiple datasets plotted with respect to the second y-axes and multiple datasets with respect to the first y-axis

조회 수: 9 (최근 30일)
Hello,
I'm trying to plot multiple lines (total of 12 data sets) onto one Figure with two y-axes and one x-axis. So far, I have multiple lines onto one Figure, but with one y-axis and one x-axis as shown below. I would like the group of lines at the bottom of the plot (total of 6 data sets) to be plotted (in scale with) or with respect to the second y-axis (not shown in image).
The farthest I've gotten was using the plotyy function, and having one data set plotted in scale with (or with respect to) the second y-axis, but the rest of the lines (11 data sets) plotted in scale with (or with respect to) the first y-axis...does that make sense? Any help would be greatly appreciated.
I initially imported a .txt data file and filtered the data to op_data and non_op_data if you're wondering. I'm using MATLAB R2015a btw. I hope this makes enough sense.
Thanks
RPM = TestCase1.data(:,2);
[row] = find(RPM > 150);
[row_non_op] = find(RPM <= 150); %non_op_row
op_data = TestCase1.data(row,:); %op_data
non_op_data = TestCase1.data(row_non_op,:); %non_op_data
d = TestCase1.textdata(2:end,1); %textdata of timestamp
date = datetime(d,'InputFormat','M/d/y h:mm:ss a'); %Converting textdata into a datetime array
op_date = date(row,1); %op_date
non_op_date = date(row_non_op,1); %non_op_date
non_op_data(:,4:9) = NaN;
if num_cyl == 6
PP_CYL_op = op_data(:,4:9);
SDoPP_CYL_op = op_data(:,10:15);
figure (); hold on
for i = 1:num_cyl
plot(op_date,PP_CYL_op(:,i))
end
hold on
for i = 1:num_cyl
plot(op_date,SDoPP_CYL_op(:,i))
end
end

채택된 답변

Star Strider
Star Strider 2015년 7월 21일
In the plotyy documentation, see: Use Right y-Axis for Two Data Sets. That may be what you want.
  댓글 수: 5

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by