This section is tightly linked with other sections. A line chart is the same but doesn't fill the surface between the line and the X axis. A connected scatterplot is almost the same thing, but each observation is represented as a dot. More generally, the time series section can interest you.connected scatter line chart time series
ggplot2 allows to draw line charts thanks to the
geom_line() function. It expects as input a data frame with 2 numeric variables, one displayed on each axis. Start your journey with the most basic line chart.
Most basic stacked area chart you can build with R and ggplot2, using the geom_area function.
Small multiple is probably the best alternative, making obvious the evolution of each gropup.
Area chart with gradient color
With ggpattern, it's now possible to have not just one color, but a gradient of colors.
Transparent gradient color
Here's how to combine a color gradient and transparency against the background in an area chart.
ggplotly() function of the
plotly library makes it a breeze to build an interactive version. Try to hover circles to get a tooltip, or select an area of interest for zooming. Double click to reinitialize.
dygraph package is dedicated to time series visualization. It offers zooming, hovering, minimaps and much more. Visit the time series section that is dedicated to it for more.
In base R, the combination of the
plot() and the
polygon() functions allows to build quality area charts.
The web is full of astonishing R charts made by awesome bloggers. The R graph gallery tries to display some of the best creations and explain how their source code works. If you want to display your work here, please drop me a word or even better, submit a Pull Request!
Line chart with labels
It is a common need to display labels at the end of the lines, since that's the place where labels are the more readable. Cédric Scherer gives us a nice walk-through here on how to do it with ggplot2.
Line chart with filled intersection
This example uses geo-faceting: the dataset is split and plotted using geographical regions. For each charts, 2 lines are displayed and the intersection between both is filled.
Stacked area chart with clean labels
A stacked area chart with a stunning color palette, some well positioned inline labels, some handy vertical annotations and some clean caption text.