'No major tick marks showing using seaborn white style and cannot restore

When I generate plots using the seaborn "white" style I see major tick labels but I don't see any major tick marks.

Setting major tick marks to be bigger using...

%matplotlib inline

import seaborn as sns
import matplotlib.pyplot as plt

sns.set_style('white', {'axes.linewidth': 0.5})
plt.rcParams['xtick.major.size'] = 20
plt.rcParams['xtick.major.width'] = 4

fig, ax = plt.subplots()
plt.show()

...has no effect.

I can't find any option that would make the tick marks visible/invisible.

Anybody have any clues?



Solution 1:[1]

In case one wants to not mess with global rcParams, but manually tune by plot, one can use ax.tick_params()

import seaborn as sns
import matplotlib.pyplot as plt

sns.set_style('white', {'axes.linewidth': 0.5})

fig, ax = plt.subplots()
ax.tick_params(bottom=True, left=True)
plt.show()

The critical part is "enabling" the tick marks - in this case the bottom and left marks were enabled. If one wants marks on the four sides, using ax.tick_params(reset=True) might also be an option, though I'm not sure how this might affect other Seaborn tunings.

There are also a number of options listed in the function documentation that might be useful, although they do not apply directly to OP.

Note: this answer also works for other styles, including the default one, not just 'white'.

Solution 2:[2]

Use the 'ticks' style

This is a built-in style for the exact purpose of having 'white' style with tick marks:

sns.set_style('ticks')  # white style with tick marks


If you really want to use the 'white' style or just want to modify tick params, it's simplest to pass an rc dict:

sns.set_style('white', rc={
    'xtick.bottom': True,
    'ytick.left': True,
})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ronan Paixão
Solution 2 tdy