0

How can I make a plot surrounded with a bold line, like so?

enter image description here

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
lola
  • 145
  • 1
  • 9

3 Answers3

1

You could use the following code that was the answer on a similar question

import matplotlib.pyplot as plt
import matplotlib as mpl
plt.rcParams["axes.edgecolor"] = "black"
plt.rcParams["axes.linewidth"] = 2.50
fig = plt.figure(figsize = (4.1, 2.2))
ax = fig.add_subplot(111)
Orfeas Bourchas
  • 353
  • 1
  • 6
1

You can set the width and colour of a border around the image like so:

from matplotlib import pyplot as plt

# some data for demonstration purposes
import numpy as np
x = np.random.randn(100)

# create figure
fig, ax = plt.subplots()

ax.plot(x)

# set the border width
fig.set_linewidth(10)

# set the border colour (to black in this case)
fig.set_edgecolor("k")

# show the figure
fig.show()

This gives:

enter image description here

Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32
1

I would use the set_linewidth and set_color parameters from matplotlib spines :

An axis spine -- the line noting the data area boundaries.

import matplotlib.pyplot as plt

C, W, L, T = "black", 4, 2, 7 # <- adjust here
#Color, Width, Length, Tickness --------------

fig, ax = plt.subplots(figsize=(W, L))
list_of_spines = ["left", "right", "top", "bottom"]

for sp in list_of_spines:
    ax.spines[sp].set_linewidth(T)
    ax.spines[sp].set_color(C)

ax.set_xticks([])
ax.set_yticks([])

plt.show();

Output :

enter image description here

Timeless
  • 22,580
  • 4
  • 12
  • 30