如何在ggplot2中删除x和y轴下方的绘图区域(参见下面的示例).我已经尝试了几个主题元素(panel.border,panel.margin,plot.margin)没有任何运气.
p <- ggplot(mtcars, aes(x = wt, y = mpg,xmin=0,ymin=0)) + geom_point()
Run Code Online (Sandbox Code Playgroud)

expand在连续尺度美学中使用这个论点......
p <- ggplot(mtcars, aes(x = wt, y = mpg,xmin=0,ymin=0)) +
geom_point()+
scale_x_continuous( expand = c(0,0) , limits = c(0,6) )+
scale_y_continuous( expand = c(0,0), limits = c(0,35) )
Run Code Online (Sandbox Code Playgroud)
设置限制以避免极端值被切断.

但如果您想在整个绘图周围没有边距,则需要使用该theme元素plot.margin,就像这样(在极右边缘下方的图中注意切割为零).
require(grid) # for unit
p + theme( plot.margin = unit( c(0,0,0,0) , "in" ) )
Run Code Online (Sandbox Code Playgroud)
