Get Started →
FREE DATA VIZ TOOL

What Chart

Should I Use?

Find the right chart for your data. Filter by analytical goal or data type, then grab the ggplot2 code. 25 chart types with R examples.

WHAT DO YOU WANT TO SHOW?
WHAT TYPE OF DATA DO YOU HAVE?
24 charts found
Bar Chart geom_col() / geom_bar()

Compares values across discrete categories using rectangular bars proportional to values.

ComparisonRanking CategoricalNumerical
BEST FOR
  • · Comparing quantities across categories
  • · Showing rankings
  • · Survey results
  • · Discrete value comparison
VARIABLES

1 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · More than 20 categories
  • · Continuous x-axis data
  • · Showing trends over time
Horizontal Bar Chart geom_col() + coord_flip()

Horizontal bars ideal for long labels, many categories, or ranked/sorted data.

ComparisonRanking CategoricalNumerical
BEST FOR
  • · Many categories (10-30)
  • · Long category labels
  • · Top-N lists
  • · Ranked data
VARIABLES

1 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Very few categories
  • · Time-series data
Grouped Bar Chart geom_bar(position = "dodge")

Clusters of bars comparing sub-groups within each category side by side.

Comparison CategoricalNumerical
BEST FOR
  • · Comparing sub-groups within categories
  • · Side-by-side group comparison
  • · 2-4 sub-groups
VARIABLES

2 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · More than 4-5 sub-groups
  • · When total per category matters more
Stacked Bar Chart geom_bar(position = "stack")

Bars divided into segments showing total value and its composition by sub-groups.

CompositionComparison CategoricalNumerical
BEST FOR
  • · Part-to-whole within categories
  • · Total and breakdown simultaneously
  • · 2-5 segments per bar
VARIABLES

2 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Comparing individual sub-group values across categories
  • · More than 6 segments
Line Chart geom_line()

Connected data points showing changes over a continuous or ordered dimension, usually time.

Trend Time SeriesNumerical
BEST FOR
  • · Trends over time
  • · Comparing multiple series
  • · Continuous data patterns
  • · Forecasting context
VARIABLES

1 temporal + 1-7 numerical series

PACKAGE

ggplot2

AVOID WHEN
  • · Categorical/unordered x-axis
  • · Fewer than 4 data points
  • · Unconnected discrete categories
Area Chart geom_area()

Line chart with filled area beneath, emphasizing volume and magnitude of change over time.

TrendComposition Time SeriesNumerical
BEST FOR
  • · Emphasizing magnitude of change
  • · Cumulative totals over time
  • · Volume under a trend
VARIABLES

1 temporal + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Multiple overlapping series
  • · Precise value reading is critical
Scatter Plot geom_point()

Points plotted on two axes showing the relationship between two continuous variables.

Relationship Numerical
BEST FOR
  • · Correlation analysis
  • · Identifying clusters
  • · Detecting outliers
  • · Bivariate exploration
VARIABLES

2 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Categorical data on either axis
  • · Fewer than 10 data points
  • · Time-series trend
Bubble Chart geom_point(aes(size = ...))

Scatter plot with a third variable encoded as bubble size, showing 3+ variable relationships.

Relationship Numerical
BEST FOR
  • · 3-variable relationship
  • · Adding size dimension to correlation
  • · Moderate data points (10-100)
VARIABLES

3 numerical + optional categorical (color)

PACKAGE

ggplot2

AVOID WHEN
  • · Too many data points
  • · Small size differences
  • · Precise size comparison needed
Histogram geom_histogram()

Frequency distribution of a continuous variable grouped into bins, showing distribution shape.

Distribution Numerical
BEST FOR
  • · Understanding distribution shape
  • · Identifying skewness
  • · Finding outliers
  • · Assessing spread
VARIABLES

1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Categorical data
  • · Very small samples (under 20)
  • · Comparing many groups simultaneously
Density Plot geom_density()

Smoothed continuous curve estimating the probability distribution of a variable.

