Dmitri
Dmitri

Reputation: 811

Matplotlib scatter(): default value for size, marker shape

Is there a way to set default marker size (s) parameter for matplotlib plt.scatter() (or likewise to set the shape of the marker)?

mpl.rcParams.keys() has settings for the line plots, e.g.

import matplotlib as mpl
mpl.rcParams['lines.marker']='D'

... but they do not seem to relate to plt.scatter().

Thanks.

Clarification:

I'd like to use a configuration mechanism like mpl.rcParams(), or some other reasonably civilized method. Locally modifying library code is not it.

On the other hand, if it cannot currently be done and somebody submits a patch to Matplotlib, that would be awesome.

Upvotes: 10

Views: 33808

Answers (3)

Dan
Dan

Reputation: 71

In the current release, marker size is defined as:

"The marker size in points**2. Default is rcParams['lines.markersize'] ** 2."

So setting rcParams['lines.markersize'] should change the default marker size for scatterplots too now. See https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html

Upvotes: 7

Fabian Rost
Fabian Rost

Reputation: 2414

It is not possible in the current release of matplotlib (http://matplotlib.org/users/customizing.html).

However, there is an option to change the default marker in the master branch on GitHub (https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/rcsetup.py#L1112).

Upvotes: 0

Leb
Leb

Reputation: 15953

Of course there is, it's all in the pyplot.py

A snippet from their code:

def scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None,
            vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
            hold=None, data=None, **kwargs):

The size is set to 20 s=20 and the marker shape is a circle marker='o' which agrees with their documentation

Upvotes: 8

Related Questions