How do I change the marker size for a plot?
Afficher commentaires plus anciens
Im trying to set the marker size on a plot but having no luck, heres my code this works fine plot( x , x^2,'-k*',... x , x^3,'-ko',... x , x^4,'-k' ) but when i try and set marker size it does not plot( x , x^2,'-k*',... x , x^3,'-ko','MarkerSize',12,... x , x^4,'-k' ) what do I need to do?
1 commentaire
Evan
le 18 Jan 2023
type 'LineWidth' instead of 'MarkerSize'
Réponse acceptée
Plus de réponses (3)
Jan
le 30 Avr 2011
plot(x, x^2,'-k*');
hold('on');
plot(x, x^3,'-ko','MarkerSize', 12);
plot(x, x^4,'-k');
2 commentaires
Leo Simon
le 22 Mai 2014
For some obscure reason, MarkerSize is not consistently used. When you use scatter, you need to set 'SizeData' instead of 'MarkerSize'. Also, the scale of SizeData is different from that of MarkerSize' E.g.,
h = scatter(rand,rand,'b','filled'); set(h,'SizeData',96);
Michelle Hirsch
le 29 Jan 2016
The difference is subtle, but intentional. It stems from the different use cases.
MarkerSize is used to control the overall size of markers, just like the overall width of a line with LineWidth or font size. The units are in points, just like LineWidth.
Scatter is used to actually scale the marker sizes based on data. Specifically, the area of the marker is proportional to the value. This is why the units are in points squared.
Matt Fig
le 30 Avr 2011
1 vote
To make this type of thing much easier, you could download this code so that all these options are available from a simple mouse click:
3 commentaires
Oleg Komarov
le 30 Avr 2011
+1
Michelle Hirsch
le 29 Jan 2016
You can also enable a context menu for changing line and marker properties just by enabling plot edit mode. Click on the button in the Figure toolbar with an arrow on it, then right click on your line.
Frank Pierce
le 1 Sep 2016
yes
Hari Desanur
le 15 Nov 2016
The Marker Size property for a particular line can be set using line object handles. For example -
l = plot(x1,y1,'*-',x2,y2,'*-');
l(1).MarkerSize = 8; % set marker size of 8 for the first line (x1,y1)
l(2).MarkerSize = 12;
1 commentaire
P_L
le 18 Avr 2019
Hi there and what if you wanted to chnage the colours of 'ko' data points so that they are filled for example with 'b'
Many thanks
Catégories
En savoir plus sur Labels and Styling dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!