Johannes
Johannes

Reputation: 43

Default Property Values for Plots in MATLAB

I try to set default values to some properties I am using in my MATLAB script.
For example:

set(0,'defaultAxesMarkerSize', 3);

This doesnt work, because Axes doesnt have the property MarkerSize.
But how is it possible to set the default properties of all plots like:

stem(...);

Upvotes: 2

Views: 5065

Answers (1)

Benoit_11
Benoit_11

Reputation: 13945

When changing the default properties of graphics objects, the usual format is as follows:

1- default

2- type of object

3-property

4-value of that property.

Or as stated on the Mathworks website (see here):

'default' ObjectType PropertyName

Therefore, since MarkerSize is a property of line objects (see here for all of them), you would need to replace Axes in your code above with Line:

set(0,'DefaultLineMarkerSize',3);

Small example:

clear
clc
close all

set(0,'DefaultLineMarkerSize',3); %// The default is usually 6

X = linspace(0,2*pi,50)';
Y = [cos(X), 0.5*sin(X)];

stem(X,Y(:,1))
hold on
set(0,'DefaultLineMarkerSize',10);
stem(X,Y(:,2),'--r')

set(gca,'XLim',[0 X(end)])

Producing the following: enter image description here

Upvotes: 2

Related Questions