繁体   English   中英

在不使用 scale_x_continuous 的情况下更改刻度线标签

[英]Changing tick mark labels without using scale_x_continuous

我一直在研究一个连续数据集,当使用geom_density (ggplot2) 绘制时,使用scale_x_continuous时数据点会被截断。 最棒的是xlim()会根据我的需要显示数据。 唯一的问题是 xlim 似乎消除了更改轴刻度线标签的能力,所以当我的 Z 分数密度 plot 需要显示从 -3 到 3 的每个刻度线时,它显示了该范围内的数据,但不显示这些点的刻度线,如1所示。

什么是 function 可以让我更改轴刻度线?

更新:这就是: scale_x_continuous(breaks = pretty(a_tubulin_data$Z.Scores, n = 9)) + coord_cartesian(xlim=c(-3,3))

输出如2所示

你在寻找这样的东西吗?

df <- data.frame(x = rnorm(100,0,1.5))

library(ggplot2)

ggplot(df,aes(x = x))+
  geom_density()+
  coord_cartesian(xlim = c(-3,3))+
  scale_x_continuous(breaks = c(-3,-2,-1,0,1,2,3))

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM