【问题标题】:plot scatter dots with normalised dot sizes?绘制具有标准化点大小的散点?
【发布时间】:2019-09-30 22:12:56
【问题描述】:

请问怎么画图?每个点的大小应与其在特定时间的比例相对应。

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

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%

情节的一个例子是这样的,但我很高兴看到其他点图案。

【问题讨论】:

  • 你的问题我不清楚。该图是否显示了您想要的输出?
  • 使用 matplotlib scatter 并根据你的比例缩放 size 关键字
  • @yifyan 我修改了我的问题。它们只是基于原始数据的示例。

标签: python r ggplot2 plot


【解决方案1】:
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))

你可以和aestheme一起玩,得到你喜欢的数字。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多