{ "metadata": { "name": "", "signature": "sha256:8c1bec06b26b2a1f314b2fdd7fb247289c24adecec9a33591513423daef46f19" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "import matplotlib.pylab as plt\n", "from matplotlib import cm\n", "from matplotlib.colors import LogNorm\n", "%matplotlib inline\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "file = 'art_cleaned.csv'" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "data = np.recfromcsv(file)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "z = plt.hist(data['year'], bins=np.arange(1500,2012,5),histtype='step')\n", "plt.yscale('log')\n", "plt.ylim((1,1e4))\n", "plt.xlabel('Year')\n", "plt.ylabel('# Pieces')" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "#How about Size vs Year?\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "h0 = plt.hist2d(data['width'], data['height'],bins=100)#,norm=LogNorm())\n", "#plt.colorbar()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "h = plt.hist2d(np.log10(data['width']), \n", " np.log10(data['height'])/np.log10(data['width']),\n", " bins=(200,200),norm=LogNorm())\n", "plt.xlim((1.5,3.5))\n", "plt.ylim((0.5,1.5))\n", "plt.colorbar()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "h, xi, yi = plt.histogram2d(np.log10(data['width']), \n", " np.log10(data['height'])/np.log10(data['width']),\n", " bins=(200,300) )\n", "\n", "plt.figure(figsize=(10,7))\n", "plt.imshow(np.log10(h+1).T,interpolation='nearest', origin='lower', aspect=2,\n", " extent=(np.min(xi),np.max(xi),np.min(yi),np.max(yi)),cmap=cm.BuPu)\n", "plt.xlim((1.5,3.5))\n", "plt.ylim((0.6,1.4))\n", "plt.xlabel('Width')\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#Now for something completely different... Art -> Data -> Art" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# now let's work on drawing squares\n", "\n", "x1 = np.array([-1, 1, 1, -1, -1], dtype='float')\n", "y1 = np.array([-1, -1, 1, 1, -1], dtype='float')\n", "\n", "# set up the figure\n", "plt.figure(figsize=(6,6))\n", "plt.xlim((-5000,5000))\n", "plt.ylim((-5000,5000))\n", "\n", "# need to do this for ALL the length of data, not just first 100\n", "for i in range(0, 100):\n", " plt.plot(x1*data['width'][i], y1*data['height'][i],'k',alpha=0.1)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }