{ "info": { "author": "Massimo DiPierro", "author_email": "massimo.dipierro@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "## Canvas - a quick and dirty interface to matplotlib\n\nI do not know about you but I find matplotlib fanatstic but overwhelming. I can never remember its syntax, yet I find myself often repeating the same boilerplate code.\n\nThis simple library is not meant to be general but it allows me to produce the quick and dirty plots I often need.\n\n`canvas.py` exposes a single object, `Canvas`, which has methods `plot`,`hist`,`errorbar`,`ellipses`,`imshow`, and `save`. These methods can be chained to overlap diffent types of plots. For example:\n\n >>> from random import gauss\n >>> from math import sin, cos\n >>> from canvas import Canvas\n\n >>> gaussian = [gauss(0,1) for i in range(1000)]\n >>> Canvas('My First Image').hist(gaussian).save('img1.png')\n\nhist data is an array of numbers.\n[output](https://github.com/mdipierro/canvas/blob/master/screenshots/img1.png)\n\n >>> spiral = [(x*cos(0.1*x),x*sin(0.1*x)) for x in range(0,300)]\n >>> Canvas('My Second Image').plot(spiral).save('img2.png')\n\nplot data is an array of 2-tuples, (x,y).\n[output](https://github.com/mdipierro/canvas/blob/master/screenshots/img2.png)\n\n >>> points = [(x,x+gauss(0,1),0.5) for x in range(20)]\n >>> Canvas('My Third Image').errorbar(points).plot(points).save('img3.png')\n\nerrorbar data is an array of 3-tuples, (x,y,dy). In the example above the plot is superimposed to errorbars. [output](https://github.com/mdipierro/canvas/blob/master/screenshots/img3.png)\n\n >>> blobs = [(gauss(0,1),gauss(0,1),0.05,0.05) for i in range(100)]\n >>> Canvas('My Fourth Image').ellipses(blobs).save('img4.png')\n\nellipses data is an array of 4-tuples, (x,y,dx,dy).\n[output](https://github.com/mdipierro/canvas/blob/master/screenshots/img4.png)\n\n >>> waves = [[sin(0.1*x)*cos(0.1*x*y) for x in range(20)] for y in range(20)]\n >>> Canvas('My Fifth Image').imshow(waves).save('img5.png')\n\nimshow data is a square 2D array of numbers.\n[output](https://github.com/mdipierro/canvas/blob/master/screenshots/img5.png)\n\nThe names of the methods of the canvas objects are the same as the methods of the corresponding matplotlib axis object.\n\n### Django example\n\n def my_image(request):\n data = [gauss(0,1) for i in range(1000)]\n image_data = Canvas('title').hist(data).binary()\n return HttpResponse(image_data, mimetype=\"image/png\")\n\n### web2py example\n\n def my_image():\n data = [gauss(0,1) for i in range(1000)]\n response.headers['Content-type'] = 'image/png'\n return Canvas('title').hist(data).binary()\n\n### Flask example\n\n @app.route('/my_image')\n def my_image():\n data = [gauss(0,1) for i in range(1000)]\n image_data = Canvas('title').hist(data).binary()\n response.headers['Content-type'] = 'image/png'\n return Response(image_data)\n\n## Arguments\n\nHere is the full signature:\n\n class Canvas(object):\n def __init__(self,title='title',xlab='x',ylab='y',xrange=None,yrange=None): ...\n def save(self,filename='plot.png'): ...\n def hist(self,data,bins=20,color='blue',legend=None): ...\n def plot(self,data,color='blue',style='-',width=2,legend=None): ...\n def errorbar(self,data,color='black',marker='o',width=2,legend=None): ...\n def ellipses(self,data,color='blue',width=0.01,height=0.01): ...\n def imshow(self,data,interpolation='bilinear'): ...\n\n## Installation\n\nYou'll need numpy and matplotlib.\n\nFrom source:\n\n python setup.py install\n\nIf you want to install the dependancies using pip you need to process this way:\n\n pip install numpy\n # THEN\n pip install matplotlib\n\nBe **sure** to have numpy installed before installing matplotlib otherwise the installation will fail.\n\n## License\n\n3-clause BSD license", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mdipierro/canvas", "keywords": "matplotlib", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "canvas", "package_url": "https://pypi.org/project/canvas/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/canvas/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/mdipierro/canvas" }, "release_url": "https://pypi.org/project/canvas/0.2/", "requires_dist": null, "requires_python": null, "summary": "canvas is a simple interface to most common matplotlib functions", "version": "0.2" }, "last_serial": 1189592, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "58699c4d842b5a73f8f2e8ba2acceb0c", "sha256": "fdd728b27fcd26f9cf142b26d551636938ec3c1fb9c4ef728ca6925ddd6575b0" }, "downloads": -1, "filename": "canvas-0.1.tar.gz", "has_sig": false, "md5_digest": "58699c4d842b5a73f8f2e8ba2acceb0c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3060, "upload_time": "2012-06-14T19:49:31", "url": "https://files.pythonhosted.org/packages/f7/d5/dbfbfe26f37f7ed1df516d1081772d37aa6033551e3682bec918443c4853/canvas-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "833a559720a29dba95ad5f0f5163f190", "sha256": "fdfb8b14e5a100972c0a793a9b2ee3a5be64f552f73b954d80224325c3f08b70" }, "downloads": -1, "filename": "canvas-0.2.tar.gz", "has_sig": false, "md5_digest": "833a559720a29dba95ad5f0f5163f190", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3312, "upload_time": "2014-08-13T19:15:24", "url": "https://files.pythonhosted.org/packages/7d/9b/b09428156f07fdf6f748f535104e35c41df9222301c3609bfa21a60f02cf/canvas-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "833a559720a29dba95ad5f0f5163f190", "sha256": "fdfb8b14e5a100972c0a793a9b2ee3a5be64f552f73b954d80224325c3f08b70" }, "downloads": -1, "filename": "canvas-0.2.tar.gz", "has_sig": false, "md5_digest": "833a559720a29dba95ad5f0f5163f190", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3312, "upload_time": "2014-08-13T19:15:24", "url": "https://files.pythonhosted.org/packages/7d/9b/b09428156f07fdf6f748f535104e35c41df9222301c3609bfa21a60f02cf/canvas-0.2.tar.gz" } ] }