Hello everybody,
I haven't figured out yet how can I plot discrete values along the x-axis. I need to plot for instance:
y= [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 13일
편집: Ameer Hamza 2020년 10월 13일

0 개 추천

Try this
y = [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];
ax = axes();
plot(y, 'r+', 'MarkerSize', 10, 'LineWidth', 2)
ax.XTickLabel = string(x);

댓글 수: 8

Thank you so much Ameer.
Just one other thing: let's assume that I have 10000 points along the x-axis, and most of them are "89". Is it possible to display just a small amount of such a digit instead of displaying all of them?
Ameer Hamza
Ameer Hamza 2020년 10월 13일
Yes, but you need to describe which one to select? Or do you want them to be selected randomly?
I would like to display all the values that appear once along the x-axis.
Ameer Hamza
Ameer Hamza 2020년 10월 13일
So you want to display just one point for all repeating values. For example, just one "89" on x-axis? What about y-value?
yes, i do.
As far as the y-values are concerned, i would like to display all of them
Run the following code. Is this what you want?
y = [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];
plot(x, y, 'r+', 'LineWidth', 2, 'MarkerSize', 10)
Nope, it was just an example. I am dealing with vectors much bigger than these.
Ameer Hamza
Ameer Hamza 2020년 10월 13일
But the same method will apply there.

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

추가 답변 (0개)

카테고리

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

질문:

2020년 10월 13일

댓글:

2020년 10월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by