fbpx

How to Embed Plotly Graphs in Powerpoint

How to Embed Plotly Graphs in Powerpoint

This tutorial content is going to teach you how to take your interactive plotly graphs and embed them into PowerPoint

Once you have created your plotly graph, putting it in your PowerPoint Slide is easier than you think. Here is how to do it.

There are 2 parts to this process:

Part 1: Take your plotly graph from your python notebook and put it on the plotly website

Part 2: Get the link for the graph from the plotly website and use it to embed the graph.

Let’s begin with PART 1:

Step 1: Sign up for a plotly account

Step 2: Install Chart Studio

  • To install plotly chart studio universally on your computer, use this code in the terminal: pip install chart_studio
  • To install plotly chart studio in anaconda environment, go to conda terminal and type: conda install -c plotly chart-studio

Step 3: Import chart studio, chart studio plotly, and chart studio tools using the following lines of code.

Step 4: Define your username and api_key using the following lines of code.

  • Username = your plotly account user name
  • API-Key = your plotly account API key
    • To access your API key and username, Go to profile name drop down menu –> click on settings –> API Keys –> Regenerate API key. Copy your API key.
    • HINT: Everytime you regenerate API key, the previous API key becomes invalid. So be careful clicking that button repeatedly.

Step 5: Log into your plotly account from your python notebook using your username and api key with the following lines of code.

Step 6: Take the graph that you want to make available online and set it equal to a variable like this (the variable name here is “spiral”)

Step 7: Upload your graph online to your plotly account using this line of code.

  • Spiral = the graph that I want uploaded online
  • Filename = what you want to name the file
    • Auto_open = True/False.
    • When auto_open is True, the file will automatically open in your browser when you run the code cell.
    • When auto_open is False, the file will not automatically open in your browser when you run the code cell.

HINT: Set auto_open to True the first time so that you can see that file in your browser as soon as you run the code cell and the graph is uploaded. Then set it to False afterward so that when you open the notebook next time and run the code cell, you won’t automatically open the file in your browser again (can get annoying).

Printed in your notebook is the link where you can find the file you just uploaded.

You can copy the link and see the uploaded graph or you can simply proceed to the following steps.

Step 8: Go to your plotly account dashboard, click on Myfiles, and you should see the file you just uploaded and the data associated with that file.

Step 9: Hover over the graph you just uploaded –> Click on viewer –> Click on the tiny code icon on the bottom right side of the graph.

Step 10: Choose how you wish to embed your files. For this tutorial, we will just use url link option. Copy the link you are presented with

NOW, it is time to embed the plotly graph in PowerPoint

Step 11: Open powerpoint –> Go to Insert Tab –> Click on Get Add-ins.

Step 12: In the Add-ins search bar –> search for plotly –> Click on add.

Step 13: Paste the URL of your graph into the plotly add-in.

HINT: To add the plotly add in a new slide, simply click the drop down menu on My Add-ins and choose plotly.

Step 14: The graph is life and fully interactive. You can turn the legend for the graph on and off by clicking the settings button and turning legend on/off.

Step 15: Join my data science community

    • To get access to the TUTORIAL PYTHON NOTEBOOK CODE that shows you how to do everything on this tutorial blog post,
    • To ask data science questions to me and other data scientists,
    • To have access to a community of data scientists that will help you debug your code and help you with your data science projects, and
    • To get access to other data science tutorial content and data science courses.

Step 16: Join my data science email list below and receive tutorial data science content in your inbox

Step 17: Follow me on twitter

Step 18: Comment below to let me know what you think of this tutorial.

13 Comments

  • I am getting a error stating , UnicodeEncodeError: ‘latin-1’ codec can’t encode characters in position 0-9: ordinal not in range(256), anyone got a solution

    Reply
    • That is correct. Last time I checked, they no longer have the add-on which makes me very sad.

      Reply
      • Thanks for the reply. While it didn’t work out, I found your step-by-step explanation easy to follow. Do you know of any alternative? I tried plotlys chart editor and deck software but it is not great.

        Reply
        • Unfortunately, I don’t know of an alternative. I have been searching for an alternative, but haven’t found one yet.

          I might do a tutorial on plotly chart deck in the future though and add it to this blog post as an alternative.

          Reply
          • Evidence,
            Thanks for sharing your ideas and work. There is an easy alternative.
            This alternative is Microsoft own Web Vie
            1. Open your powerpoint.
            2. Go to “Insert” tab and under Add-Ins click “Store”, go to ‘MY ADD-INS”, use the search bar to locate “Web Viewer”
            3. Add “Web Viewer”
            4. Go to the Web Viewer Add-in and paste your link. Click preview.

            Note: This Add-in should permanently be in My Add-Ins Ribbon within the “Insert” tab and you would not need to re-install it.

            Hope this helps

            Reply
  • I am unable to find the add in for plotly as well. Nothing shows upon search. I am using MSOffice 365.

    Reply
  • I tried this in the anaconda environment, I use Jupyter notebooks, but I get an error after step 7 “The `figure_or_data` positional argument must be `dict`-like, `list`-like, or an instance of plotly.graph_objs.Figure”

    My code (using pyplot with cufflinks):
    plot1=df.iplot(kind=’scatter’,x=’A’,y=’B’,mode=’markers’,size=10)
    py.plot(plot1, filename=’my very first live plot’, auto_open=True)

    Reply
    • I think the problem is in your “plot1”. The result of plot1 is not a dictionary, list, or a plotly graph. Try changing plot1 to just a plotly scatter graph without using cufflinks just like i did in the example tutorial to see if that works. If py.plot works with just a regular plotly graph without cufflinks, then you know the problem is the way you currently have your code structured which is (df.iplot(kind=’scatter’,x=’A’,y=’B’,mode=’markers’,size=10))

      Try printing the result of plot1 to see the “data structure”. That is to see the structure of the data that is supposed to be used for the graph. It could be that it is structured as a dictionary in a list or a list within a dictionary or some other weird structure.

      Try just plotting plot1 by itself to see if the graph works. If the graph works independently, then you know it might be a problem with cufflinks not working very nicely with plotly chart studio.

      Just try different things and let me know the results ?

      Reply
      • The add in inside word 2019 not working. After pasting the url when clicking insert button nothing happens. I think there is an issue or the plugin is not updated.

        Reply

Leave a Comment

Scroll to Top