5

I am trying to print a barplot using seaborn

plt.figure(figsize=(16, 6))
g = sns.barplot(x = 'A', y = 'B', data = df)
g.set_xticklabels(g.get_xticklabels(), rotation=90)

However, before the actual plot, there are two cell which get printed with text something like this

out[3]: <Figure size 1152x432 with 0 Axes>
out[3]: [Text(0, 0, 'valueA'),
         Text(0, 0, 'valueB'),
         ....
         Text(0, 0, 'valueZ')]

        <Actual BarPlot>

How can I suppress the text before the Actual BarPlot

Hardik Gupta
  • 4,700
  • 9
  • 41
  • 83

2 Answers2

10

set_ticklabels returns the tick values. You can either suppress it with a semicolon

g.set_xticklabels(g.get_xticklabels(), rotation=90);

Or assign the return to a name

ticks = g.set_xticklabels(g.get_xticklabels(), rotation=90)
piRSquared
  • 285,575
  • 57
  • 475
  • 624
8

The setting of text is returning the text objs. Thus; if you take them in a variable, then no output would be there.

var = g.set_xticklabels(g.get_xticklabels(), rotation=90)
Vicrobot
  • 3,795
  • 1
  • 17
  • 31