Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide text before seaborn barplot [duplicate]

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

like image 231
Hardik Gupta Avatar asked Dec 05 '22 09:12

Hardik Gupta


2 Answers

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)
like image 189
piRSquared Avatar answered Dec 24 '22 21:12

piRSquared


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)
like image 35
Vicrobot Avatar answered Dec 24 '22 19:12

Vicrobot