简体   繁体   中英

Changing tick mark labels without using scale_x_continuous

I have been working on a continuous data set that when plotted with geom_density (ggplot2) will have data points cut off when using scale_x_continuous . The great thing is that xlim() displays the data just as I need it. Only problem is that xlim seems to eliminate the ability to change the axis tick mark labels, So when my Z-score density plot needs to show every tick mark from -3 to 3, it shows data within that range, but does not display the tick marks at those points, as seen in 1 .

What would be a function that lets me alter the axis tick marks?

UPDATE: this is what: scale_x_continuous(breaks = pretty(a_tubulin_data$Z.Scores, n = 9)) + coord_cartesian(xlim=c(-3,3))

outputs as seen in 2

Are you looking for something like this?

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))

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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