Skip to content
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

factor level with 0 counts does not show up correctly #30

Closed
xdaiISU opened this issue Feb 13, 2019 · 4 comments
Closed

factor level with 0 counts does not show up correctly #30

xdaiISU opened this issue Feb 13, 2019 · 4 comments

Comments

@xdaiISU
Copy link

xdaiISU commented Feb 13, 2019

There is no child crew members, but those tiles incorrectly shows up due to spill over of 3rd Class & child

> data(Titanic)
> a <- as.data.frame(Titanic)
> ggplot(data = a) + geom_mosaic(aes(x = product(Class), fill=Survived, weight=Freq)) + facet_grid(Age~Sex)
> 

screen shot 2019-02-13 at 5 10 31 pm

@gregleleu
Copy link
Contributor

gregleleu commented Feb 28, 2019

I have the same issue :(
It's ok when I set the offset to zero...

EDITED: Quick fix in my fork, in the divider file (last two commits)
Does the job on my case, haven't tested everything...
Plus I still feel we "see" a fine line of colors for theses 0 weight lines... removing offsets might not be the way to go...

@heike
Copy link
Collaborator

heike commented Feb 28, 2019

This is not a bug, it is a feature. The fine line is an indicator to which of the cell combinations is zero. Otherwise there is visually no way to distinguish between zero kids in the crew and any of the other factors.

@heike heike closed this as completed Feb 28, 2019
@gregleleu
Copy link
Contributor

I would agree if the initial data.frame has zeros in it, but since at some point the code is expanding all case it add zeros which were not present.
Maybe it could be added as an option somewhere?

@heike
Copy link
Collaborator

heike commented Feb 28, 2019

It is tricky to talk about the 'initial data.frame' in the context of a mosaic plot. Mosaic plots are a rendering of a contingency tables. Those do have zeroes, and it is informative to know where these zeroes are.
As an option to not show the space, you can always go to offset = 0.
Anything else will affect the validity of the representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants