Code covered by the BSD License  

Highlights from
Add plot markers to an existing plot

4.0

4.0 | 3 ratings Rate this file 18 Downloads (last 30 days) File Size: 1.94 KB File ID: #23279
image thumbnail

Add plot markers to an existing plot

by Matthijs

 

13 Mar 2009 (Updated 11 Aug 2009)

Add a specified number of markers to a plot

| Watch this File

File Information
Description

Add a specified number of markers to a plot instead of a marker at each datapoint which is the default in Matlab

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
01 Apr 2009 Carl Fischer

Useful but it seems you need to increase the number of markers by 2 to obtain the correct number.

13 Oct 2009 Carl Fischer

Thanks for the update. A couple of minor issues. The function won't cope with more than 13 plots, and also fails if called with N=1. There's not much you can do about this but a clear error message for these cases would be an improvement and would have saved me about 10 seconds :-)

12 Oct 2010 Carl Fischer

I'm surprised this hasn't got more good ratings and comments.
May I suggest you also copy the LineWidth and MarkerSize properties from the original plot to the markers. Currently you only copy the LineStyle and Color. Even if there are no markers in the original plot the MarkerSize property can still be set.

28 Mar 2011 E.

Yep, with some additional changes (such as Carl Fischer suggested) this is very useful code!

12 Jan 2012 Karl

I like this function but when I set(gca,'Xlim',[startnum endnum]) the plot extend outside of the box.

Please login to add a comment or rating.
Updates
20 Mar 2009

Number of makers is now optional with 5 markers being default.
The output handle is now also optional.

11 Aug 2009

- Output handle now retains the linestyle from the input handle - useful for the legends
- The markers are spaced randomly so that they don't obscure eachother.
- Markers are added to the correct subplot

Tag Activity for this File
Tag Applied By Date/Time
plot Matthijs 13 Mar 2009 13:44:15
article Matthijs 13 Mar 2009 13:44:15
bw Matthijs 13 Mar 2009 13:44:15
markers Matthijs 13 Mar 2009 13:44:15
markers Manuel 13 Oct 2011 02:24:14

Contact us at files@mathworks.com