Menu

Data Visualization with R: Charts, ggplot2 and Customization

Data Visualization with R

Creating Charts with Base R

Base R can draw charts with one short command.

  • hist() creates a histogram.
  • plot() creates a scatter plot.
  • barplot() creates a bar chart.
  • boxplot() creates a box plot.

These charts are fast and useful when you only want a quick look at your data. They are less attractive than ggplot2 charts, but they need no extra package.

Base charts are best for your own quick checks, while ggplot2 suits reports.

Introduction to ggplot2

The ggplot2 package builds a chart in layers. You start with the data, choose which columns go on each axis, and then add a shape, such as points or bars.

Each layer is joined with a plus sign (+). This layered idea makes it easy to change one part without redoing the whole chart.

Learning this pattern once lets you draw histograms, scatter plots, and box plots in the same way.

Customizing Charts and Visualizations

A good chart is clear without extra explanation.

  • Use the labs() function to add a title and axis names.
  • Change colors with fill and colour.
  • Apply a theme such as theme_minimal() for a clean look.
  • Save the chart as an image with ggsave() so you can place it in a report.

Keep colours simple and use no more than you need, so readers focus on the message.


R for Data Science

HA

Harini A



Learn via Video Course

Data Analysis and Processing with Python using Pandas - Data Science Course Logo

Data Analysis and Processing with Python using Pandas - Data Science Course

5 hrs



Get in Touch For Details