Issue
data1 = randn(100)
data2 = randn(100)
sns.boxplot(data1,vert=False)
the above lines of code give me error below
TypeError: boxplot(
) got multiple values for keyword argument 'vert'
(All the required libraries are imported)
My version is 3.6 of Python and I am using Anaconda's Jupyter Notebook
to execute the code
Solution
When using a seaborn boxplot, the keyword argument you need is orient
. This has options "h"
for horizontal, or "v"
for vertical .
So for your case the solution would simply be sns.boxplot(data1, orient="h")
.
Seaborn boxplot calls ax.boxplot
under the hood. Seaborn doesn't accept vert
as an argument because vert
is calculated by seaborn from the orient
argument in categorical.py
line 457-459, which is then passed to ax.boxplot
:
def draw_boxplot(self, ax, kws):
"""Use matplotlib to draw a boxplot on an Axes."""
vert = self.orient == "v"
If you were to include vert=False
in sns.boxlpot(data1, vert=False)
that would essentially be the same as ax.boxplot(data1, vert=False, vert=False)
which you can't do.
Answered By - DavidG
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.