Skip to content

Question: The drop parameter of facet_grid seems not work #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bioinformatist opened this issue Apr 19, 2021 · 0 comments
Closed

Question: The drop parameter of facet_grid seems not work #510

bioinformatist opened this issue Apr 19, 2021 · 0 comments
Labels

Comments

@bioinformatist
Copy link

Hi, it seems drop parameter of facet_grid() function do not work.
Below is official example:

import pandas as pd

from plotnine import *
from plotnine.data import *

%matplotlib inline

(
    ggplot(mpg, aes(x='displ', y='hwy'))
    + geom_point()
    + facet_grid('drv ~ .')
    + labs(x='displacement', y='horsepower')
)

Then I can add a new category for mpg dataset as:

mpg['drv'] = pd.Categorical(mpg['drv'], ['4', 'f', 'r', 'yingyingying'])

This time the column mpg['drv'] seems like this:

image

An empty category 'yingyingying' was added.

I add drop=False to my code, but nothing happens:

(
    ggplot(mpg, aes(x='displ', y='hwy'))
    + geom_point()
    + facet_grid('drv ~ .', drop=False)
    + labs(x='displacement', y='horsepower')
)

image

How can I add an empty panel of 'yingyingying' without any data points?

Please tell me if there's any misunderstanding.

Thank you in advance.

@has2k1 has2k1 added the bug label Apr 20, 2021
@has2k1 has2k1 closed this as completed in 466189e Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants