打开HTML文件,搜索
modeBarButtonsToRemove:[]然后替换为您要删除的按钮
modeBarButtonsToRemove:['sendDataToCloud']
要删除Plotly徽标和链接,请搜索
displaylogo:!0并替换为
displaylogo:!1
这是使用Python的演示:
from plotly.offline import plotimport plotly.graph_objs as goimport webbrowserimport numpy as npimport pandas as pd# generate your Plotly graph hereN = 500y = 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 editingHTMLlink = plot(data, show_link=False, auto_open=False)[7:] #remove the junk characters# now need to open the HTML filewith open(HTMLlink, 'r') as file : tempHTML = file.read()# Replace the target stringstempHTML = tempHTML.replace('displaylogo:!0', 'displaylogo:!1')tempHTML = tempHTML.replace('modeBarButtonsToRemove:[]', 'modeBarButtonsToRemove:["sendDataToCloud"]')with open(HTMLlink, 'w') as file: file.write(tempHTML)del tempHTMLwebbrowser.open(HTMLlink)


