简体   繁体   中英

facet_wrap: using x_free scale but having only 2 different x-axis with date

I performed on three sites in two different periods messurements. Now i want to show the results using facet_wrap. Here I want to have 2 columns (first line first period, secound line secound period) and each site in a row. To have only the respective dates in the respective graph, I use x_free, resulting in the desired graph. Now I would like to delete the X axis labels in the above graphs so that the date is only visible in the last graph.

My data looks like that: enter image description here

My code for the plots is this one:

test_data$date <- as.Date(test_data$date )

Boxes <- ggplot(test_data, aes(date, number_bats)) + 
  geom_col(aes(date,number_bats)) +
  facet_wrap(~Box, ncol = 2, scales = "free_x")

print(Boxes)

and the resulting graph looks like that: enter image description here

How can I now delete the dates in the first two graphs, but keep it in the last one? Thanks for your help!

I found this package "ggh4x" with an extended facet function (facet_grid2 and facet_wrap2) which solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM