Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ggradar graph doesn't look correct

I’m trying to make a spider/radar graph. Here’s my code:

structure(list(Acceptance = c(16, 4, 13), `Committed Action` = c(16, 
4, 11), Diffusion = c(16, 4, 7), `Present Moment` = c(16, 4, 
10), `Self as Context` = c(16, 4, 11), Values = c(16, 4, 12)), row.names = c(NA, 
-3L), class = c("tbl_df", "tbl", "data.frame"))

# DF Structure

Acceptance `Committed Action` Diffusion `Present Moment` `Self as Context` Values
       <dbl>              <dbl>     <dbl>            <dbl>             <dbl>  <dbl>
1         16                 16        16               16                16     16
2          4                  4         4                4                 4      4
3         13                 11         7               10                11     12

Many tutorials said that you should have first row as maximum and the second row as minimum. So that’s what I’ve done.

Now, I make the graph:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

radarchart(df, axistype=1,
           #custom polygon
           pcol=rgb(0.2,0.5,0.5,0.9), pfcol=rgb(0.2,0.5,0.5,0.5), plwd=4, 
           #custom the grid
           cglcol="grey", cglty=1, axislabcol="grey", caxislabels=seq(0,16,4), cglwd=0.8,
           #custom labels
           vlcex=0.8 
)

This is what I get:

Radar Graph Output

For instance, Diffusion = 7. But in the radar graph, the value is somewhere around "4" (the first polygon among the concentric polygons. Similarly, Values is 12 but the graph shows value less than 12. How do I correct this? What’s happening?

>Solution :

The issue is that you assigned wrong labels, i.e. the inner polygon corresponds to the minimum value of 4, while the outer polygon corresponds to the maximum value of 16. Hence, the correct labels are caxislabels = seq(4, 16, length.out = 5). Or as a second option (and perhaps the result you want to achieve) set the minimum value in your data to zero.

library(fmsb)

radarchart(df,
  axistype = 1,
  # custom polygon
  pcol = rgb(0.2, 0.5, 0.5, 0.9), pfcol = rgb(0.2, 0.5, 0.5, 0.5), plwd = 4,
  # custom the grid
  cglcol = "grey", cglty = 1, axislabcol = "grey",
  caxislabels = seq(4, 16, length.out = 5), 
  cglwd = 0.8,
  # custom labels
  vlcex = 0.8
)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading