group objects of a multiple line plot
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm plotting multiple lines into figure, which I generated out of table. Now I want to group the lines into the a certain number of groups (f.e.: 5), the groups are defined by string in one column of my table. I checked the documentation and tried it with the hggroup and the findobj, since they looked helpful, but couldn't get it done. Any ideas/suggestions how to solve this? If more information is needed oder sth isn't clear please comment. Thanks
1 commentaire
Morteza Hajitabar Firuzjaei
le 25 Jan 2018
Dear Philip,
check it out:
Plot Data by Group
Load the sample data.
load fisheriris The column vector species consists of iris flowers of three different species: setosa, versicolor, and virginica. The double matrix meas consists of four types of measurements on the flowers: the length and width of sepals and petals in centimeters, respectively.
Store the data in a table array.
t = table(species,meas(:,1),meas(:,2),meas(:,3),meas(:,4),... 'VariableNames',{'species','meas1','meas2','meas3','meas4'});
Meas = dataset([1 2 3 4]','VarNames',{'Measurements'});
Fit a repeated measures model, where the measurements are the responses and the species is the predictor variable.
rm = fitrm(t,'meas1-meas4~species','WithinDesign',Meas);
Plot data grouped by the factor species.
plot(rm,'group','species')
Change the line style for each group.
plot(rm,'group','species','LineStyle',{'-','--',':'})
Plot Data Grouped by Two Factors Load the sample data.
load repeatedmeas The table between includes the between-subject variables age, IQ, group, gender, and eight repeated measures y1 through y8 as responses. The table within includes the within-subject variables w1 and w2. This is simulated data.
Fit a repeated measures model, where the repeated measures y1 through y8 are the responses, and age, IQ, group, gender, and the group-gender interaction are the predictor variables. Also specify the within-subject design matrix.
rm = fitrm(between,'y1-y8 ~ Group*Gender + Age + IQ','WithinDesign',within);
Plot data with Group coded by color and Gender coded by line type.
plot(R,'group',{'Group' 'Gender'},'Color','rrbbgg',... 'LineStyle',{'-' ':' '-' ':' '-' ':'},'Marker','.')
Morteza Hajitabar Firuzjaei
Réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!