R 从ggplot2中的geom_直方图中删除水平线

R 从ggplot2中的geom_直方图中删除水平线,r,ggplot2,histogram,R,Ggplot2,Histogram,我想绘制一个直方图,其中一些文本位于右侧,但是x轴(或者可能是直方图的下部)延伸到文本。如何删除此行 library(tibble) library(ggplot2) library(dplyr) my_label <- "text" p <- rnorm(10000) %>% as_tibble(.) %>% ggplot(., aes(x = value)) + geom_histogram(color = 'black', fill =

我想绘制一个直方图,其中一些文本位于右侧,但是x轴(或者可能是直方图的下部)延伸到文本。如何删除此行

library(tibble)  
library(ggplot2)  
library(dplyr)

my_label <- "text"

p <- rnorm(10000) %>%
  as_tibble(.) %>%
  ggplot(., aes(x = value)) +
    geom_histogram(color = 'black', fill = 'grey70', bins = 30) +
    annotate(geom = 'text', x = 15, y = 1500, label = my_label,
             hjust = 1, size = 3, color = "#cc0000") +
    theme_void()
库(TIBLE)
图书馆(GG2)
图书馆(dplyr)
我的标签%
ggplot(,aes(x=值))+
几何图形直方图(颜色=黑色,填充=灰色70,箱子=30)+
注释(geom=‘文本’,x=15,y=1500,label=my_标签,
hjust=1,size=3,color=“#cc0000”)+
主题_void()

如果它是第一个参数,那么就没有必要使用
,而且确实有点不鼓励使用它。因此,相反,将
rnorm(10000)%%>%写为_tible()%%>%ggplot(aes(x=value))…
。我不认为这是不可取的,而是个人偏好的问题()。我宁愿把它们留作教学之用。你有没有链接到任何表示不鼓励的内容?
A quick hack to rid your plot of the x-axis line

rnorm(10000) %>%
  as_tibble() -> dat

dat %>% 
  ggplot(aes(value)) +
  geom_histogram(color = 'black', fill = 'grey70') +
  annotate(geom = 'text', x = 15, y = 1500, label = my_label,
           hjust = 1, size = 3, color = "#cc0000") +
  theme_void() +
  geom_histogram(data = tibble(value=1:15), color = 'white')