plotnine
plotnine copied to clipboard
xkcd style & whiskers of box plot
Could the bars (same as boxplot) be in xkcd style?
import pandas as pd
import numpy as np
from plotnine import *
from plotnine.data import mtcars
p = ggplot(aes(x='factor(am)'), mtcars)
p + geom_bar() + theme_xkcd()

The whiskers of box plot are influenced by the transparency (alpha=0.2).
p = ggplot(aes(x='factor(am)', y='mpg'), mtcars)
p + geom_boxplot(
aes(fill='factor(cyl)'),
color='k',
alpha=0.2,
outlier_color='r',
outlier_size=1.5,
) + theme_xkcd()

Problem about line width and background of legend
p = ggplot(aes(x='factor(am)', y='mpg'), mtcars)
p + geom_boxplot(
aes(fill='factor(cyl)'),
color='k',
alpha=0.2,
outlier_color='r',
outlier_size=1.5,
) + theme_bm()

-
[ ] The bar style issue is a due to Matplotlib; the alteration of linestyles that creates the XKCD style does not apply universally. I do not know if it is easily fixable.
-
[x] The whiskers should not be influenced by the
alphatransparency. -
[x] The legend
linewidthdoes not look right, need to confirm if it looks the same in pdf.