r-xlim()对geom_点和geom_直方图的不同影响

r-xlim()对geom_点和geom_直方图的不同影响,r,ggplot2,R,Ggplot2,我用直方图覆盖散点图,然后使用xlim()设置x轴。但似乎xlim()删除了直方图的1和10,但对散点图没有影响 library(ggplot2) library(plotly) (d <- data.frame(key = 1:10, value = 1:10)) # xlim() seems to not include 1 and 10 for the histogram ggplot(data = d, aes(x = value)) + geom_histogram

我用直方图覆盖散点图,然后使用
xlim()
设置x轴。但似乎
xlim()
删除了直方图的1和10,但对散点图没有影响

library(ggplot2)
library(plotly)

(d <- data.frame(key = 1:10, value = 1:10))

# xlim() seems to not include 1 and 10 for the histogram
ggplot(data = d, aes(x = value)) + 
    geom_histogram(binwidth = 1) +
    geom_point(data = d, aes(x = key, y = value)) +
    xlim(1, 10)
库(ggplot2)
图书馆(绘本)

(d)由于声誉相对较低,我目前似乎没有编辑该帖子的权限。对不起:@LJWYou始终有权编辑您自己的帖子。由于声誉相对较低,我目前似乎没有编辑该帖子的权限。对不起。:)@LJWYou始终拥有编辑自己帖子的权限。