Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #928

Re: plot in hexagonal lattice

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!usenet.stanford.edu!postnews.google.com!m2g2000vbc.googlegroups.com!not-for-mail
From Péter Juhász <peter.juhasz83@gmail.com>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: plot in hexagonal lattice
Date Fri, 10 Feb 2012 02:53:20 -0800 (PST)
Organization http://groups.google.com
Lines 87
Message-ID <eb1a0442-3272-46fc-8de4-cdc2827dc1ac@m2g2000vbc.googlegroups.com> (permalink)
References <d92bf6e5-34be-4540-96db-90223e53d475@ge5g2000vbb.googlegroups.com>
NNTP-Posting-Host 193.225.144.95
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1328871200 5496 127.0.0.1 (10 Feb 2012 10:53:20 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Fri, 10 Feb 2012 10:53:20 +0000 (UTC)
Complaints-To groups-abuse@google.com
Injection-Info m2g2000vbc.googlegroups.com; posting-host=193.225.144.95; posting-account=zDLjuQoAAAC_blU_eX_4MHabi0k_sknv
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-Header-Order HUALENKRC
X-HTTP-UserAgent Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0,gzip(gfe)
Xref x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:928

Show key headers only | View raw


On Feb 9, 10:52 am, zsolti elter <elter.zs...@gmail.com> wrote:
> Hello!
>
> I would like to plot data-s in a hexagonal lattice. I have a .dat file
> in which the 1st and 2nd column are the X and Y coordinates of the
> hexagon's centers, and the other columns hold the data, what I want to
> plot in the lattice.
>
> I managed only to plot the datas with pm3d, but I don't know, how to
> plot the lattice grids, and how to plot hexagons. I plotted the datas
> by circles, and I increased the size of it, but it's not the best.
> So I would like to get something like the lattice map on the left part
> of the picture:http://www.kfki.hu/~aekihp/arlhome/images/verona1.gif
>
> For the lattice I guess I should use a loop and set object polygon,
> because from the center of a hexagon ! can evaluate the points of the
> hexagon (and I know the lattice pitch), but I don't know how to read
> in every step only one X and Y value from my data file, and how to
> assign the value of the data (power in my case) to this hexagon.
>
> Thanks for your help!
>
> Best regards,
>
> Zsolti Elter

Method 1: plot the file twice, building up the command that declares
the hexagons in the first pass, plotting them in the second.

######################
reset
fn = 'hexagons.dat'
S = 0.5
C = sqrt(3)/2
A = 1/C
a = 0.95*A

hex_id = 1

cmd = ''

hex_cmd(x, y, c) = sprintf("set obj hex_id poly from %g,%g-a to %g+a*C,
%g-a*S to %g+a*C,%g+a*S to %g,%g+a to %g-a*C,%g+a*S to %g-a*C,%g-a*S
to %g,%g-a fs solid 0.8 border lc pal cb %g lw 2 fc pal cb %g; hex_id
= hex_id + 1;", x,y,x,y,x,y,x,y,x,y,x,y,x,y,c,c)

read_f(x, y, c) = (cmd=cmd.hex_cmd(x, y, c), y)

set term unknown

plot fn u 1:(read_f($1,$2,$3))

set term pop

eval cmd

set size ratio -1
set xr [GPVAL_X_MIN-A:GPVAL_X_MAX+A]
set yr [GPVAL_Y_MIN-A:GPVAL_Y_MAX+A]

plot fn u 1:2:3 w d lc pal notit
########################

Some test data:

########################
3	1.73205080756888	0.627868065218539
2	3.46410161513775	0.0381587751648738
3	5.19615242270663	0.372697677268786
2	6.92820323027551	0.421502736487078
3	8.66025403784439	0.274237128801435
5	1.73205080756888	0.202129157245494
4	3.46410161513775	0.769320237819866
5	5.19615242270663	0.031500208931071
4	6.92820323027551	0.562379837027411
5	8.66025403784439	0.504284749332101
7	1.73205080756888	0.217345187922358
6	3.46410161513775	0.284577491217966
########################

Method 2: this is specific to the postscript terminal. Modify the
postscript prologue gnuplot prepends to every postscript file it
produces and change one of the point types to a hexagon. Once done,
simply plot the data 'with points pointtype X' where X is the
pointtype you've just modified.

Péter Juhász

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

plot in hexagonal lattice zsolti elter <elter.zsolt@gmail.com> - 2012-02-09 01:52 -0800
  Re: plot in hexagonal lattice Péter Juhász <peter.juhasz83@gmail.com> - 2012-02-10 02:42 -0800
    Re: plot in hexagonal lattice zsolti elter <elter.zsolt@gmail.com> - 2012-02-10 23:16 -0800
  Re: plot in hexagonal lattice Péter Juhász <peter.juhasz83@gmail.com> - 2012-02-10 02:53 -0800

csiph-web