绘制具有标准化点大小的散点?

时间:2019-09-30 22:12:56

标签: python r ggplot2 plot

请问如何绘制图形?每个点的大小应与其在特定时间的比例相对应。

是否可以使用箭头或连续线代替离散点来显示趋势?箭头/线的宽度将对应于特定时间的比例。而且,它可以处理丢失的数据,例如将缺失数据的位置设置为空白,或者使用非常细的箭头/线表示缺失数据。

pythonR都对我有好处。

原始数据:

Time;Value A;Value A proportion;Value B;Value B proportion
1;5;90%;12;10%
2;7;80%;43;20%
3;7;80%;83;20%
4;8;70%;44;30%
5;10;80%;65;20%

这样的情节示例就是这样,但我对其他点图案感到高兴。

p

1 个答案:

答案 0 :(得分:1)

In [1]: data = [('GM0051', 'GM0178', 'GM0191'),('GM0134', 'GM0267', 'GM0351', 'GM0615'),('GM0180', 'GM0474', 'GM0512'),('GM0216', 'GM0471', 'GM0586'),('GM0373', 'GM0373', 'GM0373')]
In [2]: [tuple(set(d)) for d in data]
Out[2]: 
    [('GM0051', 'GM0191', 'GM0178'),
    ('GM0267', 'GM0134', 'GM0351', 'GM0615'),
    ('GM0474', 'GM0512', 'GM0180'),
    ('GM0216', 'GM0471', 'GM0586'),
    ('GM0373',)]

enter image description here

您可以玩library(ggplot2) library(reshape2) myDF <- read.table("~/Desktop/test.txt",header=TRUE,sep=";") # remove "%" myDF <- data.frame(lapply(myDF, function(x) as.numeric(sub("%", "", x))) ) meltVar <- melt(myDF,id.vars = c("Time"),measure.vars = c("Value.A","Value.B")) meltpropr <- melt(myDF,id.vars = c("Time"),measure.vars = c("Value.A.proportion","Value.B.proportion")) newDF <- as.data.frame(cbind(meltVar,meltpropr[,"value"])) names(newDF) <- c("Time","variable","value","prop") ggplot(newDF,aes(x=Time, y=value)) + geom_point(aes(colour=variable , shape=variable, size = prop)) aes来随意获得身材。