You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given how frequent modifying color and shapes seems to appear in the dartR google group it is probably worth adding the options to gl.pcoa.plot()
There are three ways to do this with varying levels of flexibility and implementation cost.
add scale_color/shape_manual to the current function, I did this for a previous project and the code is here: https://github.com/Maschette/redartR/blob/master/plot_pcoa.R it adds the options col and shape to the current function so these can be changed. It does also set the default theme to theme_bw because that's what I needed for a publication.
add a new function which returns a ggplot object using ggbuilder which can be edited to modify a range of the ggplot settings. @raymondben had a first pass of this which I forked here: https://github.com/Maschette/redartR
Just a note: you can do option 3 now, because gl.pcoa.plot returns an object of class ggplot:
p <- gl.pcoa.plot(...)
p + theme_bw()
But you can only add new layers, so modifying an existing layer (e.g. to add a shape aesthetic) isn't possible.
Another alternative is to use ggplot_build, which will allow modification of e.g. assigned aesthetics and the underlying data:
p <- gl.pcoa.plot(...)
q <- ggplot_build(p)
## hack q here
plot(ggplot_gtable(q))
But this is probably most suited to relatively advanced users (who will probably be comfortable writing their own plotting function anyway, so might not really be targeting the audience that is asking these questions of the google group. Same probably applies to option (2) above.)
Given how frequent modifying color and shapes seems to appear in the dartR google group it is probably worth adding the options to
gl.pcoa.plot()
There are three ways to do this with varying levels of flexibility and implementation cost.
add scale_color/shape_manual to the current function, I did this for a previous project and the code is here: https://github.com/Maschette/redartR/blob/master/plot_pcoa.R it adds the options col and shape to the current function so these can be changed. It does also set the default theme to theme_bw because that's what I needed for a publication.
add a new function which returns a ggplot object using
ggbuilder
which can be edited to modify a range of the ggplot settings. @raymondben had a first pass of this which I forked here: https://github.com/Maschette/redartRrewrite the function implementing the ggplot2 style guide (https://ggplot2.tidyverse.org/dev/articles/ggplot2-in-packages.html#referring-to-ggplot2-functions) in combination with
ggbuilder
to give a more flexible function. The advantage of this being people would be able to implement things such as:gl.pcoa.plot(glPca, gl)+scale_color_manual(values=...)
to change things.My recommendation for the short term would be implement 1 and explore 2-3.
The text was updated successfully, but these errors were encountered: