emcramer / CHOIRBM

Plotting and analytic utilities for the CHOIR Body Map.
Other
5 stars 2 forks source link

Changing colour scheme #1

Closed handrigg closed 2 years ago

handrigg commented 2 years ago

Hello,

I am working with your excellent 'CHOIRBM' R package for a research project on pain and bariatric surgery. I am using it to put together a clinical research collaborator's figures on pain sites for a scientific poster presentation. I have a relatively simple (I hope) question, and I apologize in advance if it is answered in the documentation on your github page. Is it possible to change the colors for the bodymaps? Currently, they are the default dark to light blue and I was wondering if it were possible to customize this for a different gradient (blue to yellow).

Again, thanks for developing the package.

Grant

RaviBot commented 2 years ago

Hello, I would like follow up on Grant's suggestion! I tried to change the colors using ggplot2 color functions such as scale_color_brewer(palette="YlOrRd"), but to no avail. This functionality would be very useful. Thanks in advance!

emcramer commented 2 years ago

Hi @handrigg ,

I am glad to hear that the package has been helpful! I am sorry for not getting to your request sooner.

In case you have not solved the problem yet, you can change the color scheme with the ggplot2 functions. @RaviBot , I think you're on the right track, the issue may have been that scale_color_brewer(palette="YlOrRd") could be designed for a discrete as opposed to continuous scale, or is not a "fill" type. You can change the color scales like so:

plot_male_choirbm(values, "value") + scale_fill_gradient(low = "#FFFACD", high = "#800080")

Which will produce a yellow-purple gradient.

You can also use the viridis package and play around with their built-in palettes.

#install.packages("viridis") library(viridis) plot_male_choirbm(values, "value") + scale_fill_viridis(palette="magma")

I hope that helps, and good luck with your poster!