PROBLEM WITH COLOR OF FIGURE BAR
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
%% metriche laboratorio
Loudlab=[10.6752052307128;12.2898445129394;9.16325187683105;10.9350090026855;10.1481266021729;10.9281921386718;10.8816394805908;11.7297935485839;9.63866138458251;12.0087442398071;9.41653823852539;10.4343605041504];
Tonalab=[0.0690339505672455;0.0244497414678335;0.0305882636457682;0.0260471943765879;0.0279080551117659;0.0396407432854176;0.0403248146176338;0.0254815556108952;0.0341337099671364;0.0378330945968628;0.0271299816668034;0.0310444794595242];
AIlab=[78.9146499633789;70.8039169311523;88.3067626953125;79.2312164306641;80.2309112548828;79.7658157348633;78.3505172729492;73.9234085083008;84.7919540405273;74.9574432373047;82.9901885986328;79.8215179443359];
FSlab=[0.530194699764251;0.557793736457825;0.528763532638550;0.584599733352661;0.565194010734558;0.646276235580444;0.554185092449188;0.523809432983398;0.541217684745789;0.590922117233276;0.558875620365143;0.543300807476044];
Rouglab=[1.46115398406982;1.55721104145050;1.58549165725708;1.62256991863251;1.48214972019196;1.54145348072052;1.43744456768036;1.65032434463501;1.49096822738647;1.56999623775482;1.45412456989288;1.41422545909882];
Sharlab=[1.61403262615203;1.87424206733703;1.39137363433838;1.56248259544373;1.66666138172150;1.56194067001343;1.57899546623230;1.57822525501251;1.66364777088165;1.49948608875275;1.73343360424042;1.62698912620544];
PRlab=[1.75240993499755;1.51596403121948;1.55046761035919;1.76663684844971;1.73564827442169;2.21682429313660;1.85651099681854;1.57139372825623;1.48717284202576;1.54619419574738;1.52235949039459;1.55247700214386];
TTNRlab=[1.37997114658355;1.14940845966339;1.15955698490143;0.985778152942658;1.44753086566925;2.07293677330017;0.800401806831360;1.20492744445801;1.24004328250885;1.29924595355988;1.17564463615417;1.12209963798523];
Metrlab=[Loudlab,Tonalab,AIlab,FSlab,Rouglab,Sharlab,PRlab,TTNRlab];
subjrum=[-0.0300000000000000;-0.550000000000000;0.610000000000000;-0.420000000000000;0.360000000000000;-0.360000000000000;-0.330000000000000;-0.270000000000000;0.240000000000000;-0.300000000000000;0.270000000000000;0.0300000000000000];
K=size(Metrlab,2);
label={'Loudlab','Tonalab','AIlab','FSlab','Rouglab','Sharlab','PRlab','TTNRlab'};
%% result of simple regression (subjrum)
Rrum = zeros(1,K);
coeffrum = zeros(2,K);
for jj=1:K
p=polyfitn(Metrlab(:,jj),subjrum,1);
Rrum(jj)=p.R2;
coeffrum(:,jj)=p.Coefficients;
end
%% result of multiple regression 2 (subjrum)
pl2rum = nchoosek(1:K,2);
CM2rum = size(pl2rum,1);
R2rum = zeros(1,CM2rum);
coeff2rum = zeros(3,CM2rum);
label2 = cell(1,CM2rum);
for ii = 1:CM2rum
p = polyfitn(Metrlab(:,pl2rum(ii,:)),subjrum,1);
R2rum(ii)=p.R2;
coeff2rum(:,ii)=p.Coefficients;
label2{ii} = [label{pl2rum(ii,1)},' - ',label{pl2rum(ii,2)}];
end
%% result of multiple regression 3 (subjrum)
pl3rum = nchoosek(1:K,3);
CM3rum = size(pl3rum,1);
R3rum = zeros(1,CM3rum);
coeff3rum = zeros(4,CM3rum);
for ii = 1:CM3rum
p = polyfitn(Metrlab(:,pl3rum(ii,:)),subjrum,1);
R3rum(ii)=p.R2;
coeff3rum(:,ii)=p.Coefficients;
label3{ii} = [label{pl3rum(ii,1)},' - ',label{pl3rum(ii,2)},' - ',label{pl3rum(ii,3)}];
end
%% result of multiple regression 4 (subjrum)
pl4rum = nchoosek(1:K,4);
CM4rum = size(pl4rum,1);
R4rum = zeros(1,CM4rum);
coeff4rum = zeros(5,CM4rum);
for ii = 1:CM4rum
p = polyfitn(Metrlab(:,pl4rum(ii,:)),subjrum,1);
R4rum(ii)=p.R2;
coeff4rum(:,ii)=p.Coefficients;
label4{ii} = [label{pl4rum(ii,1)},' - ',label{pl4rum(ii,2)},' - ',label{pl4rum(ii,3)},' _ ',label{pl4rum(ii,4)}];
end
%% result of multiple regression 5 (subjrum)
pl5rum = nchoosek(1:K,5);
CM5rum = size(pl5rum,1);
R5rum = zeros(1,CM5rum);
coeff5rum = zeros(6,CM5rum);
for ii = 1:CM5rum
p = polyfitn(Metrlab(:,pl5rum(ii,:)),subjrum,1);
R5rum(ii)=p.R2;
coeff5rum(:,ii)=p.Coefficients;
label5{ii} = [label{pl5rum(ii,1)},' - ',label{pl5rum(ii,2)},' - ',label{pl5rum(ii,3)},' _ ',label{pl5rum(ii,4)},' _ ',label{pl5rum(ii,5)}];
end
%% result of multiple regression 6 (subjrum)
pl6rum = nchoosek(1:K,6);
CM6rum = size(pl6rum,1);
R6rum = zeros(1,CM6rum);
coeff6rum = zeros(7,CM6rum);
for ii = 1:CM6rum
p = polyfitn(Metrlab(:,pl6rum(ii,:)),subjrum,1);
R6rum(ii)=p.R2;
coeff6rum(:,ii)=p.Coefficients;
label6{ii} = [label{pl6rum(ii,1)},' - ',label{pl6rum(ii,2)},' - ',label{pl6rum(ii,3)},' _ ',label{pl6rum(ii,4)},' _ ',label{pl6rum(ii,5)},' _ ',label{pl6rum(ii,6)}];
end
%% result of multiple regression 7 (subjrum)
pl7rum = nchoosek(1:K,7);
CM7rum = size(pl7rum,1);
R7rum = zeros(1,CM7rum);
coeff7rum = zeros(8,CM7rum);
for ii = 1:CM7rum
p = polyfitn(Metrlab(:,pl7rum(ii,:)),subjrum,1);
R7rum(ii)=p.R2;
coeff7rum(:,ii)=p.Coefficients;
label7{ii} = [label{pl7rum(ii,1)},' - ',label{pl7rum(ii,2)},' - ',label{pl7rum(ii,3)},' _ ',label{pl7rum(ii,4)},' _ ',label{pl7rum(ii,5)},' _ ',label{pl7rum(ii,6)},' _ ',label{pl7rum(ii,7)}];
end
%% result of multiple regression 8 (subjrum)
pl8rum = nchoosek(1:K,8);
CM8rum = size(pl8rum,1);
R8rum = zeros(1,CM8rum);
coeff8rum = zeros(9,CM8rum);
for ii = 1:CM8rum
p = polyfitn(Metrlab(:,pl8rum(ii,:)),subjrum,1);
R8rum(ii)=p.R2;
coeff8rum(:,ii)=p.Coefficients;
label8{ii} = [label{pl8rum(ii,1)},' - ',label{pl8rum(ii,2)},' - ',label{pl8rum(ii,3)},' _ ',label{pl8rum(ii,4)},' _ ',label{pl8rum(ii,5)},' _ ',label{pl8rum(ii,6)},' _ ',label{pl8rum(ii,7)},' _ ',label{pl8rum(ii,8)}];
end
%% GRAPHIC
R_all = [Rrum R2rum R3rum R4rum R5rum R6rum R7rum R8rum];
label_all = [label,label2,label3,label4,label5,label6,label7,label8];
label_all = strrep(label_all,'lab','');
[R_all_sort,ind_sort] = sort(R_all,'descend');
label_all_sort = label_all(ind_sort);
threshold = 0.9;
logical_index = R_all_sort>=threshold;
N_true = length(find(logical_index));
figure
zall1=bar(R_all_sort(logical_index));
hold on
grid on
xlabel('metriche cappa');
ylabel('R^2 cappa ');
ax=gca;
ax.XTick = 1:N_true;
ax.XTickLabels = label_all_sort(logical_index);
ax.XTickLabelRotation = 90;
legend({'soggettività:più rumoroso-meno rumoroso' });
ylim([threshold 1]);
hi i have a problem with the graphic, i need to have different color for every differet vector in the code of bar graphic that i wrote.
the color are:
R_all=[Rrum=red,R2rum=yellow,R3rum=black,R4rum=green,R5rum=blue,R6rum=cyan,R7rum=magenta,R8rum=white]
0 Commenti
Risposte (1)
Subhadeep Koley
il 29 Ott 2019
Hi, it seems that you are trying to get different color for every different vector (e.g., Rrum=red, R2rum=yellow, R3rum=black, etc.) in a bar graph.
I have made some changes in your code to make it display different color for different vector. (Refer the attached script)
0 Commenti
Vedere anche
Categorie
Scopri di più su Graphics Object Programming 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!