2

I'm quite new to this forum (and to Python), but I'll do my best to explain the issue coherently! Well, I actually solved it using 2 different methods, still posting as this could be useful to others.

I'm learning python and have recently stumbled accross pyplot and cufflinks (https://plotly.com/python/cufflinks), which I think is a very handy wrapper library around plotly allowing you to use the iplot() and figure() methods straight on panda DF's using the same syntaxe you would for panda's built-in plot() method.

RMQ: I later realized that there's a high level API called plotly Express which also seems easy enough to use and achieves the same goal: https://towardsdatascience.com/how-to-create-a-plotly-visualization-and-embed-it-on-websites-517c1a78568b

Goal 1: upload my pyplot chart to char studio, so I can later share the public link with colleagues through emails, embed the chart into a sharepoint intranet or embed it into a ppt presentation for quarterly review

Goal 2: save my pyplot chart locally as html & either share or embed the interactive chart into a sharepoint intranet or embed it into a ppt presentation for quarterly review

Library & package import

import plotly.express as px import pandas as pd import numpy as np import chart_studio import chart_studio.plotly as py import chart_studio.tools as tls

Write credential file to connect to plotly API

username = 'site username' api_key = 'char studio API key' tls.set_credentials_file(username,api_key)

Code Method 1 (using pyplot + cufflinks):

Pre-requisite: install cufflinks library with cmd pip install cufflinks

Pre-requisite 2: create a plot.ly account & install char studio with cmd pip install chart_studio

df = pd.DataFrame(np.random.randn(100,4),columns='A B C D'.split()) plot1=df.figure(title='My first Live Fig.', xTitle='x Title', yTitle='yTitle', kind='scatter',x='A',y='B',mode='markers',size=10) py.plot(plot1,filename='test figure',auto_open=True)

Code Method 2 (using API Pyplot Express):

Pre-requisite: create a plot.ly account & install char studio with cmd pip install chart_studio

df = pd.DataFrame(np.random.randn(100,4),columns='A B C D'.split()) plot2=px.scatter(x=df['A'], y=df['B']) py.plot(plot2,filename='test figure',auto_open=True)

RMQ1: To store html locally on pc, you can use method plot2.write_html("C:/.../filename.html")

RMQ2: To embed either local html or public URL for pyplot chart to powerpoint, I used the liveweb add-in and followed these useful links to modify the windows registry and allow activeX contents: https://community.tableau.com/thread/145754

Edgar
  • 59
  • 2
  • 8
  • 2
    Great solutions! If you're going to do something like this, though, there is a 'Answer your question' button at the bottom of the page. Please put your answers into an actual answer. It makes them easier to read. – User 12692182 Apr 27 '20 at 18:41
  • As it is now, this is not a question. – Jongware Apr 27 '20 at 18:58

0 Answers0