diff --git a/_posts/python/statistical/joyplot/joyplot.ipynb b/_posts/python/statistical/joyplot/joyplot.ipynb new file mode 100644 index 000000000000..90f9c3f95a89 --- /dev/null +++ b/_posts/python/statistical/joyplot/joyplot.ipynb @@ -0,0 +1,228 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### New to Plotly?\n", + "Plotly's Python library is free and open source! [Get started](https://plot.ly/python/getting-started/) by downloading the client and [reading the primer](https://plot.ly/python/getting-started/).\n", + "
You can set up Plotly to work in [online](https://plot.ly/python/getting-started/#initialization-for-online-plotting) or [offline](https://plot.ly/python/getting-started/#initialization-for-offline-plotting) mode, or in [jupyter notebooks](https://plot.ly/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": [ + "#### Version Check\n", + "Plotly's python package is updated frequently. Run `pip install plotly --upgrade` to use the latest version." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'3.2.0'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import plotly\n", + "plotly.__version__" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Joy Plots" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "scrolled": false + }, + "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", + "import pandas as pd\n", + "\n", + "df = pd.read_csv(\"https://raw.githubusercontent.com/plotly/datasets/master/violin_data.csv\")\n", + "\n", + "trace1 = dict(\n", + " orientation='h',\n", + " type='violin',\n", + " x=list(df['total_bill'] + 4),\n", + " y0=1,\n", + " box=dict(visible=False),\n", + " line=dict(width=0),\n", + " meanline=dict(visible=False),\n", + " fillcolor='#c78dd3',\n", + " opacity=0.8,\n", + " points=False,\n", + " side='positive',\n", + ")\n", + "\n", + "trace2 = dict(\n", + " orientation='h',\n", + " type='violin',\n", + " x=list(df['total_bill'] + 4),\n", + " y0=0.1,\n", + " box=dict(visible=False),\n", + " line=dict(width=0),\n", + " meanline=dict(visible=False),\n", + " fillcolor='#8dd3c7',\n", + " opacity=0.8,\n", + " points=False,\n", + " side='positive',\n", + ")\n", + "\n", + "fig = dict(\n", + " data=[trace1, trace2,],\n", + " layout=dict(\n", + " title='',\n", + " yaxis=dict(zeroline=False),\n", + " showlegend=False\n", + " )\n", + ")\n", + "\n", + "py.iplot(fig, filename='violin-for-joyplot')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Reference\n", + "See https://plot.ly/python/reference/#violin for more information and chart attribute options!" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "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 c:\\users\\branden\\appdata\\local\\temp\\pip-5beb6u-build\n", + "Installing collected packages: publisher\n", + " Found existing installation: publisher 0.11\n", + " Uninstalling publisher-0.11:\n", + " Successfully uninstalled publisher-0.11\n", + " Running setup.py install for publisher: started\n", + " Running setup.py install for publisher: finished with status 'done'\n", + "Successfully installed publisher-0.11\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", + " 'joyplot.ipynb', 'python/joy-plots/', 'Joy Plots',\n", + " 'How to make joy plots and ridgeline plots in Python with Plotly.',\n", + " title = 'Joy Plots | Plotly',\n", + " has_thumbnail='true',\n", + " thumbnail='thumbnail/joyplot.jpg',\n", + " language='python', \n", + " display_as='statistical', \n", + " order=12.1, #ipynb='~notebook_demo/201'\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "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": 2 +}