Creating Scatter Plots
Why Use Scatter Plots?
A scatter plot is ideal for:
-
Visualizing relationships between two numerical variables;
-
Detecting patterns, clusters, or outliers;
-
Exploring correlation (positive/negative/none).
Basic Syntax for Scatter Plots in ggplot2
ggplot(data = df, aes(x = variable_x, y = variable_y)) +
geom_point()
To add group-based color, use: aes(x, y, color = group_var)
Example: Selling Price vs Kilometers Driven
ggplot(df, aes(x = km_driven, y = selling_price)) +
geom_point() +
labs(title = "Scatter Plot of Selling Price vs. Kilometers Driven",
x = "Kilometers Driven",
y = "Selling Price")
This shows how a car’s usage relates to its price — often revealing depreciation trends.
Danke für Ihr Feedback!
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Can you explain how to interpret a scatter plot?
What does a negative correlation mean in this context?
How can I identify outliers in a scatter plot?
Awesome!
Completion rate improved to 4
Creating Scatter Plots
Swipe um das Menü anzuzeigen
Why Use Scatter Plots?
A scatter plot is ideal for:
-
Visualizing relationships between two numerical variables;
-
Detecting patterns, clusters, or outliers;
-
Exploring correlation (positive/negative/none).
Basic Syntax for Scatter Plots in ggplot2
ggplot(data = df, aes(x = variable_x, y = variable_y)) +
geom_point()
To add group-based color, use: aes(x, y, color = group_var)
Example: Selling Price vs Kilometers Driven
ggplot(df, aes(x = km_driven, y = selling_price)) +
geom_point() +
labs(title = "Scatter Plot of Selling Price vs. Kilometers Driven",
x = "Kilometers Driven",
y = "Selling Price")
This shows how a car’s usage relates to its price — often revealing depreciation trends.
Danke für Ihr Feedback!