how to turn "points" in scatter diagram into "lines"
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (1)
Robert
el 18 de Ag. de 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 comentarios
Yeping Sun
el 18 de Ag. de 2016
Robert
el 18 de Ag. de 2016
You could leave them as integers and adjust the x axis tick labels after plotting.
Categorías
Más información sobre Scatter Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
