How to make scatter plots with transparent points

后端 未结 2 1021
别跟我提以往
别跟我提以往 2020-12-05 14:59

How can I plot an image with partial transparent scatter points just like in this picture with gnuplot? The problem is I don\'t know how to set the points to be tra

2条回答
  •  渐次进展
    2020-12-05 15:53

    You can use the alpha channel of argb along with lc rgb variable

    set samp 2000
    randn(x) = invnorm(rand(x))
    pl [-3:3][-3:3] '+' us (randn(0)):(randn(0)):(0xBB00AAFF) lc rgb variable pt 7 ps 2
    

    lp 7.

    This leaves some egde around each circle, probably an opacity effect from a circle plus a filled circle on top of it. Unfortunately, there is no edgecolor option as in matplotlib to control this. Replacing filled circles pt 7 with open circles but thick linewidth pt 6 lw 6 can mitigate this a bit

    pl [-3:3][-3:3] '+' us (randn(0)):(randn(0)):(0xBB00AAFF) lc rgb variable pt 6 lw 6
    

    pt 6 lw 6.

    One can also emulate a variable transparency with lc rgb variable

    set samp 50
    pl '+' us 1:1:(0x00AAFF+(int(0xFF*$1/10.)<<24)) pt 7 lc rgb variable ps 3
    

    where int(0xFF*$1/10.) maps the input from 0..10 into 0..255 and <<24 shifts it into the alpha channel.

    enter image description here

    Note that in your plot only the dense regions seem to have a transparency effect, but not the scatter points in the background.

提交回复
热议问题