无论我在使用matplotlib、openflash图表还是其他图表框架,我总是需要找到一种方法来设置x/y比例的限制和间隔,因为内置函数不够智能(或者根本就没有)
只要在pylab(ipyhton-pylab)中尝试一下,就可以理解我的意思:
In [1]: a, b, x = np.zeros(10), np.ones(10), np.arange(10)
In [2]: plot(x, a); plot(x, b)
你会看到一个空的框架网格在它的上下边界下隐藏了两条水平线。在
我想知道是否有一些算法(我可以移植到python)来巧妙地设置y的上下极限和步数,并计算出每个值显示x的厚度。在
例如,假设我有475个度量值作为(datetime, temperature)
作为(x, y)
(每5分钟一次)和
26.5 < temperature < 28.3
我对这个案例的建议是:
26.4 <= y_scale <= 28.4
with a thick every.2
每12项(每小时一次)在x_scale
上打勾。在
但是如果我在20天内用-21.5 < temperature < 38.7
来做20次测量呢?有标准化的方法吗?在
我在这里报告我的python版本的上述C代码,如果它可能有任何帮助的人:
用作:
^{pr2}$还要添加javascript移植:
以下是我多年来使用的方法,它很简单,效果很好。请原谅我是C语言,但是翻译成Python应该不难。在
下面的函数是必需的,来自Graphic Gems第1卷。在
像下面的例子一样,根据您希望显示的主刻度数选择轴的“良好”起点/终点。如果不关心刻度,可以将其设置为常量(例如:10)。在
^{pr2}$下面是我的python代码来自动计算节拍,它需要数据的范围和最大节拍数。在
例如:
下面是函数的Python代码
^{pr2}$相关问题 更多 >
编程相关推荐