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,506
  • 7
  • 33
  • 78

2 Answers2

9

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
  • 265,629
  • 48
  • 427
  • 571
6

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,516
  • 1
  • 14
  • 29