story4
install.packages(“plotly”)
library(tidyverse) library(plotly) library(viridis) library(ggridges) # Essential for clean distribution plots
1. DATA (Remains the same for Fidelity)
salary_data <- data.frame( state = c(“NY”, “CA”, “TX”, “WA”, “IL”, “MA”, “GA”, “FL”, “CO”, “VA”, “NJ”, “NC”), Data_Scientist = c(158000, 167000, 132000, 155000, 138000, 152000, 127000, 122000, 140000, 142000, 150000, 125000), Data_Engineer = c(148000, 159000, 128000, 150000, 131000, 145000, 121000, 118000, 135000, 137000, 142000, 120000), Data_Analyst = c(98000, 108000, 88000, 102000, 91000, 95000, 85000, 82000, 90000, 92000, 94000, 84000), Business_Analyst = c(92000, 101000, 84000, 95000, 88000, 90000, 81000, 78000, 86000, 88000, 90000, 80000) )
salary_long <- salary_data %>% pivot_longer(cols = -state, names_to = “Role”, values_to = “Salary”) %>% mutate(Role = str_replace_all(Role, “_“,” “))
2. NEW PROFESSIONAL VISUALS
— CHART 1: RIDGELINE PLOT (For Distribution) —
This replaces the messy histogram. It shows the “mountain peaks” of salary for each role.
plot_dist <- ggplot(salary_long, aes(x = Salary, y = Role, fill = Role)) + geom_density_ridges(alpha = 0.7, scale = 1.2, color = “white”) + scale_fill_viridis_d(option = “plasma”) + scale_x_continuous