Formatting the x-axis of a scatter plot
6 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to plot the following matrix, where the first column is the ambient temperature (x-axis) and the second column is whether or not damage was observed (1 for yes and 0 for no). The plot command I'm using doesn't format the x-axis properly. I need the x-axis to be between 50 and 90 degrees F with corresponding y-axis points either at 0 or 1 for a given temperature. I appreciate your help.
if true
historicalDamage = [66 0; 70 1; 69 0; 68 0; 67 0; 72 0; 73 0; 70 0; 57 1;
63 1; 70 1; 78 0; 67 0; 53 1; 67 0; 75 0; 70 0; 81 0; 76 0;
79 0; 75 1; 76 0; 58 1];
% Plot historical data
figure
plot(historicalDamage(:,2), '*')
title('Historical Data')
xlabel('Ambient Temperature (F)')
ylabel('Damage Observed (Yes/No)')
end
0 件のコメント
採用された回答
Chad Greene
2017 年 2 月 12 日
Indeed, the x values were left out, so it was plotting you ones and zeros on an x scale of 1 to 23, because you have 23 data points. I think you want this:
plot(historicalDamage(:,1),historicalDamage(:,2), '*')
And you said you want an x range of 50 to 90, so
xlim([50 90])
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!