How do I use custom markers for a line object in a MATLAB plot?

12 views (last 30 days)
The line object allows a limited subset of markers using the 'Marker' property. I would like to define a custom marker.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 23 Sep 2009
The ability to use custom markers for line objects is not available in MATLAB.
To work around this issue, you can find a font that has a character similar to your desired marker. Then you can use the TEXT command to create text objects at the desired marker locations. This is very similar to using the PLOT command. For example:
% Define the font and desired character
font = 'Wingdings';
m = 'J';
% Make some arbitrary data
x = 0:.5:2*pi;
y = sin(x);
% Use TEXT to plot the character along the data
text(x,y,m,'fontname',font,'color','red')
% Manually set axis limits, since TEXT does not do this for you
xlim([min(x) max(x)])
ylim([min(y) max(y)])
For more ideas on character symbols you can use, see the Related Solution.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!