r - 如何避免剪切我的 xticks?

标签 r ggplot2

我正在绘制一些具有关联日期的数据。但是,最右边的 xtick(2017 年 4 月)由于 xtick 太长而被剪裁。

除了旋转或重新格式化刻度线之外,我怎样才能避免这种剪辑?

enter image description here

最佳答案

hjust theme(axis.text=中的参数做你需要的:

library(ggplot2)
library(lubridate)
s <- c(320,790,810,820,780,780,680,700,600,380,420,620,310)
d <- seq(ymd('2016-03-01'),ymd('2017-03-01'), by = '1 month')
df <- data.frame(Date=d,No.Sales=s)

ggplot(df) + geom_bar(aes(Date,No.Sales),stat="identity") + 
             theme_bw() + 
             labs(title="Condo Sales",
                  subtitle="Montly counts of condo sales in Toronto") +
             theme(panel.border = element_blank(),
                   axis.text=element_text( hjust=1) ) 

产量:

enter image description here

关于r - 如何避免剪切我的 xticks?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42891881/

相关文章:

r - 自动比较来自小鼠 glm.mids 的嵌套模型

r - 在 R 中生成 HG19 的基因图

r - 如何改进ggplot2中的锯齿线图?

r - 用ggplot2将多个y值绘制为单独的线的正确方法

r - 在 x 轴上绘制月份下方的年份

r - 查看序数 CLMM 模型中每个级别的系数

r - Sourcing 脚本不会将任何输出打印到控制台

r - 检查差异是否小于机器精度的正确/标准方法是什么?

r - 为什么在使用 plotstyle ="ggplot"时 qqcomp 函数中没有显示任何点?

r - 创建条形图时的 Ggplot() 图形问题