plotting same values as individual points on x-axis

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

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?
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.

댓글을 달려면 로그인하십시오.

 채택된 답변

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

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)?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

2023년 11월 9일

댓글:

2023년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by