How to pass a function to julia Gadfly Theme parameter

后端 未结 2 347
梦谈多话
梦谈多话 2021-01-18 02:31

I make a plot like this:

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_colo         


        
相关标签:
2条回答
  • 2021-01-18 03:12

    For those like me trying to solve this problem more recently, I discovered that the best way to get rid of that pesky white ring is through the theme setting highlight_width=0pt

    for example

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

    I had some additional themes in the below image

    0 讨论(0)
  • 2021-01-18 03:22

    The argument name turns out to be discrete_highlight_color...

    It should be a function that modifies the colour used for the plot, typically by making it lighter (a "tint") or darker (a "shade"). In our case, we can just ignore the current colour and return black.

    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"))
      )
    )
    

    Scatterplot

    To find the correct argument, I first typed

    code_lowered( Theme, () )
    

    which gives the list of arguments, and then

    less( Gadfly.default_discrete_highlight_color )
    

    which shows how the default value is defined.

    0 讨论(0)
提交回复
热议问题