Hey there!
I'm currently working on a Jamovi Module for school students for my Mathmatics teaching studies. As I want to do a plot, comparing several binomial distributions I wonder how I can access the current jamovi theme colors if I want to have more than one.
Does anybody know ?
So far I know that I can access the color in the plot function with ``theme$fill[2]`` but this is only one color.
theme colors
Re: theme colors
take a look here:
https://github.com/jamovi/jmv/blob/master/R/descriptives.b.R#L858-L899
the plot functions take a theme object, and a ggtheme object. if you're using ggplot, you can usually just + the ggtheme onto the plot object
cheers
jonathon
https://github.com/jamovi/jmv/blob/master/R/descriptives.b.R#L858-L899
the plot functions take a theme object, and a ggtheme object. if you're using ggplot, you can usually just + the ggtheme onto the plot object
cheers
jonathon
Re: theme colors
Thanks for the quick reply!
I already looked at the code of descriptives. What I'm looking for is getting the same colours as when splitting a histogram (blue, grey, yellow in default settings).
I did use the ggtheme but it has no effect on the fill color so far. I just didn't find how the ggtheme or the theme that are passed to the plot function are constituted.
Cheers
I already looked at the code of descriptives. What I'm looking for is getting the same colours as when splitting a histogram (blue, grey, yellow in default settings).
Code: Select all
plot <- ggplot(data, aes(x=var)) +
ylab("P(X=r)") +
xlab("r") +
xlim(0,100)+
ylim(0,0.3)+
ggtheme[[1]] +
geom_bar(aes(y=density),stat="identity",linetype="blank",alpha=0.7,fill = theme$fill[2]) +
geom_bar(aes(y=density2),stat="identity",linetype="blank",alpha=0.7,fill = theme$fill[2] )
Cheers
Re: theme colors
ok I found a workaround by pasting the two densities in one list and giving them different groups. Then you can use fill=group in ggplot.
Re: theme colors
That's indeed how you have to do it to make use of the ggtheme. ggplot needs to know on which grouping you want to base the color/fill.
Re: theme colors
ok for anyone having the same problem, I found out at stack overflow how to get fill colors from the ggplot build object: https://stackoverflow.com/questions/11774262/how-to-extract-the-fill-colours-from-a-ggplot-object
Re: theme colors
The name of the palette is also accessible through theme$palette which you can pass on to the jmvcore::colorPalette function as follows (where n is the number of colors you want, and type whether you want the fill or color palette):
Code: Select all
jmvcore::colorPalette(n=2, theme$palette, type="fill")