freepizza
freepizza

Reputation: 1

How to create contour plot in R which with the color in each contour scaled separately by the density of all points within the contour

I am trying to create a contour plot in R in which all points in a certain contour are scaled according to the density inside that contour, not with respect to the density of all points in total. For example, I am trying to replicate a plot like this: https://docs.flowjo.com/flowjo/graphs-and-gating/data-visualization-and-display/gw-zebra/.

I am not sure where to proceed in doing so. If anyone could provide any advice, that would be greatly appreciated.

Upvotes: 0

Views: 139

Answers (1)

Vinícius Félix
Vinícius Félix

Reputation: 8811

Myabe this will hel you

Libraries

library(tidyverse)

Example Data

df <-
  tibble(
    x = rnorm(1000),
    y = rnorm(1000)
    )

Code

df %>% 
  ggplot(aes(x, y))+
  geom_density_2d_filled() 

Output

enter image description here

Upvotes: 0

Related Questions