[英]Plotly Heatmap Show only the image and save it
首先我检查了这篇文章https://github.com/plotly/plotly.py/issues/1736
但是我无法从我的热图中禁用所有内容,所以如果我想删除所有内容并只保留图像我能做什么,我需要设置哪些额外的参数? 我正在使用 google colab notebook,我在我的 Python 代码中尝试了一些东西 I plot 与 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=dict(t=0,b=0,l=0,r=0)
添加到布局中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.