{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# NCL_scatter_6.py\nThis script illustrates the following concepts:\n   - Drawing a scatter plot with markers of different colors and sizes\n   - Drawing outlined and filled markers on a polar map plot\n   - Generating dummy data using \"random\"\n   - Changing the marker colors on a polar map plot\n   - Changing the marker sizes on a polar map plot\n   - Turning off y-axis labels\n\nSee following URLs to see the reproduced NCL plot & script:\n    - Original NCL script: https://www.ncl.ucar.edu/Applications/Scripts/scatter_6.ncl\n    - Original NCL plot: https://www.ncl.ucar.edu/Applications/Images/scatter_6_lg.png\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Import packages:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create dummy data:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "numpoints = 100\nlon = np.random.uniform(0, 360, numpoints)\nlat = np.random.uniform(5, 90, numpoints)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Generate a figure\nfig = plt.figure(figsize=(8, 8))\n\n# Create axis with a polar projection\nax = fig.add_subplot(111, projection='polar')\nax.set_ylim([0, 90])\n\n# Change orientation of projection\nax.set_theta_zero_location(\"S\")\n\n# Create array of marker colors\ncolors = (\"limegreen\", \"orange\", \"green\", \"red\", \"yellow\", \"purple\", \"blue\",\n          \"red\", \"brown\", \"crimson\", \"skyblue\")\n\n# Create array of marker sizes\nbins = np.linspace(100, 2000, 10)\n\n# Plot all points\n# longitude points must be transformed from degrees to radians\n# to be plotted on polar projection\nfor x in range(numpoints):\n    ax.scatter((np.pi / 180.0) * lon[x],\n               lat[x],\n               color=colors[x % 10],\n               s=bins[x % 10],\n               edgecolors='black',\n               linewidths=1,\n               alpha=0.9,\n               zorder=2)\n\n# set the labels and locations of the angular gridlines\nlinelabels = ('0', '30E', '60E', '90E', '120E', '150E', '180', '150W', '120W',\n              '90E', '60E', '30E')\nlines, labels = plt.thetagrids(range(0, 360, 30), linelabels, fontsize=12)\n\n# Create distance between the x tick labels and the axis\nax.tick_params(axis='x', pad=10)\n\n# Set y-axis gridlines and turn off y-axis labels\nax.set_yticks([0, 20, 40, 60, 80, 100])\nax.set_yticklabels([])\n\n# Make gridlines dashed\nax.grid(linestyle='--')\n\nplt.show()"
      ]
    }
  ],
  "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.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}