1

I'm trying to make a scatter plot of the following data:

cellines     TFs                V3                V4
1     A549    ATF3 -63.6777147567198  15.8519394572415
2     A549    BCL3 -61.1807150847571  15.8274988278844
3     A549 BHLHE40  49.0082575992423  43.4891023541967
4     A549   CEBPB  18.9039338584414 -66.8282282747146
5     A549    CTCF  52.6089140710441 -42.5728622947219
6     A549    ELF1  27.3004998230339  42.2866894056312

and the code:

p <- ggplot(tsne_plot,aes(x=V3,y=V4,col=TFs))
p + geom_point() + theme(legend.position="none")

but Here's what I get: Plot showing unexpected axis

And I also get the error:

TEXT_SHOW_BACKTRACE environmental variable.
TEXT_SHOW_BACKTRACE environmental variable.

The goal is to make a plot with only one axis. Can anyone help me here?

Nelly Kong
  • 279
  • 1
  • 2
  • 18
  • 5
    Your data is not numeric. That's all you need to fix. Check why it was imported as character/factors or coerce to numeric. – Roland Sep 27 '17 at 04:08
  • I'm only plotting V3 and V4 here and they are numeric. The TF is a label for the color and I've tried to convert to integer values but that doesn't solve the problem. – Nelly Kong Sep 27 '17 at 04:29
  • 2
    Check str(tsne_plot) and you'll see that the data is not numeric. – Roland Sep 27 '17 at 04:37
  • can you share a reproducible example to produce your plot above? I tried with your 6 rows of records, and didn't have the issue of multiple axis. You can check out https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example on how to produce a reproducible example – shaojl7 Sep 27 '17 at 10:38
  • @shaojl7 There are no multiple axes in OP's plot. There are many decimal numbers as axis breaks, which results in overplotting of axis text. – Roland Sep 27 '17 at 16:20
  • @Roland You're right. I put the numeric part in one data frame and color table in another one and the problem is gone. Not a direct solution but works conveniently. Thanks! – Nelly Kong Sep 27 '17 at 17:55
  • That should not be necessary. A data.frame can hold different data types. The problem is probably in how you build it. Possibly you are using cbind to create a matrix somewhere which is not needed and results in such issues. – Roland Sep 27 '17 at 18:00
  • Note that using two data.frames can result in a wrong color mapping in ggplot2. – Roland Sep 27 '17 at 18:01
  • Exactly! I used cbind to construct the data frame! Now I changed it to df$V3 <- V3 and it's fixed! Thank you so much! – Nelly Kong Sep 27 '17 at 18:21

0 Answers0