Kenenbek Arzymatov
Kenenbek Arzymatov

Reputation: 9149

Add lines along axes in matplotlib

I have such a piece of code for generating two plots in jupyter notebook:

plt.figure(figsize=(5, 4))

x = np.arange(10)

plt.subplot(2, 1, 1)
plt.plot(x, x)

plt.subplot(2, 1, 2)
plt.plot(x, x)

enter image description here

How can I add black lines that go along axes?

Like this one:

2

Upvotes: 0

Views: 36

Answers (2)

Diziet Asahi
Diziet Asahi

Reputation: 40747

You seem to be using the darkgrid theme of seaborn. You want to use to tick style instead.

sns.set_style("ticks")

See Controlling figure aesthetics

Upvotes: 2

user14093575
user14093575

Reputation:

Change the following rcParams by adding the following lines to the code:

plt.rcParams['axes.spines.left'] =  True
plt.rcParams['axes.spines.bottom'] =  True
plt.rcParams['axes.spines.top'] =  True
plt.rcParams['axes.spines.right'] =  True

Upvotes: 1

Related Questions