I am fairly new to R and I am working on a radar plot with multiple y-values and facets. I want to create three seperate radar plots out of my dataframe instead of just one, depending on the location of my points. When I filter my df according to the points I want, it is not displayed with the correct values.
p.tot <- ggRadar(df.Plot.PI.total, mapping = aes(colour = scenario, facet = PlotNames),
size=3, alpha = 0, ylim = c(1,1))+
theme_bw()+
scale_color_manual(name="Scenario", values = cbPalette.PI)+
scale_fill_manual(values = cbPalette.PI, name="Scenario")+
labs(title = "Changes in Protection Indexes")+
theme(plot.title = element_text(size = 20,face = "bold"),
strip.text.x = element_text(size = 14),
legend.title = element_text(face="bold",size = 18), legend.text = element_text(size = 16),
legend.position = "bottom",
text = element_text(size=18),
axis.text = element_text(size=14),axis.title = element_text(size=14))
Plotting the whole df worked fine. For my work I want to plot three different plots, one for each group of points. So I applied a filter to the df to only plot the points of interest.
df.Plot.PI.SUB <- df.Plot.PI.total %>% filter(str_detect(PlotNames, "SUB_"))
When I plot the shortened data however, some points in the radarplots are not displayed correctly, even though the data is still the same!
Can somebody tell how to solve this problem? Thanks a lot!
The issue is that
ggRadar
by default rescales all continuous variables in the dataset (see?ggRadar
):As the rescaling depends on the data provided you will get a different result when subsetting your data. To fix that rescale your data manually and set
rescale=FALSE
.As you provided no example data I created a minimal reprex based on mtcars.
First I reproduce your issue with the default rescaling. Here we get different plots when dropping the
cyl=8
values.But when setting
rescale=FALSE
we get the same radar charts forcyl=4
andcyl=6
: