Is it possible to set the color of the borders of the dots that are generated via the Axes.scatter
or is it always black?
thanks!
Output: Now to change the colors of a scatterplot using plot(), simply select the column on basis of which different colors should be assigned to various points.
scatter( x , y , sz , c ) specifies the circle colors. You can specify one color for all the circles, or you can vary the color. For example, you can plot all red circles by specifying c as "red" .
To set color for markers in Scatter Plot in Matplotlib, pass required colors for markers as list, to c parameter of scatter() function, where each color is applied to respective data point. We can specify the color in Hex format, or matplotlib inbuilt color strings, or an integer.
Matplotlib has a function named annotate() to add text in a specific location in a plot. We need to specify annotate() function the text we want to annotate the plot with and the x and y co-ordinates for the location of the text.
If you want to make all the edges the same color:
ax.scatter(...., edgecolor=EC)
where EC
is a color. If you want to surpress the edge (so it looks like the edge color matches the face color) use
ax.scatter(..., linewidths=0)
If you want to have the edges be a different color than the face and each marker have it's own color it looks like you have to do the mapping your self:
my_cmap = cm.get_cmap('jet')
my_norm = matplotlib.colors.Normalize()
ec_data = rand(15)
my_normed_data = my_norm(ec_data)
ec_colors = my_cmap(my_normed_data) # a Nx4 array of rgba value
ax.scatter(rand(15), rand(15), s=500, c=rand(15), edgecolors=ec_colors, linewidth=3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With