Previously I was using matplotlib. Things went fairly smoothly. The only awkward places were those where I tried to customise the looks of things a bit. Having to do that for each and every plot seems cumbersome. And I guess I'm not alone with that feeling, because matplotlib let's you provide a configuration file, that sets up things the way you'd like. You name the thing “matplotlibrc” in your current working directory to have different setups in different places. So I created a file that contains the following:
lines.linewidth : 1.5
axes.grid : True
axes.color_cycle : b, r, g, c, m, y, k
xtick.labelsize : 8
ytick.labelsize : 8
legend.fancybox : True
legend.fontsize : small
Then the plotting script reduces the Python code to only pieces that are pretty self-explanatory:
import numpy as np
import matplotlib.pyplot as pp
data = map(lambda x: [ x[0],
complex(x[1], x[2]),
complex(x[3], x[4]),
complex(x[5], x[6]),
complex(x[7], x[8]) ],
np.loadtxt("wifi-antennas.s2p", skiprows=5))
def column(data, i):
return [ row[i] for row in data ]
def lin2db20(data):
return 20 * np.log10(np.abs(data))
xx = np.multiply(1/1.0e9, column(data, 0))
s11 = lin2db20(column(data, 1))
pp.plot(xx, s11, label = '2.4GHz antenna')
pp.xticks(list(pp.xticks()[0]) + [ 2.4 ])
pp.xlim(0, xx.max())
pp.ylim(np.min([s11.min(), s22.min()]) - 1, 1)
pp.xlabel("frequency [GHz]")
pp.ylabel("S11 [dB]")
pp.savefig("wifi-antennas.pdf", bbox_inches = 'tight')
Better.