Created
April 19, 2026 04:27
-
-
Save fomightez/8911a16b63be9624cd440e15e6d60c05 to your computer and use it in GitHub Desktop.
Demo basics of plotlyPowerpoint working on MyBinder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "# plotlyPowerpoint getting started on mybinder session\n", | |
| "Based on https://github.com/jonboone1/plotlyPowerpoint/blob/master/example/getting_started.ipynb\n", | |
| "And the readme there at https://github.com/jonboone1/plotlyPowerpoint/, too\n", | |
| "\n", | |
| "Run this notebook in sessions launched from [here](https://github.com/fomightez/3Dscatter_plot_mod_playground-binder)\n", | |
| "\n", | |
| "Direct launch:\n", | |
| "[](https://mybinder.org/v2/gh/fomightez/3Dscatter_plot_mod_playground-binder/main?urlpath=%2Flab%2Ftree%2Findex.ipynb)\n", | |
| "\n", | |
| "Or put https://mybinder.org/v2/gh/fomightez/3Dscatter_plot_mod_playground-binder/main?urlpath=%2Flab%2Ftree%2Findex.ipynb in your URL bar." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Collecting plotlyPowerpoint\n", | |
| " Downloading plotlyPowerpoint-1.3.39-py3-none-any.whl.metadata (6.2 kB)\n", | |
| "Collecting pydataset\n", | |
| " Downloading pydataset-0.2.0.tar.gz (15.9 MB)\n", | |
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m15.9/15.9 MB\u001b[0m \u001b[31m5.0 MB/s\u001b[0m \u001b[33m0:00:03\u001b[0mm0:00:01\u001b[0m00:01\u001b[0m\n", | |
| "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25ldone\n", | |
| "\u001b[?25hRequirement already satisfied: pandas>=1.2.4 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotlyPowerpoint) (2.3.3)\n", | |
| "Requirement already satisfied: plotly>=4.14.3 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotlyPowerpoint) (6.7.0)\n", | |
| "Collecting numerize>=0.12 (from plotlyPowerpoint)\n", | |
| " Downloading numerize-0.12.tar.gz (2.7 kB)\n", | |
| " Preparing metadata (setup.py) ... \u001b[?25ldone\n", | |
| "\u001b[?25hRequirement already satisfied: scipy>=1.6.3 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotlyPowerpoint) (1.15.3)\n", | |
| "Collecting behave>=1.2.5 (from plotlyPowerpoint)\n", | |
| " Downloading behave-1.3.3-py2.py3-none-any.whl.metadata (10 kB)\n", | |
| "Collecting flake8>=2.0 (from plotlyPowerpoint)\n", | |
| " Downloading flake8-7.3.0-py2.py3-none-any.whl.metadata (3.8 kB)\n", | |
| "Collecting lxml>=3.1.0 (from plotlyPowerpoint)\n", | |
| " Downloading lxml-6.1.0-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.metadata (4.0 kB)\n", | |
| "Collecting mock>=1.0.1 (from plotlyPowerpoint)\n", | |
| " Downloading mock-5.2.0-py3-none-any.whl.metadata (3.1 kB)\n", | |
| "Requirement already satisfied: Pillow>=3.3.2 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotlyPowerpoint) (12.2.0)\n", | |
| "Requirement already satisfied: pyparsing>=2.0.1 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotlyPowerpoint) (3.3.2)\n", | |
| "Collecting pytest>=2.5 (from plotlyPowerpoint)\n", | |
| " Downloading pytest-9.0.3-py3-none-any.whl.metadata (7.6 kB)\n", | |
| "Collecting XlsxWriter>=0.5.7 (from plotlyPowerpoint)\n", | |
| " Downloading xlsxwriter-3.2.9-py3-none-any.whl.metadata (2.7 kB)\n", | |
| "Collecting python-pptx==0.6.19 (from plotlyPowerpoint)\n", | |
| " Downloading python-pptx-0.6.19.tar.gz (9.3 MB)\n", | |
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.3/9.3 MB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m \u001b[33m0:00:01\u001b[0m eta \u001b[36m0:00:01\u001b[0m\n", | |
| "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25ldone\n", | |
| "\u001b[?25hCollecting cucumber-tag-expressions>=4.1.0 (from behave>=1.2.5->plotlyPowerpoint)\n", | |
| " Downloading cucumber_tag_expressions-9.1.0-py3-none-any.whl.metadata (4.7 kB)\n", | |
| "Collecting cucumber-expressions>=17.1.0 (from behave>=1.2.5->plotlyPowerpoint)\n", | |
| " Downloading cucumber_expressions-19.0.0-py3-none-any.whl.metadata (1.7 kB)\n", | |
| "Collecting parse>=1.18.0 (from behave>=1.2.5->plotlyPowerpoint)\n", | |
| " Downloading parse-1.21.1-py2.py3-none-any.whl.metadata (21 kB)\n", | |
| "Collecting parse-type>=0.6.0 (from behave>=1.2.5->plotlyPowerpoint)\n", | |
| " Downloading parse_type-0.6.6-py2.py3-none-any.whl.metadata (12 kB)\n", | |
| "Requirement already satisfied: six>=1.15.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from behave>=1.2.5->plotlyPowerpoint) (1.17.0)\n", | |
| "Collecting colorama>=0.3.7 (from behave>=1.2.5->plotlyPowerpoint)\n", | |
| " Downloading colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)\n", | |
| "Requirement already satisfied: tomli>=1.1.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from behave>=1.2.5->plotlyPowerpoint) (2.3.0)\n", | |
| "Collecting mccabe<0.8.0,>=0.7.0 (from flake8>=2.0->plotlyPowerpoint)\n", | |
| " Downloading mccabe-0.7.0-py2.py3-none-any.whl.metadata (5.0 kB)\n", | |
| "Collecting pycodestyle<2.15.0,>=2.14.0 (from flake8>=2.0->plotlyPowerpoint)\n", | |
| " Downloading pycodestyle-2.14.0-py2.py3-none-any.whl.metadata (4.5 kB)\n", | |
| "Collecting pyflakes<3.5.0,>=3.4.0 (from flake8>=2.0->plotlyPowerpoint)\n", | |
| " Downloading pyflakes-3.4.0-py2.py3-none-any.whl.metadata (3.5 kB)\n", | |
| "Requirement already satisfied: numpy>=1.22.4 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from pandas>=1.2.4->plotlyPowerpoint) (2.2.6)\n", | |
| "Requirement already satisfied: python-dateutil>=2.8.2 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from pandas>=1.2.4->plotlyPowerpoint) (2.9.0.post0)\n", | |
| "Requirement already satisfied: pytz>=2020.1 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from pandas>=1.2.4->plotlyPowerpoint) (2025.2)\n", | |
| "Requirement already satisfied: tzdata>=2022.7 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from pandas>=1.2.4->plotlyPowerpoint) (2026.1)\n", | |
| "Requirement already satisfied: narwhals>=1.15.1 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotly>=4.14.3->plotlyPowerpoint) (2.19.0)\n", | |
| "Requirement already satisfied: packaging in /srv/conda/envs/notebook/lib/python3.10/site-packages (from plotly>=4.14.3->plotlyPowerpoint) (25.0)\n", | |
| "Requirement already satisfied: exceptiongroup>=1 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from pytest>=2.5->plotlyPowerpoint) (1.3.0)\n", | |
| "Collecting iniconfig>=1.0.1 (from pytest>=2.5->plotlyPowerpoint)\n", | |
| " Downloading iniconfig-2.3.0-py3-none-any.whl.metadata (2.5 kB)\n", | |
| "Collecting pluggy<2,>=1.5 (from pytest>=2.5->plotlyPowerpoint)\n", | |
| " Downloading pluggy-1.6.0-py3-none-any.whl.metadata (4.8 kB)\n", | |
| "Requirement already satisfied: pygments>=2.7.2 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from pytest>=2.5->plotlyPowerpoint) (2.19.2)\n", | |
| "Requirement already satisfied: typing-extensions>=4.6.0 in /srv/conda/envs/notebook/lib/python3.10/site-packages (from exceptiongroup>=1->pytest>=2.5->plotlyPowerpoint) (4.15.0)\n", | |
| "Downloading plotlyPowerpoint-1.3.39-py3-none-any.whl (18 kB)\n", | |
| "Downloading behave-1.3.3-py2.py3-none-any.whl (223 kB)\n", | |
| "Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)\n", | |
| "Downloading cucumber_expressions-19.0.0-py3-none-any.whl (20 kB)\n", | |
| "Downloading cucumber_tag_expressions-9.1.0-py3-none-any.whl (9.7 kB)\n", | |
| "Downloading flake8-7.3.0-py2.py3-none-any.whl (57 kB)\n", | |
| "Downloading mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)\n", | |
| "Downloading pycodestyle-2.14.0-py2.py3-none-any.whl (31 kB)\n", | |
| "Downloading pyflakes-3.4.0-py2.py3-none-any.whl (63 kB)\n", | |
| "Downloading lxml-6.1.0-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (5.3 MB)\n", | |
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.3/5.3 MB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m \u001b[33m0:00:00\u001b[0m eta \u001b[36m0:00:01\u001b[0m\n", | |
| "\u001b[?25hDownloading mock-5.2.0-py3-none-any.whl (31 kB)\n", | |
| "Downloading parse-1.21.1-py2.py3-none-any.whl (19 kB)\n", | |
| "Downloading parse_type-0.6.6-py2.py3-none-any.whl (27 kB)\n", | |
| "Downloading pytest-9.0.3-py3-none-any.whl (375 kB)\n", | |
| "Downloading pluggy-1.6.0-py3-none-any.whl (20 kB)\n", | |
| "Downloading iniconfig-2.3.0-py3-none-any.whl (7.5 kB)\n", | |
| "Downloading xlsxwriter-3.2.9-py3-none-any.whl (175 kB)\n", | |
| "Building wheels for collected packages: python-pptx, pydataset, numerize\n", | |
| "\u001b[33m DEPRECATION: Building 'python-pptx' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'python-pptx'. Discussion can be found at https://github.com/pypa/pip/issues/6334\u001b[0m\u001b[33m\n", | |
| "\u001b[0m Building wheel for python-pptx (setup.py) ... \u001b[?25ldone\n", | |
| "\u001b[?25h Created wheel for python-pptx: filename=python_pptx-0.6.19-py3-none-any.whl size=470020 sha256=a0400009269c6789285740f2ff47aea393d230dacf92a1d212185fcdf8709f48\n", | |
| " Stored in directory: /home/jovyan/.cache/pip/wheels/27/10/f3/e564620750d9e3472a3627d6d1fdb8e04f9154dd3704d87288\n", | |
| "\u001b[33m DEPRECATION: Building 'pydataset' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'pydataset'. Discussion can be found at https://github.com/pypa/pip/issues/6334\u001b[0m\u001b[33m\n", | |
| "\u001b[0m Building wheel for pydataset (setup.py) ... \u001b[?25ldone\n", | |
| "\u001b[?25h Created wheel for pydataset: filename=pydataset-0.2.0-py3-none-any.whl size=15939459 sha256=65d2c62d1869a8753386ebb6fb58f2a7e2136f612c664a03717a7cb2c8459db1\n", | |
| " Stored in directory: /home/jovyan/.cache/pip/wheels/2b/83/5c/073c3755e8b7704e4677557b2055e61026c1a2342149214c13\n", | |
| "\u001b[33m DEPRECATION: Building 'numerize' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'numerize'. Discussion can be found at https://github.com/pypa/pip/issues/6334\u001b[0m\u001b[33m\n", | |
| "\u001b[0m Building wheel for numerize (setup.py) ... \u001b[?25ldone\n", | |
| "\u001b[?25h Created wheel for numerize: filename=numerize-0.12-py3-none-any.whl size=3191 sha256=3d5792e6b75664eee9c4cf66fe64be2a9b2270aceee56c5c7b73e05ae04e002b\n", | |
| " Stored in directory: /home/jovyan/.cache/pip/wheels/87/84/e1/9e30f2e3da6590acb0f1c03a806e2673d2f9e7f5bd2b11589a\n", | |
| "Successfully built python-pptx pydataset numerize\n", | |
| "Installing collected packages: parse, numerize, XlsxWriter, pyflakes, pycodestyle, pluggy, parse-type, mock, mccabe, lxml, iniconfig, cucumber-tag-expressions, cucumber-expressions, colorama, python-pptx, pytest, flake8, behave, pydataset, plotlyPowerpoint\n", | |
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m20/20\u001b[0m [plotlyPowerpoint][behave]r-expressions]\n", | |
| "\u001b[1A\u001b[2KSuccessfully installed XlsxWriter-3.2.9 behave-1.3.3 colorama-0.4.6 cucumber-expressions-19.0.0 cucumber-tag-expressions-9.1.0 flake8-7.3.0 iniconfig-2.3.0 lxml-6.1.0 mccabe-0.7.0 mock-5.2.0 numerize-0.12 parse-1.21.1 parse-type-0.6.6 plotlyPowerpoint-1.3.39 pluggy-1.6.0 pycodestyle-2.14.0 pydataset-0.2.0 pyflakes-3.4.0 pytest-9.0.3 python-pptx-0.6.19\n", | |
| "Note: you may need to restart the kernel to use updated packages.\n", | |
| "Collecting kaleido==0.2.1\n", | |
| " Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl.metadata (15 kB)\n", | |
| "Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl (79.9 MB)\n", | |
| "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m79.9/79.9 MB\u001b[0m \u001b[31m13.5 MB/s\u001b[0m \u001b[33m0:00:05\u001b[0mm0:00:01\u001b[0m00:01\u001b[0m\n", | |
| "\u001b[?25hInstalling collected packages: kaleido\n", | |
| "Successfully installed kaleido-0.2.1\n", | |
| "Note: you may need to restart the kernel to use updated packages.\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "%pip install plotlyPowerpoint pydataset \n", | |
| "%pip install kaleido==0.2.1\n", | |
| "# \" kaleido 0.2.1 downgrade is a well-known fix for headless environments — good to have that in your back pocket for future Binder/JupyterHub work.\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "initiated datasets repo at: /home/jovyan/.pydataset/\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "from pptx import Presentation\n", | |
| "import pandas as pd\n", | |
| "import numpy as np\n", | |
| "from pydataset import data\n", | |
| "import plotlyPowerpoint as pp\n", | |
| "import warnings\n", | |
| "warnings.filterwarnings('ignore')\n", | |
| "\n", | |
| "############\n", | |
| "## Prepare Data\n", | |
| "############\n", | |
| "\n", | |
| "#load datasets\n", | |
| "global df\n", | |
| "df = data('InsectSprays')\n", | |
| "global df2\n", | |
| "df2 = data(\"JohnsonJohnson\")\n", | |
| "\n", | |
| "#Data transformation\n", | |
| "df['m2'] = df['count'] * 1.1\n", | |
| "df2['year'] = df2['time'].astype(int)\n", | |
| "df2 = df2.groupby(['year']).agg({'JohnsonJohnson': 'mean'}).reset_index()\n", | |
| "\n", | |
| "#form df3 to showcase faceting on line chart\n", | |
| "temp = df2.copy()\n", | |
| "temp['company'] = 'J&J'\n", | |
| "temp = temp.rename(columns={'JohnsonJohnson': 'price'})\n", | |
| "\n", | |
| "temp2 = temp.copy()\n", | |
| "temp2['company'] = 'Phizer'\n", | |
| "temp2['price'] = temp2['price'] * 1.1\n", | |
| "\n", | |
| "df3 = pd.concat([temp, temp2])\n", | |
| "\n", | |
| "#form df4 to showcase faceting and grouping by additional dimension\n", | |
| "df4 = df.copy()\n", | |
| "df4['category'] = df['spray']\n", | |
| "df4.loc[df4['category'].isin(['A','B','C']), 'category'] = 'A'\n", | |
| "df4.loc[df4['category'].isin(['D','E','F']), 'category'] = 'B'\n", | |
| "\n", | |
| "#form df for showcasing a table\n", | |
| "df5 = df.head()\n", | |
| "df5['m2'][2] = df5['m2'][2] / 2\n", | |
| "df5['m3'] = df5['m2'] / 100\n", | |
| "df5['m4'] = df5['m2']\n", | |
| "\n", | |
| "#setup color map for table\n", | |
| "colorDf = df5.copy()\n", | |
| "colorDf['m2'] = np.select(\n", | |
| " [\n", | |
| " colorDf['m2'] >= colorDf['count'],\n", | |
| " colorDf['m2'] < colorDf['count']\n", | |
| " ],\n", | |
| " [\n", | |
| " \"#5eed4e\",\n", | |
| " \"#ed4e61\"\n", | |
| " ],\n", | |
| " default=\"\" # <-- add this\n", | |
| ")\n", | |
| "\n", | |
| "colorDf['count'] = '#fffff2'\n", | |
| "colorDf['spray'] = '#fffff2'\n", | |
| "colorDf['m3'] = '#fffff2'\n", | |
| "colorDf['m4'] = '#fffff2'\n", | |
| "\n", | |
| "#final adjustments\n", | |
| "df5['m2'][3] = None #showing how the library handles NaN values" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| " % Total % Received % Xferd Average Speed Time Time Time Current\n", | |
| " Dload Upload Total Spent Left Speed\n", | |
| "100 8876 100 8876 0 0 52154 0 --:--:-- --:--:-- --:--:-- 52211\n", | |
| " % Total % Received % Xferd Average Speed Time Time Time Current\n", | |
| " Dload Upload Total Spent Left Speed\n", | |
| "100 166k 100 166k 0 0 770k 0 --:--:-- --:--:-- --:--:-- 768k\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "!curl -OL https://raw.githubusercontent.com/jonboone1/plotlyPowerpoint/refs/heads/master/example/getting_started.ipynb\n", | |
| "!curl -OL https://raw.githubusercontent.com/jonboone1/plotlyPowerpoint/refs/heads/master/assets/powerpoint_templates/template.pptx\n", | |
| "#!curl -OL https://raw.githubusercontent.com/jonboone1/plotlyPowerpoint/refs/heads/master/assets/example/template.pptx" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "############\n", | |
| "## Setup Variableas\n", | |
| "############\n", | |
| "import plotly.express as px\n", | |
| "\n", | |
| "#define custom color palette\n", | |
| "# https://plotly.com/python/discrete-color/\n", | |
| "colors = px.colors.qualitative.Vivid\n", | |
| "\n", | |
| "#set template for funciton\n", | |
| "pp.setTemplate(\"template.pptx\")\n", | |
| "\n", | |
| "#set color palette\n", | |
| "pp.setColors(colors)\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "raw", | |
| "metadata": {}, | |
| "source": [ | |
| "\n", | |
| "#setup each slide\n", | |
| "charts = [\n", | |
| " { #Line Chart - stock prices\n", | |
| " \"data\": df2,\n", | |
| " \"type\": \"line\",\n", | |
| " \"name\": \"Stock Prices by Company\",\n", | |
| " \"metrics\": [\n", | |
| " {\"name\": \"JohnsonJohnson\", \"prettyName\": \"Stock Price\", \"method\": \"mean\"}\n", | |
| " ],\n", | |
| " \"axis\": \"year\",\n", | |
| " \"x-axis-title\": 'Year',\n", | |
| " \"y-axis-title\": \"Average Stock Price\",\n", | |
| " \"description\": \"Grouping by additional variables is easy\",\n", | |
| " \"filters\": [\n", | |
| " {\"variable\": \"year\", \"operation\": \">=\", \"value\": \"1970\", \"type\":\"int\"}\n", | |
| " ],\n", | |
| " \"item-index\": {\n", | |
| " 'slide': 0,\n", | |
| " 'title': 0,\n", | |
| " 'chart': 10,\n", | |
| " 'description': 11\n", | |
| " }\n", | |
| " },\n", | |
| " { #Bar chart of insect sprays\n", | |
| " \"data\": df,\n", | |
| " \"type\": \"bar\",\n", | |
| " \"name\": \"Avg Spray Effictiveness by Type\",\n", | |
| " \"metrics\": [\n", | |
| " {\"name\": \"count\", \"prettyName\": \"Effectiveness\", \"method\": \"mean\"},\n", | |
| " {\"name\": \"m2\", \"prettyName\": \"Effectiveness 2\", \"method\": \"mean\"}\n", | |
| " ],\n", | |
| " \"axis\": \"spray\",\n", | |
| " \"x-axis-title\": \"Effectiveness\",\n", | |
| " \"size\": \"wide\",\n", | |
| " \"description\": \"this slide has data on it!\",\n", | |
| " 'options': {\n", | |
| " 'orientation': 'horizontal',\n", | |
| " 'color-grouping': 'metric'\n", | |
| " },\n", | |
| " \"item-index\": {\n", | |
| " 'slide': 0,\n", | |
| " 'title': 0,\n", | |
| " 'chart': 10,\n", | |
| " 'description': 11\n", | |
| " }\n", | |
| " }\n", | |
| "]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "0 Title 1\n", | |
| "10 Picture Placeholder 2\n", | |
| "11 Text Placeholder 3\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "from pptx import Presentation\n", | |
| "\n", | |
| "prs = Presentation(\"template.pptx\")\n", | |
| "slide = prs.slides.add_slide(prs.slide_layouts[0]) # adjust layout index as needed\n", | |
| "\n", | |
| "for shape in slide.placeholders:\n", | |
| " print('%d %s' % (shape.placeholder_format.idx, shape.name))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "############\n", | |
| "## Run Function\n", | |
| "############\n", | |
| "#pp.createSlides(charts)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "slides = [\n", | |
| " {\n", | |
| " \"title\": \"Your Slide Title\",\n", | |
| " \"description\": \"Your description text\",\n", | |
| " \"item-index\": {\n", | |
| " \"slide\": 0,\n", | |
| " \"title\": 0,\n", | |
| " \"description\": 11\n", | |
| " },\n", | |
| " \"charts\": [ # <-- charts nested inside each slide\n", | |
| " {\n", | |
| " \"name\": \"Avg Spray Effectiveness by Type\",\n", | |
| " \"data\": df,\n", | |
| " \"type\": \"bar\",\n", | |
| " \"metrics\": [\n", | |
| " {\"name\": \"count\", \"prettyName\": \"Effectiveness\", \"method\": \"mean\"},\n", | |
| " {\"name\": \"m2\", \"prettyName\": \"Effectiveness 2\", \"method\": \"mean\"}\n", | |
| " ],\n", | |
| " \"axis\": \"spray\",\n", | |
| " \"x-axis-title\": \"Effectiveness\",\n", | |
| " \"item-index\": 10 # <-- chart index is just a plain int here\n", | |
| " }\n", | |
| " ]\n", | |
| " }\n", | |
| "]\n", | |
| "\n", | |
| "pp.createSlides(slides)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3 (ipykernel)", | |
| "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.10.19" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment