Mtcars
is a public dataset in R. I'm not sure it's a public dataset in python.
mtcars <- mtcars
I created this boxplot in R and part of what I'm doing is reordering the y-axis with the reorder()
function.
ggplot(mtcars, aes(x = mpg, y = reorder(origin, mpg), color = origin)) +
geom_boxplot() +
theme(legend.position = "none") +
labs(title = "Mtcars", subtitle = "Box Plot") +
theme(plot.title = element_text(face = "bold")) +
ylab("country")
Now in python I have this boxplot that I created with seaborn:
plt.close()
seaborn.boxplot(x="mpg", y="origin", data=mtcars)
plt.suptitle("Mtcars", x=0.125, y=0.97, ha='left', fontweight = 'bold')
plt.title("boxplot", loc = 'left')
plt.show()
I'm trying to render it now but the same kind of treatment for R doesn't work.
plt.close()
seaborn.boxplot(x="mpg", y=reorder("origin", 'mpg'), data=mtcars)
plt.suptitle("Mtcars", x=0.125, y=0.97, ha='left', fontweight = 'bold')
plt.title("boxplot", loc = 'left')
plt.show()
It's not surprising it doesn't work because it's a different language; I do know that! But how would I do this reordering in python using Seaborn? I'm having trouble understanding if this is even part of the plotting process.