필터 지우기
필터 지우기

How to make equally spaced symbols on a line plot

조회 수: 5 (최근 30일)
Em
Em 2023년 7월 24일
편집: Voss 2023년 7월 24일
I have a line plot (created from an array with many many points) and I want to use symbols rather than colours to indicate the different data. Does anyone know how to do this?
I know you can't simply add 'o' at the end because this gives error message 'The end operator must be used within an array index expression'
Cheers!
  댓글 수: 2
Voss
Voss 2023년 7월 24일
Can you post the plotting code you have so far?
Em
Em 2023년 7월 24일
The below line works just fine
plot(var1(end-1000:end,1)*10^-6, var1(end-1000:end,3)*10^9)
I want to plot it with symbols e.g.
plot(var1(end-1000:end,1)*10^-6, var1(end-1000:end,3)*10^9, 'o')

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

답변 (1개)

Voss
Voss 2023년 7월 24일
Do you want something like this?
x = 1:100;
y = sin(x/10);
plot(x,y) % the whole line
hold on
plot(x(1:10:end),y(1:10:end),'bo') % markers every so often
  댓글 수: 4
Em
Em 2023년 7월 24일
You're right, I didn't have the right .mat file loaded! Sorry to you or to anyone else who is viewing this - I edited my reply before I saw that you had replied.
I'm getting another error message when I include the ':10:' part of my code. Do you have any idea why this might be?
Cheers.
Voss
Voss 2023년 7월 24일
편집: Voss 2023년 7월 24일
Instead of this:
plot(s9a(end-1000:10:end,1)*10^-6, s9a(end-1000:10:end,3)*10^9,'Color',c(5,:), 'o')
Do this:
plot(s9a(end-1000:10:end,1)*10^-6, s9a(end-1000:10:end,3)*10^9,'o','Color',c(5,:))
Property/Value pairs, like 'Color',c(5,:), must come at the end of the list of arguments to plot.

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

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by