{ "metadata": {}, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "# from http://pythonprogramming.net/3d-bar-charts-python-matplotlib/\n", "from mpl_toolkits.mplot3d import Axes3D\n", "import matplotlib.pyplot as plt\n", "import matplotlib.patches as mpatches\n", "import numpy as np\n", "import pylab as pylab\n", " \n", "fig = plt.figure()\n", "ax1 = fig.add_subplot(111, projection='3d')\n", " \n", "xpos = np.ones(60)\n", "xpos[15:30] *= 2\n", "xpos[30:45] *= 3\n", "xpos[45:60] *= 4\n", "ypos = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]\n", "\n", "num_elements = len(xpos)\n", "zpos = np.zeros(60)\n", "dx = np.ones(60)*.1\n", "dy = np.ones(60)*.5\n", "dz = [0.90433194, 0.6139531, 0.50387484, 0.55220372, 0.51213536, 0.85443374, 0.99955922, 0.5039825, 0.73091913, 0.9780236, 0.5241028, 0.71571812, 0.93782861, 0.51210244, 0.73074697,\n", "\t0., 0., 0.03412608, 0., 0.90455366, 0.78683668, 0., 0.95912629, 0.7282637, 0., 0.78548583, 0.78935491, 0.03193823, 0.00609877, 0.17287094,\n", "\t0.4474444, 0., 0.98135641, 0., 0.96315942, 0., 0., 0., 0.15930208, 0., 0.77299245, 0., 0., 0.71739497, 0.02804206,\n", "\t0., 0., 0.99815102, 0., 0.9239562, 0., 0., 0.32862838, 0.29682383, 0., 0.85108903, 0., 0., 0., 0.6687179]\n", "\n", "colors = ['r']*15+['g']*15+['b']*15+['y']*15\n", "\n", "xLabel = ax1.set_xlabel('\\nOutput Neuron', linespacing=1.2)\n", "yLabel = ax1.set_ylabel('\\nInput Neuron', linespacing=1.2)\n", "zLabel = ax1.set_zlabel('\\nWeight', linespacing=1.2)\n", "\n", "neuron1 = plt.Rectangle((0, 0), 0.1, 0.1,fc='r')\n", "neuron2 = plt.Rectangle((0, 0), 0.1, 0.1,fc='g')\n", "neuron3 = plt.Rectangle((0, 0), 0.1, 0.1,fc='b')\n", "neuron4 = plt.Rectangle((0, 0), 0.1, 0.1,fc='y')\n", "\n", "ax1.legend((neuron1,neuron2,neuron3,neuron4),(\"neuron 1\",\"neuron 2\",\"neuron 3\",\"neuron 4\"),'best')\n", "\n", "ax1.bar3d(xpos, ypos, zpos, dx, dy, dz, color=colors, alpha=0.5)\n", "ax1.view_init(elev=60.0, azim=40)\n", "\n", "pylab.savefig('Weights3dBar.jpg')\n", "\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }