piblo95
piblo95

Reputation: 347

Format RadarChart in R (title, subtitle and labels)

Here's the data:

df <- data.frame(Jan = 2230, Feb = 2420, Mar = 2833, Apr = 2192, May = 2332, Jun = 2577, Jul = 4363, Aug = 3747, Sep = 3176, Oct = 3988, Nov = 2144, Dec = 1896)
df <- rbind(4363, 0, df)

And here's the code to build the radar chart:

radarchart(df, 
           pcol = '#B62682', pfcol = alpha("#E1f56E", 0.7), plwd = 2, 
           axistype = 1, cglcol = "lightgrey", cglty = 1, 
           axislabcol = "black", cglwd = 1, caxislabels=seq(0, round(max(df[,1]), 0), round(max(df[,1])/8, 0)),
           calcex = 1, palcex = 1, vlcex = 1, seg = 7,
           title = "Title") 

radarchart

Ideally, I want to change the title's font size, add a subtitle and change the order of the labels (month labels should follow a clockwise direction). If this can't be done using radarchart(), I'm open to use other libraries. With ggplot() it would be super simple using labs() to add a title and subtitle and plot.title, plot.subtitle, etc to format.

Thanks in advance!

Upvotes: 0

Views: 3787

Answers (2)

piblo95
piblo95

Reputation: 347

Complete answer:

radarchart(df, 
           pcol = '#B62682', pfcol = alpha("#E1f56E", 0.7), plwd = 2, 
           axistype = 1, cglcol = "lightgrey", cglty = 1, axislabcol = "black", cglwd = 1, 
           caxislabels=seq(0, round(max(df[,1]), 0), round(max(df[,1])/8, 0)),
           calcex = 1, palcex = 1, vlcex = 1, seg = 7)

mtext(side = 3, line = 2.5, at = 0, cex = 1.75, "Title", font = 2)
mtext(side = 3, line = 1, at = 0, cex = 1.25, "Subtitle", col = '#666664')

line is for the height, cex works as the size of the text, at is the position (left - negative or right - positive, 0 center)

Upvotes: 2

Gutemberg Schiessl
Gutemberg Schiessl

Reputation: 86

The order actually are very simple. You can just change the order in the data

df <- data.frame(Jan = 2230, Feb = 2420, Mar = 2833, Apr = 2192, May = 2332, Jun = 2577, Jul = 4363, Aug = 3747, Sep = 3176, Oct = 3988, Nov = 2144, Dec = 1896)
df = df[, c(12,11,10,9,8,7,6,5,4,3,2,1)] # change the order
df <- rbind(4363, 0, df)

Insted of this title = "Title" you can use this for the title font size

title=("title", vlcex=0.5)

Upvotes: 0

Related Questions