Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Understanding Layers and Syntax | section
Hands-On Data Visualization with ggplot2 in R

bookUnderstanding Layers and Syntax

Свайпніть щоб показати меню

The Grammar of Graphics is a powerful framework for building data visualizations, and ggplot2 brings this approach to R. Instead of thinking about plots as fixed charts, you build them by layering components: you start with your data, map variables to visual properties (called aesthetics), and then choose geometric objects to represent the data. This layered structure lets you build complex, customized graphics by combining simple parts.

12345
library(ggplot2) # Basic scatter plot with ggplot2 ggplot(data = mtcars, mapping = aes(x = wt, y = mpg)) + geom_point()
copy

In this code, you see how a ggplot2 plot is constructed by adding layers. The first layer specifies the data source with data = mtcars. The mapping = aes(x = wt, y = mpg) part defines the aesthetic mappings, telling ggplot2 which variables to plot on the x and y axes. The geom_point() layer adds points to the plot, representing each observation as a dot. This structure - data, aesthetics, and geometric object - is the foundation of every ggplot2 visualization.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 1
some-alt