has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
3.97k stars 213 forks source link

xkcd style & whiskers of box plot #134

Open zhouzq-thu opened 6 years ago

zhouzq-thu commented 6 years ago

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()

2

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()

1

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()

download

has2k1 commented 6 years ago