Plotting line with marker

1 view (last 30 days)
AAaaAA
AAaaAA on 7 Dec 2013
Edited: Ali on 29 Oct 2017
I have a data (X,Y) of 1000 points. i have to create a line plot with markers from this data. but the problem is that it creates markers for each point. i want to have less number of marker like 10 on the line. If anyone know how to do this. Thanks in advance
  1 Comment
Ali
Ali on 29 Oct 2017
Edited: Ali on 29 Oct 2017
if true
--------------------------------------------------- code start
This is an example for your case
Input is "Input_Data", two dimension matrix
Marker_Counter=1;
figure6=figure;
Markers = {'+','o','*','x','v','d','^','s','>','<'};
for i=1:10:size(Input_Data,1)
TPR=Input_Data(i:i+9,7);
FPR=Input_Data(i:i+9,8);
plot(FPR,TPR,strcat('-',Markers{Marker_Counter}));
Marker_Counter=Marker_Counter+1;
hold on
end
plot([0.5 1],[0.5 1],'--');
legend('Minpts = 100','Minpts = 200','Minpts = 300','Minpts = 400','Minpts = 500','Minpts = 600','Minpts = 700','Minpts = 800','Minpts = 900','Minpts = 1000','','Location','SouthEast');
xlabel('FPR or (1-Specificity)','FontSize',12,'FontWeight','bold'); ylabel('TPR or Spensitivity)','FontSize',12,'FontWeight','bold');
title('ROC Space');
close(gcf);
-------------------------------------------- code end
end
--------------------------------------- picture link preview

Sign in to comment.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 7 Dec 2013
Edited: Azzi Abdelmalek on 7 Dec 2013
Example
x=0:999;
y=sin(0.01*x);
plot(x,y)
hold on
scatter(x(1:10:end),y(1:10:end),'r')
hold off
  2 Comments
AAaaAA
AAaaAA on 7 Dec 2013
hi azzi, thanks for your help. but in this case we will have 2 different legends instead of a single line with a marker. also when i have to plot 2 or more lines in the same figure, the number of legend entities will be 2 folds. do you know how can this be managed.
Azzi Abdelmalek
Azzi Abdelmalek on 7 Dec 2013
You can add scatter after legend
x=0:999;
y=sin(0.01*x);
plot(x,y)
legend('legend1')
hold on
scatter(x(1:10:end),y(1:10:end),'r')
hold off

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!