graph drawing tool
base_for_zoom = function(base)
	local n = base
	while scale(n) < base/2 do
		if scale(n*base) < base/2 then
			n = n*base
		else  -- scale linearly
			local n2 = n
			while scale(n2) < base/2 do
				n2 = n2+n
			end
			return n2
		end
	end
	return n
end