#! /usr/bin/ruby
# This script generates a plot with differnet point types, available in gnuplot.
# Default terminal is "postscript eps enhanced color"
# Copyright 2010 Alexey Nikolaev <http://5th.org.ru>.
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License, see below the code
# for the full license text.
# Number of Columns
i_max = 8
# Number of Rows
j_max = 8
# ===========================================
require 'tempfile'
f_temp = Tempfile.new "gnuplot_points"
printf f_temp, "set terminal postscript eps enhanced color solid lw 1.0 size #{1.2*i_max+0.3}cm, #{1.2*j_max+0.5}cm # width, height
set output \"gnuplot_points.eps\"
set lmargin 2.0
set rmargin 2.5
set bmargin 2.5
set tmargin 3.5
show margin
set title \"Gnuplot Point Types\" font \"Helvetica,20\"
set xrange [-0.5:#{i_max-0.5}]
set yrange [-0.5:#{j_max-0.5}]
set notics
set noborder
set style line 1 ps 0 lc rgb \"#703010\" lw 0.0
plot "
(0...j_max).each{|j|
(0...i_max).each{|i|
printf f_temp,
"\"< echo \'#{i}\t#{j}\'\" u 1:2 w points ps 4 pt #{i+j*i_max} lc rgb \"#F06010\" lw 3.0 notitle, \\
\"< echo \'#{i}\t#{j}\t#{i+j*i_max}\'\" u 1:2:3 w labels offset 2.0,-1.9 tc ls 1 font \"Helvetica,18\" notitle"
if (j!=j_max-1 || i!=i_max-1) then printf f_temp, ", \\\n" end
}
}
f_temp.flush
f_temp.close
%x[gnuplot #{f_temp.path}]
#Copyright 2010 Alexey Nikolaev <http://5th.org.ru>. All rights reserved.
#
#Redistribution and use in source and binary forms, with or without modification, are
#permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
#THIS SOFTWARE IS PROVIDED BY Alexey Nikolaev ``AS IS'' AND ANY EXPRESS OR IMPLIED
#WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
#FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Alexey Nikolaev OR
#CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
#ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.