nsgrantham / ggdark Goto Github PK
View Code? Open in Web Editor NEWDark mode for ggplot2 themes
License: Other
Dark mode for ggplot2 themes
License: Other
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()
?
Hi Neal,
This is a great package. I have an enhancement suggestion relating to:
Line 36 in e85b4da
I suggest near-black be returned as TRUE
from this line, as well. Examples of these colors are:
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.
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)
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)
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
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
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.
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!
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.