I recently discovered the geofacet package in R. Amazing. I have 5 years worth of data for each state. I have horizontal bars in each facet. I am trying to figure out how to add a simple label that shows the value of each bar in each graph such that it sits off to the right of the bar or right side of the facet. I have tried geom_text and a number of code lines but nothing seems to add the labels for each bar in each facet.
Below is my code to make the geofacet of the US. Not sure where to add the label code either.
Any help is greatly appreciated. This is my last step to complete this awesome map.
ggplot(Alabamatest, aes(YEAR, SALES, fill = YEAR)) +
geom_bar(alpha=1, width = .75,
aes(color =TYPE, fill=TYPE),
stat = "identity", position = position_stack(reverse = TRUE)
) +
scale_color_manual(values = c("firebrick1", "cornflowerblue"))+
scale_fill_manual(values = c("firebrick1", "cornflowerblue"))+
ylim(0,9
)+
coord_flip() +
theme_bw()+
facet_geo(~ state, grid= "us_state_grid4", label ="SALES")+
scale_y_continuous(expand = c(0, 0)) +
labs(title = "2019 State Average Sales",
caption = "Data Source: Year End Data",
x = NULL,
y = "Percentage of Voters") +
theme(axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
strip.text.x = element_text(size = 6))
I am adding some test data to run with the code. I am not sure how to add a simple data frame so I have typed it out here. I am brand new to Stackoverflow. Apologies if this is not the correct way to present data
state name YEAR SALES TYPE
AL ALABAMA 2019 2 POS
AL ALABAMA 2018 1.5 POS
AL ALABAMA 2017 1.4 NEG
AL ALABAMA 2016 1.7 NEG
AZ ARIZONA 2019 3 POS
AZ ARIZONA 2018 3 POS
AZ ARIZONA 2017 2 POS
AZ ARIZONA 2016 3.4 POS
AZ ARIZONA 2015 5 POS
The two states create bar graphs. I want to be able to add the sales label to the right side of the bar graph for each year.