0

I have monthly wise information of NDVI values by COUNTYNAME (35 counties) and by REGIONS (8regions)from 2002 to 2014. Below is the script to plot boxplot (x= COUNTYNAME and y=Dec) and facet_grid by REGIONS and order the boxplot by Median value of Dec. In the output plot, i want to make some changes such as

  1. Keep only the COUNTYNAME and the box plot which fall under the REGIONS and remove the rest. Eg. The number of COUNTYNAME fall in to REGIONS 1 is only 6. I want to remove the rest of the county information (both the x axis lables as well as the empty plot space).

  2. Plot a GRANDMEAN for the variable Dec

.

  ggplot(farmsndvilongitudinal, aes(x= reorder(COUNTYNAME, Dec, FUN=median), 
                                     y = Dec, color=factor(Regions)))+
             geom_boxplot()+ 
             theme(axis.text.x = element_text(angle = 90, hjust = 1))+
             geom_point(stat="summary", fun.y=mean, size=2.0, color='black')+ 
             facet_grid(~Regions)

enter image description here

Mohana
  • 1
  • 2
  • What is your question? – B001ᛦ Sep 05 '16 at 13:05
  • I want to simplify the plot... Remove the unwanted counties which doesnt have boxplot....Eg. Under the region1, the box plot is available for only 6 counties. I want the script to be modified such that by removing the all other counties under the region1... similarly with other regions as well – Mohana Sep 05 '16 at 13:10
  • `facet_grid(~Regions, scales = 'free_x', space = 'free_x')`? – Axeman Sep 05 '16 at 13:58
  • `+ geom_hline(yintercept = mean(farmsndvilongitudinal$Dec, na.rm = TRUE), lty = 2)` – Axeman Sep 05 '16 at 14:01
  • Yes, the global mean works for me... – Mohana Sep 05 '16 at 14:24
  • ggplot(data =subset(farmsndvilongitudinal,!is.na(Year)), aes(x= reorder(factor(COUNTYNAME), Dec, FUN=median), y = Dec, color=factor(Regions)))+ geom_boxplot()+ theme(axis.text.x = element_text(angle = 90, hjust = 1))+ geom_point(stat="summary", fun.y=mean, size=2.0, color='black')+ geom_hline(yintercept = mean(farmsndvilongitudinal$Dec, na.rm = TRUE), lty = 2)+ facet_grid(~Regions,space = "free_x",scales="free_x")This code works for me now.... Thanks Axeman – Mohana Sep 05 '16 at 14:38

0 Answers0