How to use "hold on" for multiple datasets on the same graph?

4 ビュー (過去 30 日間)
Mohsen
Mohsen 2014 年 4 月 21 日
回答済み: Mohsen 2014 年 4 月 22 日
Hi,
I am trying to plot 5 different datasets for 3 patients (15 lines in total) on the same graph. The Y value for each line is between 0 and 100 but the X axis is different for each line.
The problem is that the "hold on" function is not working. I think the reason is that I am using different x axis values for each data set.
The output of my code is just the graph of the 5 rois for the last patient (patient_Plan3).
Any ideas how to fix this?
Here is my code:
Note: DVHxAccum and DVHyAccum are 5x1 cells each containing the data that I want to plot.
patient_Plan1='path1';
patient_Plan2='path2';
patient_Plan3='path3';
patient_PlanNames={patient_Plan1, patient_Plan2, patient_Plan3};
totPatient_PlanNum=length(patient_PlanNames);
figure;
hold on;
roiName = { 'Contralateral_Lung', 'rPTV', 'nonGTVLUNG', 'CTV', 'Ipsilateral_Lung'};
axis([0 7500 0 110]);
markers = {'-','.','--'};
Color={'c','m','b','r','g', 'k'};
for j=totPatient_PlanNum
planDir = strcat('O:\WorkstationDB\',patient_PlanNames{j});
[DVHxAccum DVHyAccum] = getDVHAccum(planDir, roiName);
for i = 1:length(roiName)
plot(DVHxAccum{i}, DVHyAccum{i}, [markers{j} Color{i}],'LineWidth',1);
end
end

採用された回答

Mohsen
Mohsen 2014 年 4 月 22 日
I found it:
for j=totPatient_PlanNum
should be changed to
for j=1:totPatient_PlanNum

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 4 月 21 日
The "hold" applies to a specific axes control, and you don't have one yet. You're calling hold on before there's even any axes to hold. Try calling it after you call plot for the first time.
if i == 1
hold on;
end
  4 件のコメント
Mohsen
Mohsen 2014 年 4 月 22 日
編集済み: Mohsen 2014 年 4 月 22 日
Thank you for the offer but I am using patient data that I am not allowed to share due to privacy policies. Sorry about that!
Image Analyst
Image Analyst 2014 年 4 月 22 日
You can make up some data then, just have it be in the same format.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by