- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 plotly 在我的图表上获取背景图像。如果不使用其中一个 images.plot.ly 链接,我似乎无法显示任何图像。我在与项目相同的文件夹中尝试了 Web URL 和本地镜像。这就是我使用他们教程中的图片 URL 时显示的内容:
https://plot.ly/python/images/
这是我唯一一次可以让任何东西出现。任何其他链接都不会在图表上产生任何内容。有小费吗?我已经为此搜索了高低。
layout = dict(title = 'Crime Cluster Statistics',
yaxis = dict(zeroline = False),
xaxis = dict(zeroline = False),
images= [dict(
source= "https://images.plot.ly/language-icons/api-home/python-logo.png",
xref= "x",
yref= "y",
x= 0,
y= 3,
sizex= 150000,
sizey= 150000,
sizing= "stretch")]
)
我真正想要的是在图像的背景上放置一张美国州的图像,因为这些点应该代表该州 GPS 坐标处的事件。但除了这张之外,我似乎无法将任何图像加载到背景中。
最佳答案
我也在尝试这样做(读取本地镜像并将其作为绘图图的背景)并一直使用它(可能是因为我对整个图像非常陌生并且也在尝试了解 base64 编码)。这是我在 Jupyter 笔记本中使用 plotly 离线的简单解决方案:
import base64
with open("C:/My.png", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode()
#add the prefix that plotly will want when using the string as source
encoded_image = "data:image/png;base64," + encoded_string
现在您的绘图图布局可能如下所示(在这种情况下 - 请记住,您正在使用图中的实际数据范围来放置图像,因此 x 和 Y 必须在合适的范围):
"layout": Layout(title='Graph Title',
yaxis=dict(title='Y Label'),
xaxis=dict(title='X Label'),
images=[dict(
source= encoded_image,
xref= "x",
yref= "y",
x= 0,
y= 10,
sizex= 20,
sizey= 10,
sizing= "stretch",
opacity= 0.7,
layer= "below")])
关于python - 剧情背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50111539/
我知道如何设置条形图中条形的宽度: fig = go.Figure(data=[go.Bar(x = ['A', 'B', 'C'], y = [2, 4, 1], width=[0.5]*3)])
我想在 Plotly 后端使用 latex 。看看这个例子:即使是 x 轴和 y 轴的对数刻度也没有正确格式化!你知道怎么做吗? 最好的, 诉 using Plots, LaTeXStrings pl
我在使用 minMaxLoc 时遇到了一些麻烦,当我尝试将点作为引用传递给 max_Loc 时,我遇到了错误。环顾四周后,我发现了很多人使用 double 而不是点的例子,但这里不是这种情况。 这里是
在绘图中,如何用不同的颜色为高于阈值的所有值着色?就像上面的mean + std 或mean + 2*std 一样? 最佳答案 使用 LineCollection是正确的方法,但您也可以使用屏蔽数组在
当鼠标悬停在我的图表上时,我需要 x 轴值。根据 plotly 文档 ( https://plot.ly/javascript/hover-events/ ),悬停事件回调应该包含字段“points”
当通过 Javascript API(plotly.js,而不是 plotly-nodejs)使用任何类型的 plotly 图表时,我如何才能在图表加载后运行一些 javascript?我正在寻找 p
数据框: df2 = data.frame(value = c(9, 2, 7, 3, 6), key = c('ar', 'or', 'br', 'gt', 'ko
在下面的代码中,我有一个包含 4 列(“data”、“valor”、“nome”和“total”)的数据框。变量 'text' 将列 'nome' 设置为标签。现在我需要对“总计”列做同样的事情,我也
我是一名优秀的程序员,十分优秀!