canvas是大多数常见matplotlib函数的简单接口
canvas的Python项目详细描述
##画布-一个快速和肮脏的matplotlib接口
我不知道你,但我发现matplotlib狂热但压倒性。我永远记不起它的语法,但我发现自己经常重复相同的样板代码。
这些方法可以链接到重叠不同类型的图。例如:
>;>from random import gauss
>;>from math import sin,cos
>;>from canvas import canvas
>;>gauss=[Gauss(0,1)for I in range(1000)]
>;>canvas(“我的第一张图片”).hist(高斯)。save(“img1.png”)
[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img1.png)
>;spiral=[(x*cos(0.1*x),x*sin(0.1*x))for x in range(0300)]
>;canvas(“我的第二张图片”).plot(螺旋形)。save(“img2.png”)
plot data是一个由两个元组(x,y)组成的数组。
[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img2.png)
>;points=[(x,x+gauss(0,1),0.5)for x in range(20)]
>;canvas('my third image').errorbar(points).plot(points).save('img3.png')
errorbar数据是一个三元组数组(x,y,dy)。在上面的例子中,图被叠加到误差条上。[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img3.png)
>;blobs=[(gauss(0,1),gauss(0,1),0.05,0.05)对于范围(100)内的i)
>;>;canvas(“我的第四个图像”)。ellipes(blobs)。save('img4.png')
ellipes数据是一个4元组数组,(x,y,dx,dy)。
[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img4.png)
>;>;波=[[sin(0.1*x)*cos(0.1*x*y)for x in range(20)]for y in range(20)]
>;画布(“我的第五个图像”)。(“IMG5.PNG”)BR/> BR/> IMSID数据是一个正方形的二维数组。< http://Github.com/MdiPIReO/Cabase/Bulb/Mault/Stupps/img5.PNG)。BR/> BR/>画布对象的方法名称与对应的MatPultLIB轴对象的方法相同。
BR/>示例
def my_image(请求):
data=[gauss(0,1)for i in range(1000)]
image_data=canvas('title').hist(data).binary()
return httpresponse(image_data,mimetype=“image/png”)
web2py示例
def my_image():
data=[gauss(0,1)对于范围(1000)内的i
响应。headers['content-type']=“image/png”
返回画布('title').hist(data).binary()
response.headers['content-type']='image/png'
返回响应(图像数据)
\filename='plot.png'):…
def hist(self,data,bins=20,color='blue',legend=none):…
def plot(self,data,color='blue',style='-',width=2,legend=none):…
def errorbar(self,data,color='black',marker='o',width=2,legend=none):…
def椭圆(self data,color='blue',width=0.01,height=0.01):…
def imshow(self,data,interpolation='bilinar'):…
需要这样处理:
pip install numpy
我不知道你,但我发现matplotlib狂热但压倒性。我永远记不起它的语法,但我发现自己经常重复相同的样板代码。
这些方法可以链接到重叠不同类型的图。例如:
>;>from random import gauss
>;>from math import sin,cos
>;>from canvas import canvas
>;>gauss=[Gauss(0,1)for I in range(1000)]
>;>canvas(“我的第一张图片”).hist(高斯)。save(“img1.png”)
>;spiral=[(x*cos(0.1*x),x*sin(0.1*x))for x in range(0300)]
>;canvas(“我的第二张图片”).plot(螺旋形)。save(“img2.png”)
plot data是一个由两个元组(x,y)组成的数组。
[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img2.png)
>;points=[(x,x+gauss(0,1),0.5)for x in range(20)]
>;canvas('my third image').errorbar(points).plot(points).save('img3.png')
errorbar数据是一个三元组数组(x,y,dy)。在上面的例子中,图被叠加到误差条上。[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img3.png)
>;blobs=[(gauss(0,1),gauss(0,1),0.05,0.05)对于范围(100)内的i)
>;>;canvas(“我的第四个图像”)。ellipes(blobs)。save('img4.png')
ellipes数据是一个4元组数组,(x,y,dx,dy)。
[输出](https://github.com/mdipierro/canvas/blob/master/screenshots/img4.png)
>;>;波=[[sin(0.1*x)*cos(0.1*x*y)for x in range(20)]for y in range(20)]
>;画布(“我的第五个图像”)。(“IMG5.PNG”)BR/> BR/> IMSID数据是一个正方形的二维数组。< http://Github.com/MdiPIReO/Cabase/Bulb/Mault/Stupps/img5.PNG)。BR/> BR/>画布对象的方法名称与对应的MatPultLIB轴对象的方法相同。
BR/>示例
def my_image(请求):
data=[gauss(0,1)for i in range(1000)]
image_data=canvas('title').hist(data).binary()
return httpresponse(image_data,mimetype=“image/png”)
web2py示例
def my_image():
data=[gauss(0,1)对于范围(1000)内的i
响应。headers['content-type']=“image/png”
返回画布('title').hist(data).binary()
response.headers['content-type']='image/png'
返回响应(图像数据)
\filename='plot.png'):…
def hist(self,data,bins=20,color='blue',legend=none):…
def plot(self,data,color='blue',style='-',width=2,legend=none):…
def errorbar(self,data,color='black',marker='o',width=2,legend=none):…
def椭圆(self data,color='blue',width=0.01,height=0.01):…
def imshow(self,data,interpolation='bilinar'):…
需要这样处理:
pip install numpy