I am trying to have a logarithmic scale for the color bar in R, any ideas on how I can do it?
My code:
TEST_DATAFRAME = read.table(TEST_FILE, sep="\t",skip=2, header=T)
PROD_DATAFRAME = read.table(PROD_FILE, sep="\t",skip=2, header=T)
PARAMETER = "Vf_High"
LST_RESIDUAL <- PROD_DATAFRAME[PARAMETER] - TEST_DATAFRAME[PARAMETER]
PARAM_DATAFRAME <- data.frame("NEW_MEASUREMENT" = TEST_DATAFRAME[PARAMETER], "OLD_MEASUREMENT" = PROD_DATAFRAME[PARAMETER], "RESIDUAL" = LST_RESIDUAL)
colnames(PARAM_DATAFRAME) <- c("NEW_MEASUREMENT","OLD_MEASUREMENT","RESIDUAL")
p <- plot_ly(PARAM_DATAFRAME, x = ~OLD_MEASUREMENT, y = ~NEW_MEASUREMENT, color=~RESIDUAL, colorscale = "Log",
hovertext = paste("<b>New Measurement :</b>", PARAM_DATAFRAME$NEW_MEASUREMENT,"<br><b>Old Measurement :</b>", PARAM_DATAFRAME$OLD_MEASUREMENT,"<br><b>Residual :</b>" , PARAM_DATAFRAME$RESIDUAL)) %>% add_markers()
#p <- layout(p, color = list(type = "log"))
p
this is my current output:
I also tried the following code:
TEST_DATAFRAME = read.table(TEST_FILE, sep="\t",skip=2, header=T)
PROD_DATAFRAME = read.table(PROD_FILE, sep="\t",skip=2, header=T)
PARAMETER = "Vf_High"
LST_RESIDUAL <- PROD_DATAFRAME[PARAMETER] - TEST_DATAFRAME[PARAMETER]
PARAM_DATAFRAME <- data.frame("NEW_MEASUREMENT" = TEST_DATAFRAME[PARAMETER], "OLD_MEASUREMENT" = PROD_DATAFRAME[PARAMETER], "RESIDUAL" = abs(LST_RESIDUAL))
colnames(PARAM_DATAFRAME) <- c("NEW_MEASUREMENT","OLD_MEASUREMENT","RESIDUAL")
brks <- pretty(range(PARAM_DATAFRAME$RESIDUAL))
gg <- ggplot(PARAM_DATAFRAME, aes(NEW_MEASUREMENT, OLD_MEASUREMENT, color = RESIDUAL)) +
geom_point() +
scale_colour_gradient(
low = "blue", high = "red",
trans = "log", breaks = brks, labels = brks) +
theme_minimal()
ggplotly(gg)
this is the result:
How can I give it legible labelling? I want to configure the color bar as the following: