python - Seaborn barplot with 2 bars with the same label -
i using seaborn python3 create horizontal barplot, so:
#!/usr/bin/python3 import seaborn sns import matplotlib.pyplot plt if __name__ == '__main__': names = ['alice', 'bob', 'bob'] values = [3, 2, 1] sns.barplot(x = values, y = names) plt.savefig('seaborn_figure.png')
sometimes, 2 bars have same label (as in example above), leads seaborn draw 2 datapoints label 1 bar error bar:
i prefer seaborn not combine values (i.e. particular chart should have 3 horizontal columns, 2 of them labeled bob).
i've tried setting xerr = none
in sns.barplot()
call, changes nothing.
it better if did not have label duplication, unfortunately names set people outside of sphere of influence. of course around renaming datapoints (e.g. "bob 1" , "bob 2"), not elegant solution.
is there way force seaborn draw many bars there labels/values, if labels identical?
you can following:
names = ['a', 'b', 'c'] values = [3, 2, 1] ax = sns.barplot(x = values, y = names) ax.set_yticklabels(['alice', 'bob', 'bob'])
but should this? doesn't make sense seaborn asking, may better off importing seaborn
style want, plotting matplotlib
can plot want.
Comments
Post a Comment