Formatting the x-axis of a scatter plot

조회 수: 40(최근 30일)
Bill Symolon
Bill Symolon 2017년 2월 11일
답변: Chad Greene 2017년 2월 12일
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

채택된 답변

Chad Greene
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by