Coder Social home page Coder Social logo

ggdark's People

Contributors

nsgrantham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggdark's Issues

dark_theme_* verboseness during knit()

When running knitr, a lot of messages are sent to the log file:

processing file: initial-data-splitting.qmd
  |......................................         |  80% [fig-ames-splitting]  Inverted geom defaults of fill and color/colour.
To change them back, use invert_geom_defaults().

Could you add ... to the dark_theme_*() functions to pass verbose to dark_mode()?

Force convert for near-black colors

Hi Neal,

This is a great package. I have an enhancement suggestion relating to:

geoms_are_dark <- geoms[["GeomPoint"]]$default_aes$colour %in% c("black", "#000000")

I suggest near-black be returned as TRUE from this line, as well. Examples of these colors are:

  • #330000 #330000
  • #00004d #00004d
  • #1a0d00 #1a0d00

None of the above colors would force color inversion in the above line, but I think they probably should.


Rather than list all of these possible colors in the c("black", "#000000") vector, I am proposing something like the following:

too_dark <- function(color) {
  rgb <- col2rgb(color)[,1]
  dark_rtg <- sum(c(0.299, 0.587, 0.114) * rgb)
  dark_rtg < 25
}

This snippet accepts a color (by name or hex) and returns a logical value indicating whether or not the color is too dark. This could be applied across the geoms[["GeomPoint"]]$default_aes$colour vector to determine if any of the values are too dark.

As a note, the above formula is an International Telecommunication Union standard for Luma.


I am happy to implement this in a pull request, but I don't see a CONTRIBUTING.md or similar file anywhere in your repository. Let me know if you think this is a good idea and, if so, any specifics you'd like me to apply in my pull request.

Prevent ggdark from inverting geoms when ussing it as `ggdark::`

I was wondering if it's possible to change the behavior of ggdark. is it possible to keep the inverting of geoms by default when loading it as library(ggdark) but prevent such inversion when using ggdark with :: (e.g., plot + ggdark::dark_theme_minimal(base_size = 24) would bring the dark theme but not modify any of the default geoms)

`geom_step()` behaves strangely when inverting colors

library(ggplot2)
library(ggdark)
set.seed(1)

df <- data.frame(x=1:100, y = rnorm(100))
ggplot(df, aes(x, y))+
  geom_point() +
  dark_theme_bw()
#> Inverted geom defaults of fill and color/colour.
#> To change them back, use invert_geom_defaults().

# This should work for both step and point
ggplot(df, aes(x))+
  geom_step(aes(y=cumsum(y), group=1))+
  geom_point(aes(y=cumsum(y)))+
  dark_theme_bw()

  
# This is the expected output, right?
ggplot(df, aes(x))+
  geom_step(aes(y=cumsum(y), group=1), color="white")+
  geom_point(aes(y=cumsum(y)))+
  dark_theme_bw()

# let's call it normally
ggplot(df, aes(x))+
  geom_step(aes(y=cumsum(y), group=1))+
  geom_point(aes(y=cumsum(y)))

invert_geom_defaults()
# now step gets inverted
ggplot(df, aes(x))+
  geom_step(aes(y=cumsum(y), group=1))+
  geom_point(aes(y=cumsum(y)))

Created on 2023-01-05 by the reprex package (v2.0.1)

Getting Error in col2rgb: invalid color name '~'

Hi,

When I get this error, I restart R and sometimes it works, sometimes it doesn't. What can be the source of this issue? Here's the traceback

172: col2rgb
171: invert_color
170: invert_geom_defaults
169: dark_mode
168: dark_theme_gray
167: renderPlot
165: func
125: drawPlot
111: reactive:plotObj
95: drawReactive
82: origRenderFunc
81: output$bars
1: shiny::runApp

protect against no active themes

ggdark::dark_theme_grey()
#> Error in if (geoms_are_dark || force_geom_invert) {: missing value where TRUE/FALSE needed

Created on 2024-06-29 with reprex v2.1.0

or maybe add ggplot2 as depends since it doesn't work without it loaded

Add support for non-native geoms

There are many extensions to ggplot2 which provide a variety of new geoms (see http://www.ggplot2-exts.org/gallery/).

Modify update_geom_colors to update the default colors of any new geoms that have been loaded. One solution may be to grep for geom_* defined in the global environment and update those with fill and color aesthetics.

Silence ggdark?

Hi,

thanks for creating such a cool ggplot2 extension!

I'm currently using your package as

dark_theme_bw() +
   theme(legend.position = c(0.25, 0.18), 
         legend.background = element_blank(),
         legend.title = element_blank(), 
         legend.text = element_text(size = 12),
         legend.key.size = unit(6, units = 'mm'),
         axis.text = element_text(colour = 'white'),
         axis.title.x = element_blank() )

and every now and then I get a message that says:

Inverted geom defaults of fill and color/colour.
To change them back, use invert_geom_defaults().

Is it possible NOT to print such message? Is there something like verbose = FALSE argument?

Thanks!

Licensing

Howdy,

This is an awesome package - thanks for providing such a simple API for making dark-theme plots! I'd like to make some modifications on top of the ggdark themes and contribute any that are useful back upstream. Would you consider relicensing the repo under an open source friendly license? I won't advise on which license to choose (that's something for you to decide), but something more permissive would encourage contributions, and a Citation / Contributing guide could help ensure you still got proper credit from the community.

Cheers,
Eric

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.