I am trying to plot a hollow
bubble plot. The plot is fine except the legend is not showing the bubble size in the legend
. It can be seen in the legend the increment in the bubble
is not shown in legend.
How can I fix this?
I did look at this and this question, but it did not fix the legend.
Code + sample data
library(elevatr)
library(sf)
library(sp)
library(tidyverse)
# Create an example data.frame
set.seed(65.7)
examp_df = data.frame(x = runif(3, min = -73, max = -72.5), y = runif(3, min = 42,
max = 43))
prj_dd = "EPSG:4326"
# Create and example data.frame with additional columns
cats = data.frame(category = c("H", "M", "L"))
examp_df2 = data.frame(examp_df, cats)
# Create an example SpatialPoints
examp_sp = SpatialPoints(examp_df, proj4string = CRS(prj_dd))
# Create an example SpatialPointsDataFrame
examp_spdf = SpatialPointsDataFrame(examp_sp, data = cats)
# Get elevation data
spdf_elev_epqs = get_elev_point(examp_spdf, src = "epqs")
# Convert to sf object
examp_sfdf = st_as_sf(spdf_elev_epqs)
# Plot
ggplot() +
geom_sf(data = examp_sfdf, aes(size = elevation ), shape = 1, show.legend = T) +
coord_sf() +
theme(axis.text.x = element_text(angle = 90)) +
labs( size = "Mean Elevation (meters)")
Plot