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

[Issue] With g2(), subject() is pushing down the plot and hiding the x axis #5

Open
jdunham022 opened this issue May 13, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jdunham022
Copy link

When using subject() with g2(), my plots are being pushed down by the title and my axis is then being hidden (as well as the bottom of the plot). I am just starting out with the g2r package and could possibly be doing something incorrectly. Below is a simple plot with subject() being used. I have attached two pictures showing my output of the below code. One is with subject("Plot Title"), and the other is without subject() being used.

dat <- mtcars %>%
  mutate(car = rownames(mtcars)) %>%
  head(6)

g2(dat, asp(x = car, y = mpg)) %>%
  fig_interval() %>%
  subject("Plot Title")

with_subject
without_subject

@jdunham022 jdunham022 added the bug Something isn't working label May 13, 2021
@JohnCoene
Copy link
Member

I think this is a corner case caused by an option to display the visualisation over the entire browser/viewer.

As a workaround you can set the height of the plot in pixels (defaults to 100%).

# set height
g2(dat, asp(x = car, y = mpg), height = 500) %>%
  fig_interval() %>%
  subject("Plot Title")

It should work fine in Rmarkdown, let me know if it does not.

@jdunham022
Copy link
Author

Thank you for the quick response. Your solution does with within RStudio and the RStudio Viewer, but once knitted to an html document (I am using flexdashboard), the problem persists. I messed around with different {data-height} values with flexdashboard as well as different pixel values within g2, and am still coming up empty.

Thanks again for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants