0
votes

I'm trying to make a "density" type scatter plot, where each point is a transparent circle, so when they overlap it makes a density map. I'm doing this with a huge number of samples, so the transparency is very low, but this means it's impossible to see the key. Can I make the key's transparency different than the actual plots?

This is what I have:

if (!exists("outfile")) outfile='plot.pdf'

set terminal pdf enhanced size 8in, 4.8in
set output outfile

set style fill transparent solid 0.1 noborder
set style circle radius 0.03

plot sample1 u 1:2 w circles, sample2 u 1:2 w circles

example plot

1
Check help keyentry. - theozh
Just a thought: if you have 10'000 or many more data points, PDF (vector format) is maybe not the best format because it probably will become pretty large. PNG (bitmap format) might be better in this case. - theozh
@theozh I have 200,000 data points - the PDF is around 3.6 MB, but it does take a long time to render. I'm including this in a LaTeX report, so I just defaulted to PDF, but I'll switch to PNG if I'm not satisfied with the render time. - Otto von Bisquick

1 Answers

1
votes

Simply use keyentry and with points pt 7. Check help keyentry.

Code:

### keyentry
reset session

# create some random test data
set samples 10000
set table $Data1
    plot '+' u (invnorm(rand(0))+1):(invnorm(rand(0))+1) w table
set table $Data2
    plot '+' u (invnorm(rand(0))+4):(invnorm(rand(0))+4) w table
unset table

set style fill transparent solid 0.1 noborder
set style circle radius 0.03

plot $Data1 u 1:2 w circles notitle,\
     $Data2 u 1:2 w circles notitle, \
     keyentry w p pt 7 lc 1 title "Data1", \
     keyentry w p pt 7 lc 2 title "Data2"
### end of code

For older "pre-keyentry" gnuplot versions you could exchange the keyentry lines by:

 NaN w p pt 7 lc 1 title "Data1", \
 NaN w p pt 7 lc 2 title "Data2"

Result:

enter image description here