Rice University logo
 
Top blue bar image
Boanerges Aleman-Meza, Computer Scientist
 

Gnuplot scattered plot with circles filled, not filled, with border

Gnuplot can make great scattered plots, including the use of circles instead of just dots. The circles are typically filled, with their radious depending on a numerical value on the data being plotted. In addition, it is also possible to draw a border in the circle using different colors. Here is an example using characters from Grey’s Anatomy TV show.

These are the gnuplot commands to create the scattered plot:

set term jpeg size 700,800
set output 'plot_scattered.jpeg'
set xtics rotate ( "Meredith" 1, "Avery" 2, "Teddy" 3, "Karev" 4, "Bailey" 5, "Burke" 6, "Lexie" 7, "Owen" 8, "Addison" 9, "O'Malley" 10, "Arizona" 11, "Derek" 12, "April" 13, "Sloan" 14, "Izzie" 15, "Webber" 16, "Christina" 17, "Callie" 18 ) scale 0
set ytics ( "Meredith" 1, "Avery" 2, "Teddy" 3, "Karev" 4, "Bailey" 5, "Burke" 6, "Lexie" 7, "Owen" 8, "Addison" 9, "O'Malley" 10, "Arizona" 11, "Derek" 12, "April" 13, "Sloan" 14, "Izzie" 15, "Webber" 16, "Christina" 17, "Callie" 18 ) scale 0
plot [0:19][0:23] "homerun.txt" using 3:5:1 title 'homerun' with circles linecolor rgb "#9ACD32" fill solid noborder \
, "gender.txt" using 3:5:1 title 'homerun same gender' with circles linecolor rgb "#9400D3" lw 3 fill solid border lt 3 \
, "firstbase.txt" using 3:5:1 title 'first-base' with circles linecolor rgb "#A9A9A9" lw 3

These are the text files with the data being plotted: homerungenderfirstbase.

One great thing about Gnuplot is that it can create SVG files, this is the SVG file of the same plot: svg_file (rename it to .svg instead of .txt so that a web browser can open it).

One Response to “Gnuplot scattered plot with circles filled, not filled, with border”

  1. djconnel says:

    Nice (and funny) — but I’d recommend PNG, not JPEG for this type of plot (JPEG introduces color distortions near the edge of the symbols).

Leave a Reply