1

Running the code below produces a chart where the x-axis labels just get nuked.

import seaborn as sns; sns.set() 
import matplotlib.pyplot as plt 
fmri = sns.load_dataset("fmri") 
ax = sns.lineplot(x="timepoint", y="signal", data=fmri) 
ax.set_xticklabels(ax.get_xmajorticklabels(), fontsize = 12)

the same holds true for:

ax.set_xticklabels(ax.get_xticks())
ax.set_xticklabels(ax.get_xticklabels())
ax.set_xticklabels(ax.get_xmajorticklabels())

How do I fix this?

enter image description here

Fabian Bosler
  • 2,310
  • 2
  • 29
  • 49

1 Answers1

2

The first argument of set_xtickslabels has to be a list of strings for it to work. Like such:

import seaborn as sns; sns.set() 
import matplotlib.pyplot as plt 
fmri = sns.load_dataset("fmri")
ax = sns.lineplot(x="timepoint", y="signal", data=fmri)  
ax.set_xticklabels([str(i) for i in ax.get_xticks()], fontsize = 20)

produces this output

enter image description here

JacoSolari
  • 1,226
  • 14
  • 28