how to turn "points" in scatter diagram into "lines"
Afficher commentaires plus anciens
Dear all,
I have two sets of data for two clusters, respectively. These data sets (C_01.txt and C_02.txt) are attached. But define the first columns of these two data set as x1,x2,and the second columns as y1(all elements in y1 are 1),y2(all elements in y2 are 2),respectively, I can draw the attached figure by using
scatter(x1,y1); hold on; scatter(x2,y2);

However, I actually want a image like the following:

That is to say, I need to show each points in the scatter diagram as a vertical line with a certain hight.
Could that be possibly done in matlab?
Réponse acceptée
Plus de réponses (1)
Robert
le 18 Août 2016
You could display the data as an image. I see that your x values are all integers in your text files. If this will always be true, you can use them as indices of your array.
img = 0; % initialize with a zero
img(1,x2) = 2; % fill top row (will expand img as needed)
img(2,x1) = 1; % fill bottom row (will expand img as needed)
imagesc(img) % display matrix as image
colormap([1,1,1;0,0,1;1,0,0]) % color zeros white, ones blue, and twos red
2 commentaires
Yeping Sun
le 18 Août 2016
Robert
le 18 Août 2016
You could leave them as integers and adjust the x axis tick labels after plotting.
Catégories
En savoir plus sur Scatter Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
