2

I am trying to remove the borders on this data viz. Here is my current code:

ggplot(data = GDP, aes(x=year, y=gdp_percap/1e3, fill=continent)) + 
geom_col() + 
 facet_wrap(~continent, ncol=2) + 
 ylab("GDP") + 
  theme_minimal() + 
  theme(legend.position = "none",
  panel.background = element_rect(fill=NA, color="gray50"),
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.border = element_blank())
  strip.background = element_rect(fill=NA, color=NA) +
scale_y_continuous(expand = expand_scale(mult = c(0, 0.05)),
breaks = seq(0,200,100),limits=c(0,NA)) +
scale_x_continuous(expand = c(0,0),
breaks = seq(1950,2000,20))

GDP-data

enter image description here

Tung
  • 26,371
  • 7
  • 91
  • 115
r2b2
  • 21
  • 2
  • 1
    Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Jan 28 '20 at 05:42

1 Answers1

0

I believe by borders you mean the boxes around all the facets? In that case, note that you are specifying to have each facet have a transparent background rectangle with this: panel.background = element_rect(fill=NA, color="gray50").

Change that to this and you will have removed all those borders:

panel.background = element_blank()

If you still want the axis lines (X and Y whenever you have axis labels), add this within theme(...):

axis.line = element_line(color='black')

For more info on formatting, this resource is pretty useful.

chemdork123
  • 12,369
  • 2
  • 16
  • 32