Phlox Midas
Phlox Midas

Reputation: 4347

How can I have more than 10 marker types in a scatter plot?

The documentation specifies only 10 types of markers in a scatter plot: http://uk.mathworks.com/help/matlab/ref/scatter.html

I need 30. My current string for marker types is:

markers = '+o*.xsd^v<>h';

I don't want to reuse the same markers. Entering other letters etc. results in a crash. Letters of the alphabet would be acceptable markers. Is there a way to have more than 10 types of markers?

Edit: I'm already using colors to indicate something else.

Upvotes: 2

Views: 1028

Answers (2)

marsei
marsei

Reputation: 7751

Several function can be used to emulate the behaviour of scatter. Here we use both text and plot to create unique markers.

On the left, markers with numbers and dots, on the right circle and arrows (thanks to unicode).

enter image description here

Computation:

N = 50;
x = rand(N,1);
y = rand(N,1);

%numbers in text
txt1 = cellstr(num2str((11:11+N-1)'));

%unicode text
Nstart = 8592; %arrows 
txt2 = cellstr(char(Nstart:Nstart+N-1)');

figure;
subplot(1,2,1);
h = text(x, y, txt1, ...
    'FontName', 'Courier New', 'FontSize', 18, ...
    'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');

hold on;
plot(x, y, 'r.', 'MarkerSize', 10)

subplot(1,2,2);
h = text(x, y, txt2, ...
    'FontSize', 20, ...
    'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');

hold on;
plot(x, y, 'o', 'MarkerSize', 22)

Upvotes: 2

user664303
user664303

Reputation: 2063

You can use text to plot letters at particular locations. It will be much less efficient because each point will require a new graphics object.

Upvotes: 1

Related Questions