Open the HTML file, search for modeBarButtonsToRemove:[]
then replace with the buttons you want removed, for my purpose modeBarButtonsToRemove:['sendDataToCloud']
To remove the Plotly Logo and link, search for displaylogo:!0
and replace with displaylogo:!1
Here is a demo using Python:
from plotly.offline import plot
import plotly.graph_objs as go
import webbrowser
import numpy as np
import pandas as pd
# generate your Plotly graph here
N = 500
y = np.linspace(0, 1, N)
x = np.random.randn(N)
df = pd.DataFrame({'x': x, 'y': y})
data = [go.Histogram(x=df['x'])]
# plot it for offline editing
HTMLlink = plot(data, show_link=False, auto_open=False)[7:] #remove the junk characters
# now need to open the HTML file
with open(HTMLlink, 'r') as file :
tempHTML = file.read()
# Replace the target strings
tempHTML = tempHTML.replace('displaylogo:!0', 'displaylogo:!1')
tempHTML = tempHTML.replace('modeBarButtonsToRemove:[]', 'modeBarButtonsToRemove:["sendDataToCloud"]')
with open(HTMLlink, 'w') as file:
file.write(tempHTML)
del tempHTML
webbrowser.open(HTMLlink)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…