Hi all,
I'm pretty new to plplot and I'm fairly confused on how one goes about
plotting data into a polar plot. I've searched around but haven't found a
clear example, although I think its something to do with mapping 'world
views' and 'pltr1/pltr2'.
In the example below I am faking up some data to produce 2 plots:
1). Rectangluar sky-view, where X=azimuth (0->360) and Y=elevation (0->90)
2). Polar sky-view, where rotation around circle is azimuth, outside of
circle is horizon (elevation=0) and center is 'up' (elevation=90).
Any suggestions on how to plot the 'data' array into the polar plot would
be appreciated...
At present I'm using the python bindings with plplot-5.9.5 on Ubuntu, but
plan to move to (native) Windows in the future,
Simon.
#!/usr/bin/env python
import math
from plplot import *
from numpy import *
plinit()
# ---------------------------------------------------
# Build random array
plseed(1234)
x=[]
y=[]
for i in range(1000) :
x.append(plrandd() * 360)
y.append(plrandd() * 90)
# compute binned density on 15' boundaries
# 360' gives 24 divisions
# 90' gives 6 divisions
data = zeros((24,6))
for i in range(len(x)):
data[int(x[i]/15)][int(y[i]/15)] += 1
# ---------------------------------------------------
# Rectangular plot
plcol0(1)
plenv(0, 360, 0, 90, 0, 2)
plcol0(2)
pllab("Azimuth", "Elevation", "Rectangular Sky View")
# plot binned density
col = []
for i in range(16):
col.append(i*16)
plscmap1(col, col, col)
plimage(data, 0, 360, 0, 90, 0, 100, 0, 360, 0, 90)
# plot points
plpoin(x,y,5)
# ---------------------------------------------------
# Polar plot
plenv(-1.5, 1.5, -1.5, 1.5, 2, -2)
pllab("", "", "Polar Sky View")
# plot data (somehow....)
# plimagefr(data, 0, 360, 0, 90, 0, 0, 1, 1, pltr2, 0, 0);
# Draw radial spokes and write labels
dtr = math.pi / 180.0
for i in range(12):
theta = 30.0 * i
dy = math.cos(dtr * theta)
dx = math.sin(dtr * theta)
pljoin(0.0, 0.0, dx, dy)
text = `int(theta)`
if dx >= 0:
plptex(dx, dy, dx, dy, -0.15, text)
else:
plptex(dx, dy, -dx, -dy, 1.15, text)
pleop()
plend()------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plplot-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-general