![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287154/image.png)
How Can I plot data 1 dimension
52 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
If I have dataset
x=[0
0
0
0
0
0
-0.0488497231243238
0.179582426641752
0.417286015074303
0.26880559803247
-0.334079911686008];
and I have class label
y=[1
1
1
1
1
1
2
2
2
2
2];
How can I plot 1-dimensional data (1 column) showing 2-dimensional results with differecne class label? If not, Please suggest me, how to show the 1 dimensional data in difference class label graphic.
Thank you so much
0 commentaires
Réponses (2)
Selene Schmittling
le 24 Avr 2020
Here's an alternative way:
% for clarity change x -> data
data=[0 0 0 0 0 0 -0.0488497231243238 0.179582426641752 ...
0.417286015074303 0.26880559803247 -0.334079911686008];
% for clarity change y -> labels
labels=[1 1 1 1 1 1 2 2 2 2 2];
% define values for y-axis
y=zeros(length(data),1);
% create plot
gscatter(data, y, labels, 'br', '.',18);
axis([min(data)-.1 max(data)+.1 -.05 .1])
yticks(0)
title('1-D Plot by Class','FontSize',18)
Here is what this looks like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287154/image.png)
0 commentaires
KALYAN ACHARJYA
le 3 Juil 2019
Modifié(e) : KALYAN ACHARJYA
le 3 Juil 2019
plot(y,x)
bar or stem(y,x)
0 commentaires
Voir également
Catégories
En savoir plus sur Axis Labels 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!