Reputation: 9180
I have the following Python 3 code for generating a plot with matplotlib
:
import numpy as np
import matplotlib.pyplot as py
x = np.arange(0, 10, 0.1)
y = np.sin(x)
py.figure(1)
py.plot(x, y, c='g', lw=2)
py.ylim(-1.1, 1.1)
py.title('Plot Title')
py.ylabel('Y label')
py.xlabel('X label')
py.gca().spines['top'].set_visible(False)
py.gca().spines['right'].set_visible(False)
py.gca().spines['bottom'].set_visible(False)
py.gca().spines['left'].set_visible(False)
py.tick_params(top='off', right='off', bottom='off', left='off')
py.grid()
py.show()
This is my preferred configuration for creating plots with no axis borders or tick marks. Only the axis labels, title, and grid remain. Instead of writing the spines
and tick_params
for every plot figure, I tried to add the parameters to a mplstyle
file. However, the style file doesn't support these features. Is there a way to make this the default configuration for all figures?
Upvotes: 0
Views: 1193
Reputation: 9180
Using the axes.linewidth
and the major.width
parameters in the style sheet, I'm able to replicate the same effects as the spine
and tick_params
. The following is what I am currently using in my style sheet to get the desired effects:
lines.linewidth : 2
axes.grid : True
axes.linewidth : 0
xtick.major.width : 0
ytick.major.width : 0
grid.color : black
And here is the plot that the style creates:
Upvotes: 1