Formatting the x-axis of a scatter plot

8 次查看(过去 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

采纳的回答

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 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by