Lyn*_*ite 6 plot scatter-plot julia gadfly
我想在Gadfly中绘制一个标记的散点图,如下所示.
(来源: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)
Run Code Online (Sandbox Code Playgroud)
选项是使用颜色,但这不是很好,因为传说变得巨大(特别是在不那么简单的例子中).
plot(x=X,y=Y, color=Labels)
Run Code Online (Sandbox Code Playgroud)

虽然@ 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)
Run Code Online (Sandbox Code Playgroud)

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