{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Generate Graphs using the Generic Graphing Tool\n\nIn this example, we generate a line plot, a density plot and a scatter plot.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Author: Fan Wang (fanwangecon.github.io)\nimport pyfan.graph.generic.allpurpose as pyfan_graph_allpurpose\nimport numpy as np"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plot Time Series Lines of Temperatures in Two Cities\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# construct data inputs\nnp.random.seed(0)\nit_days = 365\nar_x = np.linspace(1, 365, it_days)\nar_y1 = np.random.normal(25, 3, it_days)\nar_y2 = np.random.normal(15, 5, it_days)\nmt_y = np.column_stack((ar_y1, ar_y2))\n\n# graphing class object instance\nco_grapher = pyfan_graph_allpurpose.graphFunc()\nco_grapher.xyPlotMultiYOneX(xData=ar_x, yDataMat=mt_y,\n                            basicTitle=\"Temperature Flucations Two Cities\",\n                            basicXLabel=\"days of the year\",\n                            basicYLabel=\"daily temperatures\",\n                            labelArray=[\"city 1, mean=25, sd=3\",\n                                        \"city 2, mean=15, sd=5\"], noLabel=False,\n                            graphType='plot',\n                            saveOrNot=False, showOrNot=False)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plot Three Densities of Test Score Distributions\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# construct data inputs\nnp.random.seed(0)\nit_students_perclass = 100\nar_student_id = np.arange(it_students_perclass)\nar_class_a_tests = np.random.normal(80, 3, it_students_perclass)\nar_class_b_tests = np.random.normal(75, 10, it_students_perclass)\nar_class_c_tests = np.random.normal(50, 20, it_students_perclass)\nmt_y = np.column_stack((ar_class_a_tests, ar_class_b_tests, ar_class_c_tests))\n\n# graphing class object instance\nco_grapher = pyfan_graph_allpurpose.graphFunc()\nco_grapher.xyPlotMultiYOneX(xData=ar_x, yDataMat=mt_y,\n                            basicTitle=\"Test Score Densities (100 students per class)\",\n                            basicXLabel=\"Test Scores\",\n                            basicYLabel=\"Densities\",\n                            labelArray=[\"Class 1\", \"Class 2\", \"Class 3\"], noLabel=False,\n                            graphType='density',\n                            saveOrNot=False, showOrNot=False)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plot a Scatter Plot of the Relationship Between Wage and Education\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# construct data inputs\nnp.random.seed(0)\nit_worker_obs = 100\nar_worker_edu = np.random.choice(18, it_worker_obs);\nar_log_wage_shock = np.random.normal(0, 0.2, it_worker_obs)\nar_worker_wage = np.exp(2 + ar_worker_edu*0.05 + ar_log_wage_shock)\n\n# graphing class object instance\nco_grapher = pyfan_graph_allpurpose.graphFunc()\nco_grapher.xyPlotMultiYOneX(xData=ar_worker_edu, yDataMat=ar_worker_wage,\n                            basicTitle=\"Hourly Wage and Years of Education\",\n                            basicXLabel=\"Years of Schooling\",\n                            basicYLabel=\"Hourly Wage\",\n                            graphType='scatter', scattersize=10,\n                            saveOrNot=False, showOrNot=False)"
      ]
    }
  ],
  "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.8.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}