Based on the code and data below how can I get an output similar to the desired output?
Current output:
2D output:
Desired 3D output (obtained from here):
Code + data:
library(tidyverse)
library(maps)
library(rayshader)
# Read the state population data
StatePopulation = read.csv("https://raw.githubusercontent.com/ds4stats/r-tutorials/master/intro-maps/data/StatePopulation.csv", as.is = TRUE)
# Plot all states with ggplot2, using black borders and light blue fill
# Load United States state map data
MainStates = map_data("state")
# Use the dplyr package to merge the MainStates and StatePopulation files
MergedStates = inner_join(MainStates, StatePopulation, by = "region")
MainCities = filter(us.cities, long >= -130)
# 2D
g = ggplot()
g = g + geom_polygon(data = MergedStates,
aes(x = long,
y = lat,
group = group,
fill = population/1000000),
color = "black",
size = 0.2) +
scale_fill_continuous(name = "State Population",
low = "lightblue",
high = "darkblue",
limits = c(0,40),
breaks = c(5,10,15,20,25,30,35),
na.value = "grey50") +
labs(title="Population (in millions) in the Mainland United States")
g_pt = g + geom_point(data = MainCities,
aes(x = long,
y = lat,
size = pop/1000000),
color = "gold",
alpha = .5) + scale_size(name = "City Population")
# 3D
plot_gg(g_pt,
raytrace = TRUE,
multicore = TRUE,
width = 5,
height = 3,
scale = 310)