![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195980/image.png)
Recreate plot from image
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Cliff Karlsson
le 18 Sep 2018
Réponse apportée : Nicole Peltier
le 18 Sep 2018
How can I recreate the plot in the picture? I just want to understand how to add multiple axes and how to scale every axis to different values.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196087/image.png)
I have created this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196088/image.png)
clear
load carbig.mat
colors = [[0 0 0]; [0 0 0]; [1 0 0]; [0 1 0]; [1 0.5 0]; [1 0 1]; [0 0 0]; [0 0 1]];
data = [MPG Horsepower Weight Acceleration Displacement Cylinders*500];
labels = {'MPG', 'Horsepower', 'Weight', 'Acceleration', 'Displacement', 'Cylinders'};
lineobjects = parallelcoords(data, 'Labels',labels)
for i=1:length(lineobjects)
lineobjects(i).Color = colors((lineobjects(i).YData(6)/500),:)
%lineobjects(i).Color(4) = .15;
end
0 commentaires
Réponse acceptée
Nicole Peltier
le 18 Sep 2018
You need to scale each parameter (MPG, Horsepower, etc.) by the maximum value of each parameter. I used repmat in my code so that the scaling could be done in a single line instead of a for-loop.
% Find maximum value for each variable
% Use repmat to allow for vectorization (faster computation)
column_max = repmat(max(data), size(data, 1), 1);
% Scale data so that max value for each variable = 1
data_scaled = data./column_max;
h = figure();
set(h,'DefaultAxesColorOrder',[1 0 0; 0 1 0; 1 1 0; 1 0 1; 0 0 1]);
lineobjects = parallelcoords(data_scaled,'Group',Cylinders,'Labels',labels);
The code above will produce the following figure (not an exact replica of the figure you sent, but you can mess around with annotations and axis labels):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195980/image.png)
Hope this helps!
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Printing and Saving 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!