Borrar filtros
Borrar filtros

plotting same values as individual points on x-axis

5 visualizaciones (últimos 30 días)
Sumera Yamin
Sumera Yamin el 9 de Nov. de 2023
Comentada: Sumera Yamin el 10 de Nov. de 2023
Hello, I want to plot a data in which x coordinate has multiple point waith same values and i want to keep those values as individual points. What will be the best way to do so. for example I have data in the following format in which x-coordiate values are repeated as a series but i want to keep them as individual points and not have just five points in x-coordinate. many thanks.
x=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
y=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
  2 comentarios
Dyuman Joshi
Dyuman Joshi el 9 de Nov. de 2023
It's not clear to me what exactly you want to obtain. What should be the output for the given data?
"but i want to keep them as individual points and not have just five points in x-coordinate."
Could you elaborate on this?
Sumera Yamin
Sumera Yamin el 9 de Nov. de 2023
yes, i want to plot from 1-5 on x-axis not just one time but three times as they appear in the data. If i use simple plot, it will have fivr points on x-axis and not a series.

Iniciar sesión para comentar.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 9 de Nov. de 2023
x=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5];
y=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
vec = 1:numel(y);
scatter(vec,y)
xticks(vec)
xticklabels(string(x))
  1 comentario
Sumera Yamin
Sumera Yamin el 10 de Nov. de 2023
Many thanks. This is precisely what i wanted but I have one question. in command line "vec = 1:numel(y);", you made variable vec with the values in y and plotted scatter between vec and y, where does values of x comes from in this code? Should the scatter be between (x,y) instead of (vec,y)?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by