Published: 13 Oct 2025 › Updated: 13 Oct 2025

Density Plot Tutorial in R
Hey everyone, I wanted to share this density plot tutorial that I recently created. I also provided sample code that you can use to follow along with or to modify if you want to change the colors or labels.
install.packages("tidyverse")
library(tidyverse)
head(diamonds)
ggplot(data = diamonds,
aes(x = price, fill = cut))+geom_density()+
labs(title = "Diamond Price",
x = "Price",
y = "Density",
fill = "Legend")+
theme(
plot.title = element_text(hjust = .5, color = "hotpink"),
panel.background = element_rect(fill = "black"),
plot.background = element_rect(fill = "black"),
axis.title = element_text(color = "hotpink"),
axis.text = element_text(color = "hotpink"),
legend.background = element_rect(fill = "black", color = "white"),
legend.text = element_text(colour = "white"),
legend.title = element_text(color = "white")
)+coord_cartesian(
xlim = c(0,10000),
ylim = c(.0001,.0003)
)
Leave Density Plot Tutorial in R to:
Read more #stem posts
Best Posts From Amber K
We have not curated any of algoswithamber's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Amber K
- Moments That Made Me a Better Splinterlands Player
- Splinterlands Winterfest Gift Box Opening!!🎁
- The Path to Power in Splinterlands 💪
- Finally Got a Grove Doomblade...in GOLD!!
- Splinterlands Arena Architect - Choosing the Winning Strategy!!⚔️ 🛡️
- Splinterlands Card Spotlight: A'lan Musketeer🏹
- Splinterlands Modifier Mastery 🧙♀️🔮⚔️
- Splinterlands Match Analysis ⚔️🔥💥
- Splinterlands Harvest Heroes - The Cards and Community that Make The Game Great!
- Splinterlands Strategy: Double Strike + Poison 🧪☠️