如何避免 expand = c(0,0) 裁剪轴刻度标签

Ste*_*ted 4 r ggplot2

我正在构建一个显示介于 0.0 和 1.0 之间的值的克利夫兰点图。

我接近拥有我想要的情节,但一个小细节困扰着我。因为我使用 expand = c(0,0) 截断了 x 轴上 1.00 中的最后一个 0。

我曾尝试更改各种设置,但没有运气。

这个问题有一个类似的标题这个职位呢,遗憾的是,没有帮助。

你能帮我保持图的边界而不切断 x 轴上 1.00 的最后一个零吗?

代表:

library(tidyverse)

df <- tibble(
  Tastyness = c(0.6, 0.7, 0.9, 0.95, 0.98),
  Fruit = c("Bananas", "Apples", "Oranges", "Mango", "Peach")
)


ggplot(df, aes(x = Tastyness, y = Fruit)) +
  geom_point(size = 4) +
  theme_bw() +
  scale_x_continuous(
    limits = c(0.0, 1.0),
    expand = c(0, 0),
    breaks = c(0, 0.5, 0.75, 0.9, 1.00)
  )
Run Code Online (Sandbox Code Playgroud)

Mar*_*dri 6

适用于情节周围边距的解决方案:

ggplot(df, aes(x = Tastyness, y = Fruit)) +
  geom_point(size = 4) +
  theme_bw() +
  scale_x_continuous(
    limits = c(0.0, 1.0),
    expand = c(0, 0),
    breaks = c(0, 0.5, 0.75, 0.9, 1.00)
  ) +
  theme(plot.margin=unit(c(.2,.5,.2,.2),"cm"))
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明