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

Color/size of text labels? #20

Closed
bartekbursa opened this issue Sep 8, 2019 · 5 comments
Closed

Color/size of text labels? #20

bartekbursa opened this issue Sep 8, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@bartekbursa
Copy link

Is there any way to change the color and size of text labels on the plots?

@alastairrushworth
Copy link
Owner

Hi @bartekbursa. At the moment, there isn't an argument in show_plot() that does this, but I think it would be straightforward to add. It may also be possible to change this after the show_plot() call by manipulating the ggplot2 object. Is there a particular plot you have in mind?

@bartekbursa
Copy link
Author

Thanks for your response. It would be very convenient to be able to change some graphical parameters of the plots after show_plot(). In particular, I would like to change the color of the labels on plots made from inspect_cat from white to black. And possibly also the font size.

@alastairrushworth
Copy link
Owner

Thanks @bartekbursa. I agree, this would be a great feature to add. I've added it to the backlog and will leave this issue open until it's implemented.

In the meantime, an inelegant solution is to modify the ggplot2 object, for example:

library(dplyr)
library(inspectdf)
library(ggplot2)

# save the ggplot object
gf <- starwars %>% inspect_cat %>% show_plot
# decrease the label size
gf$layers[[2]]$aes_params$size <- 5
# change the text color - ignore the warning
gf <- gf + scale_colour_manual(values = c("red", "black"))
# view the modified plot
gf

Hope that helps!

@bartekbursa
Copy link
Author

Thanks @alastairrushworth for the workaround! It works fine :)

@alastairrushworth alastairrushworth added the enhancement New feature or request label Mar 9, 2020
@alastairrushworth alastairrushworth self-assigned this Mar 9, 2020
@alastairrushworth
Copy link
Owner

Hi @bartekbursa thanks for raising this issue. It is now possible to change the color of text label in several of the show_plot() outputs by adding the label_color = ... argument. I will add this change to the next cran release in a week or so. For example

library(dplyr)
library(inspectdf)
library(ggplot2)

starwars %>% inspect_cat %>% show_plot(label_color = c('red'))

For inspect_cat(), I haven't added flexibility to adjust the font size - resizing of text is handled internally at the moment. I might add the option to fix this size for a future release, but leaving as is for now, unless there is a good use case / example.

Thanks again for the suggestions :)

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

No branches or pull requests

2 participants