{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Scatter Demo2\n\nDemo of scatter plot with varying marker colors and sizes.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport matplotlib.cbook as cbook\n\n# Load a numpy record array from yahoo csv data with fields date, open, high,\n# low, close, volume, adj_close from the mpl-data/sample_data directory. The\n# record array stores the date as an np.datetime64 with a day unit ('D') in\n# the date column.\nprice_data = cbook.get_sample_data('goog.npz')['price_data']\nprice_data = price_data[-250:]  # get the most recent 250 trading days\n\ndelta1 = np.diff(price_data[\"adj_close\"]) / price_data[\"adj_close\"][:-1]\n\n# Marker size in units of points^2\nvolume = (15 * price_data[\"volume\"][:-2] / price_data[\"volume\"][0])**2\nclose = 0.003 * price_data[\"close\"][:-2] / 0.003 * price_data[\"open\"][:-2]\n\nfig, ax = plt.subplots()\nax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5)\n\nax.set_xlabel(r'$\\Delta_i$', fontsize=15)\nax.set_ylabel(r'$\\Delta_{i+1}$', fontsize=15)\nax.set_title('Volume and percent change')\n\nax.grid(True)\nfig.tight_layout()\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n\n   component: marker\n   styling: color\n   styling: colormap\n   plot-type: scatter\n   level: beginner\n\n"
      ]
    }
  ],
  "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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}