{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### New to Plotly?\n", "Plotly's Python library is free and open source! [Get started](https://plotly.com/python/getting-started/) by downloading the client and [reading the primer](https://plotly.com/python/getting-started/).\n", "
You can set up Plotly to work in [online](https://plotly.com/python/getting-started/#initialization-for-online-plotting) or [offline](https://plotly.com/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plotly.com/python/getting-started/#start-plotting-online).\n", "
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) (new!) to help you get started!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Basic Wind Rose Chart" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go\n", "\n", "trace1 = go.Barpolar(\n", " r=[77.5, 72.5, 70.0, 45.0, 22.5, 42.5, 40.0, 62.5],\n", " text=['North', 'N-E', 'East', 'S-E', 'South', 'S-W', 'West', 'N-W'],\n", " name='11-14 m/s',\n", " marker=dict(\n", " color='rgb(106,81,163)'\n", " )\n", ")\n", "trace2 = go.Barpolar(\n", " r=[57.49999999999999, 50.0, 45.0, 35.0, 20.0, 22.5, 37.5, 55.00000000000001],\n", " text=['North', 'N-E', 'East', 'S-E', 'South', 'S-W', 'West', 'N-W'],\n", " name='8-11 m/s',\n", " marker=dict(\n", " color='rgb(158,154,200)'\n", " )\n", ")\n", "trace3 = go.Barpolar(\n", " r=[40.0, 30.0, 30.0, 35.0, 7.5, 7.5, 32.5, 40.0],\n", " text=['North', 'N-E', 'East', 'S-E', 'South', 'S-W', 'West', 'N-W'],\n", " name='5-8 m/s',\n", " marker=dict(\n", " color='rgb(203,201,226)'\n", " )\n", ")\n", "trace4 = go.Barpolar(\n", " r=[20.0, 7.5, 15.0, 22.5, 2.5, 2.5, 12.5, 22.5],\n", " text=['North', 'N-E', 'East', 'S-E', 'South', 'S-W', 'West', 'N-W'],\n", " name='< 5 m/s',\n", " marker=dict(\n", " color='rgb(242,240,247)'\n", " )\n", ")\n", "data = [trace1, trace2, trace3, trace4]\n", "layout = go.Layout(\n", " title='Wind Speed Distribution in Laurel, NE',\n", " font=dict(\n", " size=16\n", " ),\n", " legend=dict(\n", " font=dict(\n", " size=16\n", " )\n", " ),\n", " radialaxis=dict(\n", " ticksuffix='%'\n", " ),\n", " orientation=270\n", ")\n", "fig = go.Figure(data=data, layout=layout)\n", "py.iplot(fig, filename='polar-area-chart')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Reference\n", "\n", "See https://plotly.com/python/reference/#barpolar for more information and chart attribute options!" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Collecting git+https://github.com/plotly/publisher.git\n", " Cloning https://github.com/plotly/publisher.git to /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-req-build-FM7hk1\n", "Building wheels for collected packages: publisher\n", " Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n", "\u001b[?25h Stored in directory: /private/var/folders/tc/bs9g6vrd36q74m5t8h9cgphh0000gn/T/pip-ephem-wheel-cache-p_NUGG/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", "Successfully built publisher\n", "Installing collected packages: publisher\n", " Found existing installation: publisher 0.11\n", " Uninstalling publisher-0.11:\n", " Successfully uninstalled publisher-0.11\n", "Successfully installed publisher-0.11\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated since IPython 4.0. You should import from nbconvert instead.\n", " \"You should import from nbconvert instead.\", ShimWarning)\n", "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you \"Save\" this notebook before running this command? Remember to save, always save.\n", " warnings.warn('Did you \"Save\" this notebook before running this command? '\n" ] } ], "source": [ "from IPython.display import display, HTML\n", "\n", "display(HTML(''))\n", "display(HTML(''))\n", "\n", "! pip install git+https://github.com/plotly/publisher.git --upgrade\n", "import publisher\n", "publisher.publish(\n", " 'wind-rose.ipynb', 'python/wind-rose-charts/', 'Python Wind Rose Charts | plotly',\n", " 'How to graph wind rose charts in python. Wind Rose charts display wind speed and direction of a given location. ',\n", " title = 'Python Wind Rose Charts | plotly',\n", " name = 'Wind Rose Charts',\n", " has_thumbnail='true', thumbnail='thumbnail/wind-rose.jpg', \n", " language='python', page_type='example_index', \n", " display_as='scientific', order=8,\n", " ipynb= '~notebook_demo/38')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 1 }