i want plot 2d hanning window function picture n=512
pixels colorbar vector graphics (*.svg
, *.eps
, (vectorized!) *.pdf
or so)... need plot 2d function
w(x,y) = sin(x*pi/n)^2 * sin(y*pi/n)^2
my solution python
first:
import numpy np pil import image im_hanning = image.new("f", (n, n)) pix_hanning = im_hanning.load() x in range(0, n): y in range(0, n): pix_hanning[x,y] = np.sin(x*np.pi/n)**2 * np.sin(y*np.pi/n)**2 * 255 im_hanning = image.fromarray(array)
but raster graphics of course.
so tried gnuplot
. seemed better until saw result:
set xrange [0:1] set yrange [0:1] unset xtics unset ytics set pm3d map set size square set samples 512 set isosamples 512 set palette gray splot sin(x*pi)**2 * sin(y*pi)**2
i had increase samples, else looked terrible... result looks fine:
i colorbar on right. produces (no matter terminal set) raster graphics again.
is there possibility plot 2d function vector graphics?
with pdf, svg or eps terminal, gnuplot does give vector graphics. but function has represented in way, , gnuplot piecewise linear interpolation, is, surface represented small portions of plane (triangles or quadrangles), number of set sampling rate.
if want infinitely scalable colour map, way produce has primitive of scalable vector language using, e.g. svg. real question: there svg/pdf/eps primitive represent gradient sin(x*pi)**2 * sin(y*pi)**2
. believe not case, colour gradients piecewise linear afaik, asked in way may attract answers specialists.
Comments
Post a Comment