How to pass function to julia gadfly theme parameter

I am doing a story 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_color=color("black")))) 

Scatterplot

As you can see, the white circle around the dots makes the high-density areas almost white.

I would like to change the color of the outer circle of dots to black (or blue) to better show that there really are dots.

From the Gadfly documentation, it seems that the highlight_color Theme() argument can do this, but it takes the function as an argument.

I do not understand how this should work. Any ideas?

+6
source share
2 answers

The argument name is discrete_highlight_color ...

This should be a function that changes the color used for the plot, usually making it lighter (“hue”) or darker (“hue”). In our case, we can simply ignore the current color and return to 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 a list of arguments, and then

 less( Gadfly.default_discrete_highlight_color ) 

which shows how the default value is determined.

+6
source

For people like me trying to solve this problem recently, I found that the best way to get rid of this annoying white ring is to set the highlight_width=0pt

eg

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

I had some additional themes in the image below example i made

0
source

Source: https://habr.com/ru/post/978332/


All Articles