Controlling the spacing between markers in a plot in a figure

조회 수: 74 (최근 30일)
Sam Alex
Sam Alex 2012년 12월 24일
답변: Jacob Jonsson 2018년 5월 22일
How do I control the spaces between markers in a plot so that it although I am plotting say a 100,000 points but it shows markers at only sample points, and does not show markers when the plot drops between two points:
A sample is shown in figure below:
Thanks

채택된 답변

Image Analyst
Image Analyst 2012년 12월 24일
I'm not sure why my answer to your duplicate question at http://www.mathworks.com/matlabcentral/answers/57241#answer_69235 didn't work for you. Walter and I are both saying the same thing: plot a subset of your data:
plot(allYourData, 'r-');
hold on;
plot(allYourData(1:10:end), 'bo'); % Or can use scatter.
or something like that. You can pick them at random, or pick every 10th one like I did above or some other subsampling period.
  댓글 수: 4
Image Analyst
Image Analyst 2012년 12월 25일
They don't get mixed up. How could that happen? It doesn't. You can go ahead and plot on a loglog, semilogx or semilogy and they won't change order. Everything is exactly where it should be. If you say they are not, then post code and a screenshot to prove it.
Sam Alex
Sam Alex 2012년 12월 25일
You are right...I just got my brain mixed up...lots of figures :(
Thanks man...your expertise is wonderful :)
Thanks for helping me...I appreciate it..

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

추가 답변 (2개)

Walter Roberson
Walter Roberson 2012년 12월 24일
plot() once without any markers on the line. Then scatter() the desired markers into place.
  댓글 수: 4
Sam Alex
Sam Alex 2012년 12월 24일
it goes from 0-100,000?
Walter Roberson
Walter Roberson 2012년 12월 24일
Yes, remember that plot(x,y) places the points at the given x locations. For example,
x = 0:1000:100000;
y = x.^2;
plot(x,y);
That will have an x axis from 0 to 100000 even though only 100 points are plotted.

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


Jacob Jonsson
Jacob Jonsson 2018년 5월 22일
I wrote a function available at: https://www.mathworks.com/matlabcentral/fileexchange/37165-plotsparsemarkers Should work with MATLAB versions that have 'MarkerIndices' as well as the older ones.

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by