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)
  )


0
0
0.000
1 comments
avatar

Congratulations @algoswithamber! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 3750 upvotes.
Your next target is to reach 4000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

0
0
0.000