Effacer les filtres
Effacer les filtres

plotting same values as individual points on x-axis

5 vues (au cours des 30 derniers jours)
Sumera Yamin
Sumera Yamin le 9 Nov 2023
Commenté : Sumera Yamin le 10 Nov 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 commentaires
Dyuman Joshi
Dyuman Joshi le 9 Nov 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 le 9 Nov 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.

Connectez-vous pour commenter.

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 9 Nov 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 commentaire
Sumera Yamin
Sumera Yamin le 10 Nov 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)?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots 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!

Translated by