Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label on map: add color for a given factor #160

Open
priviere opened this issue Nov 18, 2021 · 0 comments
Open

label on map: add color for a given factor #160

priviere opened this issue Nov 18, 2021 · 0 comments
Labels
Agro Related to agro functions
Milestone

Comments

@priviere
Copy link
Owner

Example with cluster from bayesian gxe model

data_cluster = out_model_bh_GxE_vec_variables$out_parameter_groups_t$clust$clust
data_cluster$parameter = rownames(data_cluster)

vec_loc = vec_lat = vec_long = NULL
for(i in 1:nrow(data_cluster)){
  loc = unlist(strsplit(sub("theta\\[", "", as.character(data_cluster[i, "parameter"])), ":"))[1]
  vec_loc = c(vec_loc , loc)
  lat = data[which(data$location == loc), "lat"][1]
  vec_lat = c(vec_lat, lat)
  long = data[which(data$location == loc), "long"][1]
  vec_long = c(vec_long, long)
}
data_cluster$location = vec_loc
data_cluster$lat = vec_lat
data_cluster$long = vec_long

p = plot(data, plot_type = "map")
p = p$map + geom_nodelabel_repel(data = data_cluster, aes(x=as.numeric(long), y=as.numeric(lat), fill = clust, label=location))
p
@priviere priviere added the Agro Related to agro functions label Nov 18, 2021
@priviere priviere added this to the v2 milestone Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agro Related to agro functions
Projects
None yet
Development

No branches or pull requests

1 participant