{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.plot([1,2,3,8], [1,4,9,16], marker='x')\n", "#plt.axis([0,5,0,20])\n", "plt.ylabel('OX')\n", "plt.xlabel('OY')\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.plot([1,2,3,4], [1,4,9,16], '-o') # Check also '-o', '-x'\n", "plt.axis([0,5,0,20])\n", "plt.ylabel('OX')\n", "plt.xlabel('OY')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "\n", "f = lambda x: x**2 - 5*x + 6 \n", "x = np.linspace(1.0, 4.0, 100, endpoint=True)\n", "plt.plot(x, f(x))\n", "plt.plot(x, [0] * len(x))\n", "plt.plot([2,3], [0,0], 'o', color='red')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from random import randint\n", "\n", "dice = 10\n", "def two_dices():\n", " return randint(1,dice) * randint(1, dice) # '+' => '*'\n", "\n", "results = [two_dices() for _ in range(100000)]\n", "plt.hist(results, 100, normed=1, alpha=0.75) # 2*dice-1 => 10\n", "plt.show()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "\n", "mu, sigma = 100, 15\n", "x = mu + sigma * np.random.randn(10000)\n", "\n", "# the histogram of the data\n", "n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)\n", "\n", "plt.title('Rozklad madrosci w populacji')\n", "plt.text(60, .025, r'$\\mu=100,\\ \\sigma=15$')\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from mpl_toolkits.mplot3d import axes3d\n", "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "\n", "fig = plt.figure()\n", "ax = fig.gca(projection='3d')\n", "X, Y, Z = axes3d.get_test_data(0.05)\n", "ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)\n", "cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)\n", "cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)\n", "cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)\n", "\n", "ax.set_xlabel('X')\n", "ax.set_xlim(-40, 40)\n", "ax.set_ylabel('Y')\n", "ax.set_ylim(-40, 40)\n", "ax.set_zlabel('Z')\n", "ax.set_zlim(-100, 100)\n", "\n", "#plt.show()\n", "plt.savefig('figure_xyz.pdf') # pdf, eps, svg" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.0" } }, "nbformat": 4, "nbformat_minor": 0 }