Radar Charts: A Guide to Data Visualization with R

방사형 차트 - R 데이터 시각화
(R Data Visualization)

When you want to compare multiple variables, analyzing data with just numbers can often be overwhelming. This is where radar charts can be an excellent choice. Radar charts utilize multiple axes to visually represent data, and are especially useful when comparing characteristics or drawing patterns between different groups.

In this post, we'll use the RThe FMSB Packageto utilize the How to create a radar chartand how to effectively analyze and utilize data through radar charts.

What is a radar chart?

A radar chart is a graph that visualizes R data in the form of polygons along multiple axes.

  • Purpose of use: Relative comparisons or pattern analysis of multiple items.
  • Features
    • Each axis represents a variable (attribute).
    • Closer to the end of the axis means a higher value for that variable.
    • You can overlay multiple data sets to make comparisons between groups.

Radar charts can be used in a variety of areas, including analyzing survey results, comparing products, evaluating team performance, and more.

R Data Visualization: Leveraging the fmsb package

Code blocks

Below is the code for the R data visualization.

Install and load the # fmsb package
if (!requireNamespace("fmsb", quietly = TRUE)) {
  install.packages("fmsb") install # package if it doesn't exist
}
library(fmsb) load # package

# Data Generation and Dataframe Conversion
# Evaluation score for each item
res <- c(3, 4, 5, 3, 6, 5, 7, 4, 6, 7, 5, 5, 2, 3, 3, 3, 3)
mat <- matrix(res, byrow = TRUE, ncol = 8)
df <- as.data.frame(mat)
colnames(df) <- c("Performance", "Stability", "Usability", "Durability",
                  "Approachability", "Differentiation", "Reputation", "Pride")

Add # max and min values (to set the axis range of the radar chart)
df <- rbind(rep(7, 8), rep(1, 8), df)

Define the # color palette
library(scales)
fill_colors <- alpha(c("#FF6347", "#4682B4"), 0.4)

Draw the # radar chart
radarchart(
  df,
  axistype = 1,
  pcol = c("#FF6347", "#4682B4"),
  pfcol = fill_colors,
  plwd = 2,
  cglcol = "grey",
  cglty = 1,
  cglwd = 0.8,
  axislabcol = "black",
  vlcex = 1.2
)

Add a title for the #
title(main = "Radar Chart: Product Comparison",
      col.main = "black",
      font.main = 2,
      cex.main = 1.5)

Add the # legend
legend(
  x = 1, y = 0.8,
  legend = c("Product A", "Product B"),
  col = c("#FF6347", "#4682B4"),
  pch = 15,
  pt.cex = 2,
  cex = 1.2,
  bty = "n"
)

Code commentary

1. Install and load the FMSB package

if (!requireNamespace("fmsb", quietly = TRUE)) {
  install.packages("fmsb")
}
library(fmsb)
  • requireNamespace()using the fmsb Check to see if the package is installed, and if not, install and load it.

2. generate data

res <- c(3, 4, 5, 3, 6, 5, 7, 4, 6, 7, 5, 5, 2, 3, 3, 3, 3)
mat <- matrix(res, byrow = TRUE, ncol = 8)
df <- as.data.frame(mat)
  • Create evaluation scores as vectors (res), and then converted to a matrix (matrix) and converted to a dataframe (as.data.frame).

3. Set the axis range

df <- rbind(rep(7, 8), rep(1, 8), df)
  • Add a maximum value (7) and a minimum value (1) to each axis to define the range of the radar chart.

4. style the radar chart

radarchart(
  df,
  axistype = 1,
  pcol = c("#FF6347", "#4682B4"),
  pfcol = fill_colors,
  plwd = 2,
  cglcol = "grey",
  cglty = 1,
  cglwd = 0.8,
  axislabcol = "black",
  vlcex = 1.2
)
  • axistype: Set axis style.
  • pcol: Color the data lines.
  • pfcol: Set the translucent color of the data area.
  • cglcol: Set the color of the grid lines to gray.
  • vlcex: Resize axis labels.

5. add a legend and title

title(main = "Radar Chart: Product Comparison")
legend(x = 1, y = 0.8, legend = c("Product A", "Product B"), col = c("#FF6347", "#4682B4"))
  • Add titles and legends to make your graphs more intuitive.

Advantages of radar charts

레이더 차트 장점

1. compare data

  • Optimized for multidimensional data analysis
    Radar charts provide a visual representation of multiple attributes on one screen, allowing you to intuitively compare values between each item.
    • For example, you can simultaneously compare a product's performance, reliability, and price competitiveness to quickly identify where it excels and where it falls short.
    • At a glance, you can see how the characteristics of a particular group differ from other groups.

2. Discover patterns

  • Identify the strengths and weaknesses of your data
    The radial structure allows you to see scalability from the center of your data, giving you a clear view of your strengths and weaknesses.
    • Strengths: Values are displayed near the end of the axis, making them easy to see.
    • Weaknesses: Values close to the center of the axis, which are clearly visible.
  • Detect trends and anomalies
    With multiple data sets overlaid, you can discover groups with similar patterns, or visually detect outliers where certain data deviates from the pattern.

3. applicability

  • Wide range of applications
    Radar charts are extremely useful for comparing data and analyzing patterns, and have a wide range of applications, including
    • Compare productsComparing key characteristics between competing products to inform consumer or marketing strategy.
    • Analyzing surveysVisualize survey data to analyze respondents' preferences or satisfaction.
    • Evaluate team performanceVisually identify strengths and areas for improvement by comparing the performance of individual team members or across departments.
    • Decision supportAnalyzing the strengths and weaknesses of multiple alternatives to arrive at an optimal choice.
  • Enhance visual communication
    Communicating information through visual charts, rather than simply listing data as numbers, greatly improves communication efficiency.

4. aesthetic and intuitive presentation

  • Visually appealing
    Radar charts provide beautiful, modern visualizations that look like infographics and are highly readable in presentations and reports.
  • User-friendly
    It's a great tool for communicating complex data because the structure is easy to understand for those new to the data.

Finalize

In this post, we looked at the concept of radar charts and how to implement them with R. Radar charts are a powerful tool for intuitively showing patterns and relationships in your data. Modify your own data, tweak the styling, and create your own radar charts!

For reference, here's a visualization of Korea's painful history and the ongoing impeachment of the president in December 2024, along with past cases. In the spirit of not repeating history, I wrote it once. Impeachment history visualized using radar charts! Analyzing the impeachment of South Korea's president: R data visualization and historical lessons

Similar Posts