Formatting the x-axis of a scatter plot

4 vues (au cours des 30 derniers jours)
Bill Symolon
Bill Symolon le 11 Fév 2017
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

Réponse acceptée

Chad Greene
Chad Greene le 12 Fév 2017
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])

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by