chevron_left
Text, Label and Annotations Cookbook
Adding a title to a plotAdding arrows to an annotationAdding axis labels to a plotAdding markers to a plotAnnotating data pointsApplying an offset to annotationsChanging the default font sizeChanging the marker size in scatterplotsChanging the number of ticksChanging the tick sizeRemoving certain ticksRemoving column name label from pie chartsRemoving default axis labelsRotating axis labelsRotating custom tick labelsSpecifying custom tick labelsWriting mathematical expressions
0
0
0
new
Changing the marker size of scatter plots in Matplotlib
Programming
chevron_rightPython
chevron_rightMatplotlib
chevron_rightCookbooks
chevron_rightText, Label and Annotations Cookbook
schedule Jul 1, 2022
Last updated Python●Matplotlib
Tags tocTable of Contents
expand_more Constant size
To change the size of all markers in Matplotlib, specify the s
argument in plt.scatter(~)
:
x = [1,2,4]y = [3,3,3]plt.scatter(x, y, s=100)plt.show()
This produces the following output:

Variable size
To vary the size of individual markers, pass in an array instead:
x = [1,2,4]y = [3,3,3]sizes = [5,50,500]plt.scatter(x, y, s=sizes)plt.xlim(0,5)plt.show()
The output is as follows:

Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
Ask a question or leave a feedback...
0
0
0
Enjoy our search