My histogram color is different everytime I run the program and the legend colors don't match.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Every time I run the program my figure 7 histogram comes back with different colors and the Florida legend is correct but the Minnesota color in not. I can't figure out what is wrong with the program. I have also posted a picture of what my graphs come out like.
T = readtable('Numerical Methods EGM 3344 Speeds.xlsx');
F70 = T (1:100,1);
F65 = T (1:100,2);
F55 = T (1:100,3);
M70 = T (1:100,4);
M65 = T (1:100,5);
M55 = T (1:100,6);
figure(1);
histogram(F70.F70);
histogram(F70.F70,65:1:90)
histogram(F70.F70,'BinWidth',.5)
histogram(F70.F70, 'FaceColor', [0 0 0])
set(gca, 'XTick', 65:1:90)
title('Speeds Recorded from Florida Interstate 10 Speed Limit 70 MPH')
xlabel('Speeds Recorded')
ylabel('Amount of Each Speed')
figure(4);
histogram(M70.M70);
histogram(M70.M70,68:1:83)
histogram(M70.M70,'BinWidth',.5)
histogram(M70.M70, 'FaceColor', [1 0 0])
set(gca, 'XTick', 68:1:83)
title('Speeds Recorded from Minnesota Interstate 35 Speed Limit 70 MPH')
xlabel('Speeds Recorded')
ylabel('Amount of Each Speed')
figure(7);
histogram(F70.F70);
histogram(F70.F70, 'FaceColor', [0 0 0])
set(gca, 'XTick', 65:1:90)
hold on
histogram(M70.M70);
histogram(M70.M70, 'FaceColor', [1 0 0])
title('Comparison for the 70 MPH Speed Limit Zones')
xlabel('Speeds Recorded')
ylabel('Amount of Each Speed')
legend('Florida','Minnesota')
0 Commenti
Risposte (1)
Chidvi Modala
il 10 Ott 2019
Hello Chase Viche,
From my understanding, you are trying to plot two histograms on the same figure. But histogram is coming back with different colors. It is because you are plotting each histogram twice as shown by the commented code below
figure(7);
% histogram(M70.M70);
% histogram(M70.M70, 'FaceColor', [1 0 0])
set(gca, 'XTick', 65:1:90)
hold on
% histogram(M70.M70);
% histogram(M70.M70, 'FaceColor', [1 0 0])
title('Comparison for the 70 MPH Speed Limit Zones')
xlabel('Speeds Recorded')
ylabel('Amount of Each Speed')
legend('Florida','Minnesota')
Try replacing the above code with the below one
figure(7);
histogram(F70.F70, 'FaceColor', [0 0 0])
set(gca, 'XTick', 65:1:90)
hold on
histogram(M70.M70, 'FaceColor', [1 0 0])
title('Comparison for the 70 MPH Speed Limit Zones')
xlabel('Speeds Recorded')
ylabel('Amount of Each Speed')
legend('Florida','Minnesota')
Vedere anche
Categorie
Scopri di più su Histograms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!