{ "metadata": { "name": "", "signature": "sha256:c078eb674c423e0d081d62fdd1674ffb055c1791f4b6271b9fffbfa011dfe50f" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import math" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "\u6563\u5e03\u56f3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "4\u3064\u306e\u70b9\u3092\u5e73\u9762\u4e0a\u306b\u30d7\u30ed\u30c3\u30c8\u3059\u308b\u4f8b\u3067\u3059\u3002``plot(x\u306e\u30ea\u30b9\u30c8, y\u306e\u30ea\u30b9\u30c8)``\u3068\u3044\u3046\u66f8\u5f0f\u3067\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f4\u3064\u306e\u70b9\u3092\u7d50\u3076\u76f4\u7dda\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002" ] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot([1,2,3,4], [1,4,9,16])\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\u7dda\u3067\u306f\u306a\u304f\u70b9\u3067\u8868\u793a\u3059\u308b\u306b\u306f\u3001plot()\u306e\u7b2c\u4e09\u5f15\u6570\u306b'o'\u3092\u52a0\u3048\u307e\u3059\u3002" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# \u8d64\u3044(r)\u70b9(o)\u3092\u8868\u793a\n", "plt.plot([1,2,3,4], [1,4,9,16], 'ro')\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\u70b9\u3068\u7dda\u306e\u4e21\u65b9\u3092\u8868\u793a\u3059\u308b\u306b\u306f\u3001plot()\u306e\u7b2c\u4e09\u5f15\u6570\u306b'o-'\u3068\u66f8\u304d\u307e\u3059\u3002" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# \u8d64\u3044(r)\u70b9(o)\u3092\u8868\u793a\n", "plt.plot([1,2,3,4], [1,4,9,16], 'r-o')\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "\u5404\u7a2e\u30e9\u30d9\u30eb\u306e\u8ffd\u52a0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\u30bf\u30a4\u30c8\u30eb\u3001X\u8ef8\u3001Y\u8ef8\u306b\u540d\u524d\u3092\u4ed8\u3051\u308b\u65b9\u6cd5\u3067\u3059\u3002\n", "\n", "\u3064\u3044\u3067\u306b\u3001\u30b0\u30e9\u30d5\u4e2d\u306b\u30c6\u30ad\u30b9\u30c8\u3092\u66f8\u304f\u65b9\u6cd5\u3068\u3001\u30b0\u30ea\u30c3\u30c9\u7dda\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u3082\u793a\u3057\u3066\u3044\u307e\u3059\u3002" ] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot([1,2,3,4], [1,4,9,16], 'ro')\n", "# x\u8ef8, y\u8ef8\u306e\u7bc4\u56f2\u3092\u8a2d\u5b9a x\u8ef8\u306f[0,6], y\u8ef8\u306f[0, 20]\n", "plt.axis([0, 6, 0, 20])\n", "# \u30b0\u30e9\u30d5\u306b\u30bf\u30a4\u30c8\u30eb\u3092\u4ed8\u4e0e\n", "plt.title('graph title here')\n", "# x\u8ef8, y\u8ef8\u306b\u540d\u524d\u3092\u4ed8\u4e0e\n", "plt.xlabel('x-axis name here')\n", "plt.ylabel('y-axis name here')\n", "# \u30b0\u30e9\u30d5\u4e2d\u306b\u30c6\u30ad\u30b9\u30c8\u3092\u8868\u793a\n", "plt.text(1, 15, r'text here. $\\alpha, \\beta, \\gamma$')\n", "# \u30b0\u30ea\u30c3\u30c9\u7dda\u3092\u8868\u793a\n", "plt.grid(True)\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "\u65e5\u672c\u8a9e\u306e\u30e9\u30d9\u30eb" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# \u53c2\u8003\uff1ahttp://sucrose.hatenablog.com/entry/2013/06/10/001250\n", "import matplotlib.font_manager\n", "prop = matplotlib.font_manager.FontProperties(fname=r'C:\\Windows\\Fonts\\meiryo.ttc')\n", "\n", "plt.title(u'\u65e5\u672c\u8a9e\u306e\u30bf\u30a4\u30c8\u30eb\u3092\u8868\u793a', fontproperties=prop)\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "y = f(x)\u306e\u8868\u793a" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\u5909\u6570\u306e\u6570\u304c\u3072\u3068\u3064\u306e\u95a2\u6570\u3092\u66f8\u304f\u306b\u306f\u3001\u4e0a\u3067\u66f8\u3044\u305f\u6563\u5e03\u56f3\u306e\u8003\u3048\u65b9\u3092\u5fdc\u7528\u3057\u307e\u3059\u3002\n", "\n", "\u4e0b\u306e\u4f8b\u3067\u306f\u3001\u307e\u305ax\u30920.0\u304b\u30895.0\u306e\u7bc4\u56f2\u30670.2\u305a\u3064\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002\n", "\u305d\u3057\u3066\u5404x\u306b\u5bfe\u3059\u308b$f(x)$ (\u3053\u3053\u3067\u306f$f(x) = \\sin(x)$)\u306e\u5024\u3092\u8a08\u7b97\u3057\u3001fx\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002\n", "\u3042\u3068\u306f\u6563\u5e03\u56f3\u306e\u66f8\u304d\u65b9\u3068\u540c\u69d8\u3067\u3059\u3002" ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = np.arange(0., 5., 0.2)\n", "fx = np.sin(x)\n", "plt.plot(x, fx)\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "y = f(x), g(x), h(x)\u3092\u540c\u6642\u306b\u6bd4\u8f03" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\u540c\u6642\u306b\u8907\u6570\u306e\u30b0\u30e9\u30d5\u3092\u66f8\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002" ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = np.arange(0., 5., 0.1)\n", "\n", "fx = np.sin(x)\n", "gx = np.cos(x)\n", "hx = np.sqrt(x)\n", "\n", "plt.plot(x, fx, 'r--', x, gx, 'bs', x, hx, 'g^')\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }