Skip to content

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

Description

@bioinformatist

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions