correlation icon indicating copy to clipboard operation
correlation copied to clipboard

Changing aesthetics of the correlation plot

Open MarkKramer opened this issue 1 year ago • 2 comments

I am struggling to make 2 aesthetic adjustments and am sincerely hoping that you can assist:

i. How can I make the legend (colorbar) continuous as opposed to discrete? ii. How can I change the orientation of the plot (i.e. top left vs. bottom right)? Ankle_ROM_vs_PF_LR

MarkKramer avatar May 08 '23 15:05 MarkKramer

Hi Mark,

You can customize the legend and change the orientation by overwriting some ggplot specifications:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.2.2
library(correlation)

mtcars |> 
  correlation() |> 
  summary() |> 
  plot() +
  scale_fill_gradient2(low = "purple", high="green") +
  scale_y_discrete(limits = rev)
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.

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

Hope that helps!

DominiqueMakowski avatar May 08 '23 15:05 DominiqueMakowski

Brilliant, this is exactly what I was looking for. The next question is: I then plotted the correlation for some of the relationships using: plot(cor_test(ROM_PF_left, "PF_LLLI","PF_LLSJ")) + theme_bw() I am trying to increase the marker size and color, but nothing seems to alter the marker size. I tried using "cex=3" but this was not effective. Are there any suggestions? I also tried creating another layer using "geom_point", which works, but if I change the alpha level, the dots from the original layer are visible. Correlation1

MarkKramer avatar May 09 '23 12:05 MarkKramer