ggplot2 theme with no axes or grid

前端 未结 3 1545
感动是毒
感动是毒 2020-12-05 00:24

I am trying to make a plot with no information beyond the data. No axes; no grid; no title; just the plot.

But I keep getting extra margins and padding that I can\'t

相关标签:
3条回答
  • 2020-12-05 01:04

    From ggplot2_2.0.0 you can use theme_void:

    ggplot() + 
      geom_area(data = economics, aes(x = date, y = unemploy), linetype = 0) +
      theme_void()
    

    0 讨论(0)
  • 2020-12-05 01:05

    Here is the way to plot only the panel region:

    p <- ggplot() + geom_area (data=economics, aes(x = date, y = unemploy), linetype=0) +
      scale_x_date(expand = c(0,0)) + scale_y_continuous(expand = c(0,0)) +
      theme(line = element_blank(),
            text = element_blank(),
            title = element_blank())
    
    gt <- ggplot_gtable(ggplot_build(p))
    ge <- subset(gt$layout, name == "panel")
    
    grid.draw(gt[ge$t:ge$b, ge$l:ge$r])
    

    enter image description here

    0 讨论(0)
  • 2020-12-05 01:06

    try

    last_plot() + theme(axis.ticks.length = unit(0.001, "mm")) + labs(x=NULL, y=NULL)
    

    you may want to file a bug for the 0 tick length.

    0 讨论(0)
提交回复
热议问题