gpt4 book ai didi

plot - 如何创建带标签的散点图?

转载 作者:行者123 更新时间:2023-12-04 14:11:57 31 4
gpt4 key购买 nike

我想绘制一个标记的散点图,如下所示,
在牛虻。

Like this example
(来源:http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/images/renda.png)

我怎样才能做到这一点?

散点图很简单:

using Gadfly
X = [1, 2, 2, 3, 3, 3, 4]
Y = [4, 4, 7, 7, 9, 1, 8]
Labels = ["bill", "susan", "megan", "eric", "fran", "alex", "fred"]

plot(x=X, y=Y)

On Option 是使用颜色,但这并不是很好,因为图例变得巨大(特别是在比这更不重要的例子中)。
plot(x=X,y=Y, color=Labels)

colors

最佳答案

虽然@Oxinabox 的答案有效,但 Gadfly 的方法是使用 Geom.label ,例如

using Gadfly
X = [1, 2, 2, 3, 3, 3, 4]
Y = [4, 4, 7, 7, 9, 1, 8]
Labels = ["bill", "susan", "megan", "eric", "fran", "alex", "fred"]

plot(x=X, y=Y, label=Labels, Geom.point, Geom.label)

Gadfly Plot

这有很多好处,包括智能标签放置以避免标签重叠,或者您可以从一些易于使用的规则中进行选择,例如 :centeredbelow .另外,它会从主题中获取字体/字体大小。

关于plot - 如何创建带标签的散点图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28665507/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com