首先我检查了这个帖子 https:/github.comotlyplotly.pyissues1736。
但我不能从我的热图中禁用一切,所以如果我想删除一切,只保留图像,我可以做什么,我需要设置什么额外的参数?我在google colab笔记本上工作,我在我的Python代码中尝试了一些东西,我用iplot绘制......。在iplot之前,我需要用plotly-orca保存文件。(基本上我需要删除x_axis数字,y_axis数字和右边的color_bar)
import scipy.io.wavfile as wavfile
import plotly
import plotly.graph_objs as go
[Fs, s] = wavfile.read('wavfile.wav')
# here there is a function that exports the data for the heatmap
layout = go.Layout(xaxis_showgrid=False, yaxis_showgrid=False, xaxis_zeroline=False, yaxis_zeroline=False)
...
heatmap = go.Heatmap(z=S, y=f, x=t)
figure = go.Figure(data=[heatmap],layout=layout)
figure.write_image(str(name)+'.png')
figure = {'data': [heatmap],
'layout': {'xaxis_showgrid':False,
'yaxis_showgrid':False,
'xaxis_zeroline':False,
'yaxis_zeroline':False}}
iplot(figure)
你正在寻找类似下面的东西吗?
import numpy as np
import plotly.graph_objs as go
matrix = np.random.randn(10, 10)
ticks = ["tick %i" % i for i in range(10)]
trace = go.Heatmap(z=matrix,
x=ticks,
y=ticks,
colorscale='Viridis',
showscale=False)
layout = dict(xaxis_showgrid=False,
xaxis_zeroline=False,
xaxis_showticklabels=False,
yaxis_showgrid=False,
yaxis_zeroline=False,
yaxis_showticklabels=False)
fig = go.Figure(data=trace, layout=layout)
fig.show()
如果你想去掉margin,你可以添加 margin=dict(t=0,b=0,l=0,r=0)
到布局。