10

Consider this plot:

import matplotlib.pyplot as plt
import seaborn as sns

Data = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", hue="smoker", data = Data, legend_out = False, aspect = 2)
g.set(xlabel = "independent", ylabel = "dependent")
sns.despine(fig=None, ax=None, top=False, right=False, left=False, bottom=False, offset=None, trim=False)
plt.show()

enter image description here

Now if I add the settings:

sns.set(rc={'figure.figsize':(10,5)}, font_scale=1.5)
sns.set_style({'axes.facecolor':'white', 'grid.color': '.8', 'font.family':'Times New Roman'})

It removes the border which I want to keep:

enter image description here

I would appreciate if you could help me know what is th eproblem and how I can fix it.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193

2 Answers2

10

Maybe you want to ignore seaborn's styling and just set the parameters you need directly?

import matplotlib.pyplot as plt
import seaborn as sns

rc = {'figure.figsize':(10,5),
      'axes.facecolor':'white',
      'axes.grid' : True,
      'grid.color': '.8',
      'font.family':'Times New Roman',
      'font.size' : 15}
plt.rcParams.update(rc)

Data = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", hue="smoker", data = Data, legend_out = False, aspect = 2)
g.set(xlabel = "independent", ylabel = "dependent")
sns.despine(fig=None, ax=None, top=False, right=False, left=False, bottom=False, offset=None, trim=False)
plt.show()

enter image description here

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • That's actually even better. The only reason I'm using seaborn is because I can get the nice error bars through the `lmplot`. otherwise, it is not a straight forward library at all. Not that `matplotlib` or other libraries are better, bu there are at least more information on the internet. I will try your solution and will come back. – Foad S. Farimani Mar 06 '19 at 15:29
8

Try use this (Python)

# Remove all borders
sns.despine(bottom = True, left = True)
plt.show()