- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the border color of the dots in matplotlib's scatterplots?
To set the border color of the dots in matplotlib scatterplots, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Initialize a variable "N" to store the number of sample data.
- Create x and y data points using numpy.
- Plot the x and y data points using scatter() method. To set the border color of the dots, use the edgecolors parameter in the scatter() method. Here, we have used "red" as the border color of the dots by using edgecolors='red'.
- To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True N = 10 x = np.random.rand(N) y = np.random.rand(N) plt.scatter(x, y, s=500, c=np.random.rand(N), edgecolors='red', linewidth=3) plt.show()
It will produce the following output
- Related Articles
- How to set the border color of certain Tkinter widgets?
- Set the color of the border with CSS
- Set the color of the right border using CSS
- How to set border color for SoftBevelBorder in Java?
- Using Colormaps to set the color of line in Matplotlib
- How to set the background color of a column in a matplotlib table?
- How to set raised and lowered SoftBevelBorder for components in Java. Also set the border color.