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!