Distribution Numerical
BEST FOR
  • · Comparing 2-4 distribution shapes
  • · Smoother alternative to histogram
  • · Continuous data shape analysis
VARIABLES

1 numerical, 1-4 groups

PACKAGE

ggplot2

AVOID WHEN
  • · Discrete/categorical data
  • · Very small samples
  • · When exact bin counts matter
Box Plot geom_boxplot()

Shows median, quartiles, range, and outliers as a compact distribution summary.

DistributionComparison CategoricalNumerical
BEST FOR
  • · Comparing distributions across groups
  • · Identifying outliers
  • · Compact summary
  • · 3-20 groups
VARIABLES

1 numerical + 0-1 categorical

PACKAGE

ggplot2

AVOID WHEN
  • · Non-technical audience
  • · When distribution shape matters (bimodality hidden)
  • · Very small samples
Violin Plot geom_violin()

Combines box plot with kernel density, showing the full shape of the distribution.

Distribution CategoricalNumerical
BEST FOR
  • · When distribution shape matters
  • · Detecting bimodality
  • · Richer alternative to box plot
VARIABLES

1 numerical + 0-1 categorical

PACKAGE

ggplot2

AVOID WHEN
  • · Very small samples
  • · Non-technical audience
  • · Too many groups (10+)
Pie Chart geom_col() + coord_polar("y")

Circular chart divided into slices representing proportions of a whole.

Composition CategoricalProportional
BEST FOR
  • · Simple part-to-whole (2-5 slices)
  • · Highlighting a dominant category
  • · Rough proportions
VARIABLES

1 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · More than 6 categories
  • · Comparing similar-sized slices
  • · Values not summing to a whole
  • · Precise comparison needed
Heatmap geom_tile()

Matrix of values encoded as colors showing patterns across two dimensions.

RelationshipComparison CategoricalNumerical
BEST FOR
  • · Correlation matrices
  • · Two-dimensional patterns
  • · Time-of-day/day-of-week patterns
  • · Large numeric tables
VARIABLES

2 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Precise values needed
  • · Few data points
  • · Color-blind accessibility concerns
Treemap geom_treemap()

Nested rectangles showing hierarchical part-to-whole relationships sized by value.

Composition HierarchicalCategoricalNumerical
BEST FOR
  • · Hierarchical composition
  • · Many categories (where pie chart fails)
  • · Relative sizes
  • · Portfolio allocation
VARIABLES

1-3 categorical levels + 1 numerical

PACKAGE

treemapify

AVOID WHEN
  • · Non-hierarchical data
  • · Precise comparison of similar sizes
  • · Too many nesting levels
  • · Negative values
Lollipop Chart geom_segment() + geom_point()

Dot connected to axis by a thin line. Cleaner alternative to bar chart for many categories.

ComparisonRanking CategoricalNumerical
BEST FOR
  • · Many categories with less clutter
  • · Ranked data visualization
  • · Feature importance scores
VARIABLES

1 categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Very few categories
  • · When filled bar weight conveys meaning
Waterfall Chart geom_rect()

Shows how an initial value changes through sequential positive and negative contributions.

CompositionFlow / Process CategoricalNumerical
BEST FOR
  • · Financial bridge analysis
  • · Revenue-to-profit walkdown
  • · Variance analysis
  • · Incremental changes
VARIABLES

1 categorical (steps) + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Non-sequential data
  • · Too many steps (15+)
  • · When running total is meaningless
Ridgeline Plot geom_density_ridges()

Stacked overlapping density plots showing distribution changes across groups.

Distribution CategoricalNumerical
BEST FOR
  • · Comparing distributions across many groups
  • · Distribution shifts over time
  • · Visually striking comparisons
VARIABLES

1 numerical + 1 categorical/ordinal

PACKAGE

ggridges

AVOID WHEN
  • · Very few groups
  • · Precise distribution comparison needed
  • · Non-technical audience
Funnel Chart geom_col() + coord_flip()

Progressive narrowing showing drop-off through sequential stages of a process.

