0

I have try to plot using the ggridges package. My code runs but the plot only shows white empty space. If I change the alpha values, I get

Picking joint bandwidth of NaN

Sample data


# Create the dataframe
sample <- data.frame(No = 0:4, nm = c(6217.276, 5087.43, 4512.67, 4990.639, 6504.022), nm1 = c(5922.943, 4700.321, 4194.645, 4496.32, 6140.53))

# Print the dataframe
sample

| No |     nm    |    nm1   | 
| 0  | 6217.276  | 5922.943 |
| 1  | 5087.43   | 4700.321 |
| 2  | 4512.67   | 4194.645 |
| 3  | 4990.639  | 4496.32  |
| 4  | 6504.022  | 6140.53  |

My code. I started by converting my data into long format:

sample_long <- pivot_longer(sample, cols = c(nm,nm1), names_to = "para")
sample_long %>%
  mutate(NoFct = fct_rev(as.factor(No))) %>%
  ggplot(aes(y = NoFct)) +
  geom_density_ridges(
    aes(x = value, fill= para), 
    alpha = .8
  )
megmac
  • 547
  • 2
  • 11
vigneshmoham
  • 1
  • 1
  • 3
  • To share your data, please use `dput(your_data_frame)` and paste the resulting code information into your question formatted as code. Depending on how large your data is, `dput(sample)` should return code that starts with `structure(...`. – chemdork123 May 17 '23 at 11:41
  • 1
    Does the [answer](https://stackoverflow.com/a/71987814/8449629) to a similar question have any relevance for you? – Z.Lin May 17 '23 at 13:23

0 Answers0