0

I have a barplot in searborn in which I want to set the width of the bars. I thought this would be as easy as anything in seaborn, but it apparently isn't:

plt.figure(figsize=(20,10))
plt.xticks(rotation=45)

sns.barplot(
    x="date",
    y="nr_events",
    hue='weekday',
    data=df_count
)

Now, this gives me a bar plot showing a number of events per day, colored by weekday. But if I add width=1 in the arguments, an error is returned:

TypeError: bar() got multiple values for argument 'width'

How is this supposed to work in seaborn?

mrgou
  • 1,576
  • 2
  • 21
  • 45
  • I saw that too, but I was hoping there would be a much easier solution to such a simple thing. I have only 3 lines of codes to produce my plot, so adding 10 more to just tweak the bar width is rather unexpected! – mrgou Mar 10 '21 at 10:39
  • 1
    True, and what about the `dodge=False` parameter (second answer)? – perl Mar 10 '21 at 10:54
  • 1
    Yes, you're right! I had totally overlooked that part of the answer! Thank you!!! :-) – mrgou Mar 10 '21 at 11:49
  • Cool, glad it helped! – perl Mar 10 '21 at 11:50

0 Answers0