如果您使用plotly
4.2版,则不再需要import plotly.offline
,而只需在使用Plotly Express或fig.show()
创建的图形上调用go.Figure()
。新的渲染器框架具有特定于Databricks的渲染器:)
此处提供完整文档:https://plot.ly/python/renderers/和https://plot.ly/python/creating-and-updating-figures/
,
从查看the docs开始,您必须指定output_type='div'
并将绘图对象传递给displayHTML()
。这是Python笔记本或单元中的一个有效示例:
## Install & import plotly
!pip install plotly
from plotly.offline import plot
import plotly.graph_objs as go
import numpy as np
x = np.random.randn(2000)
y = np.random.randn(2000)
# Instead of simply calling plot(...),store your plot as a variable and pass it to displayHTML().
# Make sure to specify output_type='div' as a keyword argument.
# (Note that if you call displayHTML() multiple times in the same cell,only the last will take effect.)
p = plot(
[
go.Histogram2dContour(x=x,y=y,contours=dict(coloring='heatmap')),go.Scatter(x=x,mode='markers',marker=dict(color='white',size=3,opacity=0.3))
],output_type='div'
)
displayHTML(p)
本文链接:https://www.f2er.com/3141014.html