plot - R - color key for a scatterplot -


i'm working in r , creating 3-variable scatter plot, x , y corresponding position, , color given z.

however, due specifics of project, couldn't use existing color palette, , instead wrote function directly converting data rgb values.

i'm able graph way want (the colors correct), don't know how create suitable color key.

assuming i've done processing want do, , have data structure column 1 x value, column 2 y value, column 3 rgb value want color of point, , column 4 score used generate color hex value of given point, how best display scatter plot color key?

i want key cover entire color range , go 0 max score.

the scores (column 4) don't need in graph - used assign color hex values, , determine range of color key.

here simple example of how work colour palettes , maps using spatstat , plotrix:

library("spatstat") ; library("plotrix")  #your data: x <- 1:3 # colours included colors <- c("#ff0000" , "#00ff00" , "#0000ff") n.colors <- 100 # number of colours interpolate on  plot(1:3 , col = colors , pch = 16)  # interpolate colours: palette <- colorramppalette(colors, space = "rgb")(n.colors) color.map <- colourmap( palette , range=range(x) ) color.range <- color.map( seq(min(x), max(x), length.out = n.colors) )  #the labels of legend col.labels <- round(seq(min(x),max(x),length=3) ,digits=1) color.legend( xl =2.5 , yb = 1, xr = 2.7, yt = 2 , # coordinates               legend = col.labels , gradient="y",                rect.col=color.range, align="rb") 

enter image description here


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -