bioRad icon indicating copy to clipboard operation
bioRad copied to clipboard

bioRad ggmap objects cannot be customized fully with ggplot

Open adokter opened this issue 5 years ago • 9 comments

adokter avatar Apr 09 '19 09:04 adokter

@adokter can you be more precise about which plotting methods or when this happens?

For the plot.scan method:

library(bioRad)
library(ggplot2)

data(example_scan)
myplot <- plot(example_scan, param = "DBZH") + 
  theme_bw()
myplot

image

Similar to plotting ppi:

data(example_scan)
ppi <- project_as_ppi(example_scan)
myplot <- plot(ppi)+  
  theme_bw()
myplot

Notice:

The output of plot.vp, plot.vpi and plot.vpts are not ggplot objects.

stijnvanhoey avatar Apr 09 '19 10:04 stijnvanhoey

I was thinking specifically of changing the color palette of the plot, which is problematic. i.e. I can't add a statement + scale_fill_gradientn( ....) to change to color gradient

adokter avatar Apr 09 '19 10:04 adokter

color gradients are defined here

adokter avatar Apr 09 '19 10:04 adokter

ok, this works for me (please, no comments on color choice ;-)):

# plot scan
data(example_scan)
myplot <- plot(example_scan, param = "DBZH") + 
  scale_fill_gradientn(
    colours = c(
      "black", "grey",
      "blue", "darkblue", "green",
      "orange"
    )
  )
myplot

image

You get a warning about the overwriting of an existing color scale though:

Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale.

but that is just informative

stijnvanhoey avatar Apr 09 '19 10:04 stijnvanhoey

Really ugly colors though

CeciliaNilsson709 avatar Apr 09 '19 10:04 CeciliaNilsson709

The problem occurs only with ggmapping, not ggplotting:

my_ppi=project_as_ppi(example_scan)
my_map=basemap(my_ppi)
map(my_ppi,my_map) + scale_fill_gradientn(
    colours = c(
      "black", "grey",
      "blue", "darkblue", "green",
      "orange"
    )
  )

ggmap_plot

adokter avatar Apr 09 '19 12:04 adokter

map command for ppi's is coded here. Could the suppressWarnings() statement cause the problem?

adokter avatar Apr 09 '19 12:04 adokter

maybe related to this

stijnvanhoey avatar Apr 09 '19 13:04 stijnvanhoey

The problem is that we use inset_raster to overlay the data on the map. inset_raster requires the datapoints to be already hex color values. Therefore in bioRad::map the data are converted to hex values, after which they can't be modified anymore

Seems to address this we need a different solution than inset_raster that is equally fast (preferably faster).

adokter avatar Feb 18 '20 21:02 adokter