plotting same values as individual points on x-axis

6 Ansichten (letzte 30 Tage)
Sumera Yamin
Sumera Yamin am 9 Nov. 2023
Kommentiert: Sumera Yamin am 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 Kommentare
Dyuman Joshi
Dyuman Joshi am 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 am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 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 Kommentar
Sumera Yamin
Sumera Yamin am 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)?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by