Flow / ProcessComparison CategoricalNumerical
BEST FOR
  • · Conversion funnels
  • · Pipeline analysis
  • · Process drop-off
  • · 3-8 sequential stages
VARIABLES

1 ordered categorical + 1 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · Non-sequential processes
  • · Values increasing at later stages
  • · More than 8 stages
Dumbbell Chart geom_segment() + geom_point()

Two points per category connected by a line, showing before/after or gap between two values.

Comparison CategoricalNumerical
BEST FOR
  • · Before/after comparisons
  • · Gap analysis between two values
  • · Period-over-period change
VARIABLES

1 categorical + 2 numerical

PACKAGE

ggplot2

AVOID WHEN
  • · More than 2 comparison points
  • · Very few categories
  • · When absolute values matter more than gap
Correlation Matrix geom_tile() + geom_text()

Grid displaying pairwise correlations among many numeric variables at a glance.

Relationship Numerical
BEST FOR
  • · Exploring variable relationships
  • · Feature selection
  • · Multicollinearity detection
VARIABLES

3+ numerical variables

PACKAGE

ggplot2 + reshape2

AVOID WHEN
  • · Non-numeric data
  • · Very few variables
  • · When causation matters more than correlation
Candlestick Chart geom_candlestick()

Shows open, high, low, close prices per time period for financial instruments.

Trend Time SeriesNumerical
BEST FOR
  • · Stock/commodity price analysis
  • · Price range and direction
  • · Technical analysis
VARIABLES

1 temporal + 4 numerical (OHLC)

PACKAGE

tidyquant

AVOID WHEN
  • · Non-financial data
  • · Audience unfamiliar with financial charts
  • · When only closing price matters
Stacked Area Chart geom_area(position = "stack")

Multiple area series stacked to show how components contribute to a total over time.

TrendComposition Time SeriesCategoricalNumerical
BEST FOR
  • · Composition changes over time
  • · Component contributions to total
  • · 2-6 category series
VARIABLES

1 temporal + 1 numerical + 1 categorical

PACKAGE

ggplot2

AVOID WHEN
  • · Reading individual series values precisely
  • · More than 7 categories
  • · Vastly different scales
Slope Chart geom_segment() + geom_point() + geom_text()

Shows change between exactly two time points or conditions per category.

ComparisonTrend CategoricalNumerical
BEST FOR
  • · Before/after comparison for multiple groups
  • · Ranking changes between two periods
  • · Period-over-period shifts
VARIABLES

1 categorical + 2 numerical (start/end)

PACKAGE

ggplot2

AVOID WHEN
  • · More than 2 time points
  • · Too many categories (lines overlap)
  • · When absolute value matters more than change

CHARTS BY QUESTION

Not sure what chart to use? Find your question below.

"I want to compare values across categories"

If your data has categories on one axis and numbers on the other, you need a comparison chart. The right one depends on how many categories and whether you have sub-groups.

"I want to show how something changes over time"

If your x-axis is dates, months, years, or any ordered time dimension, you need a trend chart. Choose based on whether you care about the trajectory, the volume, or the composition.

"I want to see how my data is distributed"

If you have one numerical variable and want to understand its shape — is it normal? skewed? bimodal? where are the outliers? — you need a distribution chart.

"I want to find the relationship between variables"

If you want to answer "does X correlate with Y?" or "which variables are related?", you need a relationship chart.

"I want to show parts of a whole"

If your data represents percentages, proportions, market share, or budget allocation, you need a composition chart. The right one depends on how many categories and whether you have hierarchy.

"I want to show a process or pipeline"

If your data represents sequential stages with drop-off — like a sales pipeline, conversion funnel, or user flow — you need a flow chart.

HOW TO CHOOSE THE RIGHT CHART

Start with your analytical goal

The most common mistake is picking a chart type first and forcing your data into it. Instead, ask: what question am I answering? Are you comparing values across categories? Showing a trend over time? Exploring the distribution of a variable? Revealing the relationship between two measures? Once you know the goal, the right chart family becomes obvious.

