To add black border to matplotlib 2.0 'ax' object in Python, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Set axes edgecolor to black.
- Set axes linewidth to 2.50.
- Initialize a variable, N, to get the number of sample data.
- Create x and y data points using numpy.
- Plot x and y data points using plot() method.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.rcParams["axes.edgecolor"] = "black" plt.rcParams["axes.linewidth"] = 2.50 N = 10 x = np.random.randint(low=0, high=N, size=N) y = np.random.randint(low=0, high=N, size=N) plt.plot(x, y, color='red') plt.show()