0

I am trying to plot taylor diagram for each data.frame (i.e., Precipitation, Max_Temp, and Min_temp) on same figure. Each data.frame have a ref observation and model outputs represented by (A1,G2, and G3). Any help would be appreciated.

library(tidyverse)
library(plotrix)

set.seed(123)

precipitation <- data.frame(Ref = runif(730,1,5), A1 = runif(730,0,8), G2 = runif(730,2,6), G3 = runif(730,1,7)) 
Max_Temp <-  data.frame(Ref = runif(730,-5,30), A1 = runif(730,-8,32), G2 = runif(730,-2,28), G3 = runif(730,-10,25))
Min_Temp <-  data.frame(Ref = runif(730,-20,5), A1 = runif(730,-25,10), G2 = runif(730,-25,6), G3 = runif(730,-15,10))

I tried the code to just draw the diagram for precipitation but am getting error.

precipitation %>% 
  pivot_longer(names_to = "Models", values_to = "values", -Ref) %>% 
  taylor.diagram(Ref, values, col = Models)

I would like to have a Figure like below enter image description here

Hydro
  • 1,057
  • 12
  • 25

1 Answers1

0

I'm not sure that your sample data will produce a plot like you expect, but you could try filtering your dataframe for each model and overlay the points on the same plot with the add = TRUE option. Also, I think the explosion pipe will help (%$%), and I just learned it's actually called the 'exposition pipe' in the docs:

library(tidyverse)
library(plotrix)
library(magrittr)

set.seed(123)
precipitation <- data.frame(Ref = runif(730,1,5), A1 = runif(730,0,8), G2 = runif(730,2,6), G3 = runif(730,1,7)) 
Max_Temp <-  data.frame(Ref = runif(730,-5,30), A1 = runif(730,-8,32), G2 = runif(730,-2,28), G3 = runif(730,-10,25))
Min_Temp <-  data.frame(Ref = runif(730,-20,5), A1 = runif(730,-25,10), G2 = runif(730,-25,6), G3 = runif(730,-15,10))

precipitation %>% 
  pivot_longer(names_to = "Models", values_to = "values", -Ref) %>% 
  filter(Models == "A1") %$%
  taylor.diagram(Ref, values, col = "blue", pch = 1)

precipitation %>% 
  pivot_longer(names_to = "Models", values_to = "values", -Ref) %>% 
  filter(Models == "G2") %$%
  taylor.diagram(Ref, values, col = "red", pch = 2, add = TRUE)

precipitation %>% 
  pivot_longer(names_to = "Models", values_to = "values", -Ref) %>% 
  filter(Models == "G3") %$%
  taylor.diagram(Ref, values, col = "green", pch = 3, add = TRUE)

example_2.png

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46