Reputation: 21
I am trying to plot a simple Seaborn plot.
import seaborn as sns
from matplotlib import pyplot as plt
tips = sns.load_dataset('tips')
#Plotting our subplots dividing with smoker
sns.relplot(x = "total_bill", y = "tip", hue = "smoker", col = "size", data = tips)
#Showing our plots in a proper format
plt.show()
But it is showing an error
ValueError: could not broadcast input array from shape (244,2) into shape (244,)
What should I do?
Upvotes: 1
Views: 757
Reputation: 80534
There seems to be a bug with the 'size' column name. That's strange, because tips
is one of seaborn's typical example datasets.
It works as expected when that column gets renamed:
import seaborn as sns
from matplotlib import pyplot as plt
tips = sns.load_dataset('tips')
tips.rename(columns={'size': 'size_renamed'}, inplace=True)
sns.relplot(x='total_bill', y='tip', hue='smoker', col='size_renamed', data=tips)
plt.tight_layout()
plt.show()
Upvotes: 2