can not transpose ggplot2 smooth line
1
0
Entering edit mode
8.7 years ago
mbk0asis ▴ 680

Hi,

I was trying to draw scatter plots with smooth lines using ggplot2. When I transpose X/Y axis (data), the smooth line didn't.

I thought smooth lines were to show the trend of data. Am I misunderstanding?

When I changed below

p <- qplot(
  log2(countsNormalized[,1]+1),
  log2(countsNormalized[,4]+1),
  xlab="A",
  ylab="B",
  alpha=0.9)
p + 
  geom_smooth(method="lm",se=F) +
  geom_abline(intercept = 0,linetype="dotted") +
  geom_point(size=3) +
  stat_smooth_func(geom="text",method="lm",hjust=0,parse=TRUE)

to next

p <- qplot(
  log2(countsNormalized[,4]+1),
  log2(countsNormalized[,1]+1),
  xlab="A",
  ylab="B",
  alpha=0.9)
p +
  geom_smooth(method="lm",se=F) +
  geom_abline(intercept = 0,linetype="dotted") +
  geom_point(size=3) +
  stat_smooth_func(geom="text",method="lm",hjust=0,parse=TRUE)

the smooth line stayed the same.

Any ideas would be helpful. Thanks.

ggplot2 RNA-Seq R • 2.4k views
ADD COMMENT
0
Entering edit mode

By the way, how can I put picture here?

ADD REPLY
3
Entering edit mode
8.7 years ago
Daniel ★ 4.0k

Instead of swapping the axes around in the columns, you can just use + coord_flip().

Check out: http://docs.ggplot2.org/0.9.3.1/coord_flip.html for implementations.

ADD COMMENT

Login before adding your answer.

Traffic: 2523 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6