I think I have a solution for this. First, you need to download the open source file Plotly.js. Then I have a function written below that will call javascript from the python graph and reference your local copy of plotly-latest.min.js. See below:
import sys import os from plotly import session, tools, utils import uuid import json def get_plotlyjs(): path = os.path.join('offline', 'plotly.min.js') plotlyjs = resource_string('plotly', path).decode('utf-8') return plotlyjs def js_convert(figure_or_data,outfilename, show_link=False, link_text='Export to plot.ly', validate=True): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) width = figure.get('layout', {}).get('width', '100%') height = figure.get('layout', {}).get('height', 525) try: float(width) except (ValueError, TypeError): pass else: width = str(width) + 'px' try: float(width) except (ValueError, TypeError): pass else: width = str(width) + 'px' plotdivid = uuid.uuid4() jdata = json.dumps(figure.get('data', []), cls=utils.PlotlyJSONEncoder) jlayout = json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) config = {} config['showLink'] = show_link config['linkText'] = link_text config["displaylogo"]=False config["modeBarButtonsToRemove"]= ['sendDataToCloud'] jconfig = json.dumps(config) plotly_platform_url = session.get_session_config().get('plotly_domain', 'https://plot.ly') if (plotly_platform_url != 'https://plot.ly' and link_text == 'Export to plot.ly'): link_domain = plotly_platform_url\ .replace('https://', '')\ .replace('http://', '') link_text = link_text.replace('plot.ly', link_domain) script = '\n'.join([ 'Plotly.plot("{id}", {data}, {layout}, {config}).then(function() {{', ' $(".{id}.loading").remove();', '}})' ]).format(id=plotdivid, data=jdata, layout=jlayout, config=jconfig) html="""<div class="{id} loading" style="color: rgb(50,50,50);"> Drawing...</div> <div id="{id}" style="height: {height}; width: {width};" class="plotly-graph-div"> </div> <script type="text/javascript"> {script} </script> """.format(id=plotdivid, script=script, height=height, width=width)
The key lines that take away all the links are:
config['showLink'] = show_link #False .... config["modeBarButtonsToRemove"]= ['sendDataToCloud']
You would call fuction as such to get a static HTML file that references your local copy of the open source conspiracy library:
fig = { "data": [{ "x": [1, 2, 3], "y": [4, 2, 5] }], "layout": { "title": "hello world" } } js_convert(fig, 'test.html')