基于散点图/条形图中的范围与plotly

时间:2019-10-23 08:46:55

标签: r ggplot2 colors plotly

下面是我的文件格式

Gene    Position    Depth
DDX11L1 13141   7
WASH7P  15563   324.5768037
FAM138F 35345   5000
OR4F5   69549   800
OR4F29  368127  90

下面是代码

library(ggplot2)
library(plotly)
library(dplyr)
setwd("F:\\Work\\Laptop2_M3_210")
ps = read.table("PositionGE.txt", header=TRUE)
ps$Gene <- as.character(ps$Gene) 
ps$Gene <- factor(ps$Gene, levels=unique(ps$Gene))

ggplot(ps) + scale_y_log10() + geom_point(aes(x=Position, y=Depth), color = ifelse(ps$Position<=1000,"black","red")) + geom_bar(aes(x=Position, y=Depth), stat = "identity", width = 0.08, color = "blue") + theme(axis.text.x = element_text(face="bold", color="#993333", size=6, angle=45)) + ylab("Expression Log10 Ratio of GOU_6H_0hr")

输出: This how my plot looks like, I want the coloring based on range and with plotly

我想知道如何进行条件着色 悬停在( <1000 Black, >1000 and <50000 then green, else blue)(第一列)上时,条形图的to display the Gene, Position and Depth

0 个答案:

没有答案