Match your data type

Categorical data (country, product, department) pairs naturally with bar charts and grouped bars. Numerical data works with histograms, scatter plots, and density plots. Time-series data calls for line charts, area charts, and candlestick charts. Proportional data that sums to a whole uses pie charts or treemaps.

The ggplot2 advantage in R

R's ggplot2 library uses a grammar of graphics where you build charts layer by layer. Every chart on this page maps to a specific geom_* function. Once you learn the pattern — ggplot(data, aes(x, y)) + geom_*() — switching between chart types is just swapping the geom function. This makes R one of the most flexible tools for data visualization.

What chart for categorical vs numerical data?

One categorical + one numerical: bar chart, lollipop chart, or horizontal bar. Two categorical + one numerical: grouped bar, stacked bar, or heatmap. Two numerical: scatter plot. Three numerical: bubble chart. One numerical only: histogram, density plot, or box plot. Time + numerical: line chart, area chart. Proportional: pie chart, treemap, stacked bar (100%).

Quick reference table

GoalBest chart typesKey geom
ComparisonBar, grouped bar, lollipop, dumbbellgeom_col()
TrendLine, area, stacked area, candlestickgeom_line()
DistributionHistogram, density, box plot, violin, ridgelinegeom_histogram()
RelationshipScatter, bubble, heatmap, correlation matrixgeom_point()
CompositionPie, stacked bar, treemap, waterfallgeom_col(position="stack")
Ranking / FlowHorizontal bar, lollipop, funnel, slopegeom_segment()

FREQUENTLY ASKED QUESTIONS

What graph should I use for comparing two groups?

For comparing two groups, a grouped bar chart places bars side by side for direct comparison. A dumbbell chart is ideal for before/after or plan-vs-actual comparisons, showing the gap between the two values.

When should I use a bar chart vs a line chart?

Use bar charts for comparing discrete categories (countries, products, departments). Use line charts for showing trends over a continuous axis, typically time. If your x-axis is ordered and continuous, a line chart communicates the trajectory. If it's categorical, bars are more appropriate.

What chart do I use for percentage data?

For percentages that sum to 100%: pie chart (2-5 categories), stacked bar chart (comparing across groups), or treemap (many categories). For percentages that change over time, use a stacked area chart.

Should I ever use a pie chart?

Pie charts work well with 2-5 slices that represent parts of a whole, especially when one category dominates. For more categories or precise comparison between similar values, bar charts or treemaps are better. Despite their bad reputation, simple pie charts remain effective for high-level executive summaries.

What chart shows correlation between variables?

Scatter plots show correlation between two variables. For three variables, use a bubble chart. To see correlations among many variables at once, use a correlation matrix.

How many data points do I need for a meaningful chart?

It depends on the chart type. Histograms and density plots need at least 20-30 observations to show a meaningful distribution. Scatter plots need 10+ points to reveal patterns. Bar charts work with any number of categories. Line charts need at least 4-5 time points to show a trend.

What's the best chart for financial data?

For stock prices: candlestick charts (OHLC data). For revenue analysis: waterfall charts (showing incremental changes). For portfolio allocation: treemaps. For time-series financial metrics: line charts with area fills. For break-even analysis, try our Break-Even Chart Generator.

What chart for survey data?

For single-response questions: bar chart or horizontal bar chart for ranked results. For Likert scale data: stacked bar chart. For comparing survey results across demographics: grouped bar chart. For "select all that apply" questions: horizontal bar sorted by frequency.

What chart for showing outliers?

Box plots explicitly mark outliers as individual points beyond the whiskers. Scatter plots make outliers visible as isolated points far from the cluster. Histograms show outliers as isolated bars in the tails.

CREATE CHARTS IN R

Run ggplot2 code instantly.

RChat runs R directly in your browser. Paste any ggplot2 code from this page, tweak it with AI assistance, and see the chart rendered instantly.

Free tokens on signup · No credit card required