2

I have a dataframe named IAT like this:

dados = [["2019-10",20.59,"Glosa de 5%"],["2019-10",47.37,"Glosa de 5%"],["2019-10",78.12,"Glosa de 5%"],["2019-10",10,"Glosa de 5%"],["2019-11",15,"Glosa de 5%"],["2019-10",96,"Nenhuma Penalidade"],["2019-10",91,"AdvertĂȘncia"], ["2019-10",91,"AdvertĂȘncia"]] 

IAT = pd.DataFrame(dados, columns=['Conclusao Real', 'Indicador de Prazo', 'Penalidade'])

I want to plot "Conclusao Real" x "Indicador de Prazo" using the column "Penalidade" as the color bars.

My plot got right, but there is a black vertical line inside the third bar that I did not understand the reason it appeared:

Plot

My plot code:

import seaborn as sns

IAT.sort_values('Conclusao Real',inplace=True,ascending=True)

fig,ax = plt.subplots()
fig.set_size_inches(10,6)

g=sns.barplot(x='Conclusao Real',y='Indicador de Prazo',data=IAT, hue='Penalidade',ax=ax)

What is wrong with this code above?

Is there another better way to plot it?

asongtoruin
  • 9,794
  • 3
  • 36
  • 47
Renata Mesquita
  • 105
  • 1
  • 13

1 Answers1

3

These are just the error bars. You can turn them of by setting ci=None.

sns.barplot(x='Conclusao Real', y='Indicador de Prazo', data=IAT, hue='Penalidade', ax=ax, ci=None)

Fig1

The reason they're only turning up on a single column is because you need multiple points of data to calculate error bars and only 2019-10 Glosa de 5% has multiple data points to do this. You also have two data points for AdvertĂȘncia but both these data points are the same value so the error is none.

Muon
  • 1,294
  • 1
  • 9
  • 31