7

我做了一个这样的情节:

plot(
  layer(x=sort(randn(1000),1), y=sort(randn(1000),1), Geom.point),
  layer(x=[-4,4], y=[-4,4], Geom.line(), Theme(default_color=color("black"))))

散点图

如您所见,点周围的白色圆圈使绘图的高密度部分几乎是白色的。

我想将点的外圈颜色更改为黑色(或蓝色),以更好地显示这些点确实存在。

Gadfly 文档看来,可能的highlight_color参数Theme()可能会这样做,但它需要一个函数作为参数。

我不明白这应该如何工作。有任何想法吗?

4

2 回答 2

7

参数名称原来是discrete_highlight_color...

它应该是一个修改用于绘图的颜色的函数,通常通过使其更亮(“色调”)或更暗(“阴影”)。在我们的例子中,我们可以忽略当前颜色并返回黑色。

using Color
using Gadfly
plot(
  layer(
    x = sort(randn(1000),1), 
    y = sort(randn(1000),1), 
    Geom.point,
    # Theme(highlight_width=0.0mm) # To remove the border
    Theme( discrete_highlight_color = u -> LCHab(0,0,0) )
  ),
  layer(
    x = [-4,4], 
    y = [-4,4], 
    Geom.line(), 
    Theme(default_color=color("black"))
  )
)

散点图

为了找到正确的论点,我首先输入

code_lowered( Theme, () )

它给出了参数列表,然后

less( Gadfly.default_discrete_highlight_color )

它显示了如何定义默认值。

于 2014-11-18T16:09:20.613 回答
0

对于像我这样最近试图解决这个问题的人,我发现摆脱那个讨厌的白环的最好方法是通过主题设置highlight_width=0pt

例如

plot(x=rand(10),y=rand(10),Theme(highlight_width=0pt))

我在下图中有一些额外的主题我做的一个例子

于 2016-06-06T08:59:35.540 回答