- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的 Django 元素中嵌入了一个 Bokeh 图表,效果很好,但我在使用它创建的嵌入时遇到了问题。我将模板中的脚本和 div 作为 {{ div |安全 }}
和 {{ script |安全 }
} 但 div 在我的模板上创建了一个大的空白区域。
有什么想法吗?
Here's an image of how it looks in the browser
And here's the div which is really long for some reason
脚本:
<script type="text/javascript">
(function() {
var fn = function() {
Bokeh.safely(function() {
(function(root) {
function embed_document(root) {
var docs_json = {"998040af-6ec7-4d0a-9512-892e668e543b":{"roots":{"references":[{"attributes":{},"id":"39af7b08-c2a0-4239-8140-5fb6715147c3","type":"ResetTool"},{"attributes":{},"id":"66fe871a-6ed6-485c-8785-2348adf6114e","type":"SaveTool"},{"attributes":{"active_drag":"auto","active_inspect":"auto","active_scroll":"auto","active_tap":"auto","tools":[{"id":"5974d4bb-2135-4a2a-ae1d-33193cf46b77","type":"PanTool"},{"id":"4d082f4c-d578-4258-ada6-3f36133784c8","type":"WheelZoomTool"},{"id":"9faa6e3c-28e7-497a-a09a-d8ca67e6dffd","type":"BoxZoomTool"},{"id":"66fe871a-6ed6-485c-8785-2348adf6114e","type":"SaveTool"},{"id":"39af7b08-c2a0-4239-8140-5fb6715147c3","type":"ResetTool"},{"id":"07186e88-4a07-43f0-8246-0e4dd3ac404e","type":"HelpTool"}]},"id":"66619cf2-604a-43ed-b139-0b376222a87e","type":"Toolbar"},{"attributes":{"callback":null},"id":"451449e3-c761-4c57-a674-8b1b5a37f378","type":"DataRange1d"},{"attributes":{"callback":null},"id":"e0c60293-c503-4885-af6b-132872d94c5c","type":"DataRange1d"},{"attributes":{"below":[{"id":"c419969e-5741-4736-90de-34259d29a726","type":"LinearAxis"}],"border_fill_color":{"value":"whitesmoke"},"left":[{"id":"5e62dbcd-09f9-410b-9b19-c8f420b90bfb","type":"LinearAxis"}],"plot_height":150,"plot_width":400,"renderers":[{"id":"c419969e-5741-4736-90de-34259d29a726","type":"LinearAxis"},{"id":"42ac392d-f455-4528-95e3-f940470c065b","type":"Grid"},{"id":"5e62dbcd-09f9-410b-9b19-c8f420b90bfb","type":"LinearAxis"},{"id":"120afe85-61ea-4894-8366-9d5b0887adde","type":"Grid"},{"id":"5ba3c58f-6a2a-4af8-bb1a-bb6add5cc76d","type":"BoxAnnotation"},{"id":"d5d3beda-b199-4e31-a82a-4ca59930767d","type":"GlyphRenderer"}],"sizing_mode":"scale_width","title":{"id":"01d880cf-b868-49b4-b91b-bec60d5de6d2","type":"Title"},"toolbar":{"id":"66619cf2-604a-43ed-b139-0b376222a87e","type":"Toolbar"},"x_range":{"id":"e0c60293-c503-4885-af6b-132872d94c5c","type":"DataRange1d"},"x_scale":{"id":"8a36f571-dd09-4aed-980c-e19037c9b24a","type":"LinearScale"},"y_range":{"id":"451449e3-c761-4c57-a674-8b1b5a37f378","type":"DataRange1d"},"y_scale":{"id":"9da9e3b4-e359-4786-bd7c-daf86e94c3bf","type":"LinearScale"}},"id":"77eaaafa-b380-4c45-832a-65faea06bb98","subtype":"Figure","type":"Plot"},{"attributes":{},"id":"07186e88-4a07-43f0-8246-0e4dd3ac404e","type":"HelpTool"},{"attributes":{},"id":"d5ced699-d662-4c31-9b6a-793d97c998c8","type":"BasicTickFormatter"},{"attributes":{"formatter":{"id":"0da65dd3-5702-4c74-91e1-71733066a74f","type":"BasicTickFormatter"},"plot":{"id":"77eaaafa-b380-4c45-832a-65faea06bb98","subtype":"Figure","type":"Plot"},"ticker":{"id":"41d2e0a6-2feb-4437-bb35-efcea6c1c813","type":"BasicTicker"}},"id":"c419969e-5741-4736-90de-34259d29a726","type":"LinearAxis"},{"attributes":{"data_source":{"id":"2e6d3a2c-3d54-4b8a-984d-9d620aa7febe","type":"ColumnDataSource"},"glyph":{"id":"e0d6dab9-8df6-4abb-b825-b273548f408a","type":"MultiLine"},"hover_glyph":null,"muted_glyph":null,"nonselection_glyph":{"id":"75db6381-cd4f-4161-9926-ec219d3bd761","type":"MultiLine"},"selection_glyph":null,"view":{"id":"f8571075-8034-434f-9579-5197405959a9","type":"CDSView"}},"id":"d5d3beda-b199-4e31-a82a-4ca59930767d","type":"GlyphRenderer"},{"attributes":{"source":{"id":"2e6d3a2c-3d54-4b8a-984d-9d620aa7febe","type":"ColumnDataSource"}},"id":"f8571075-8034-434f-9579-5197405959a9","type":"CDSView"},{"attributes":{"plot":{"id":"77eaaafa-b380-4c45-832a-65faea06bb98","subtype":"Figure","type":"Plot"},"ticker":{"id":"41d2e0a6-2feb-4437-bb35-efcea6c1c813","type":"BasicTicker"}},"id":"42ac392d-f455-4528-95e3-f940470c065b","type":"Grid"},{"attributes":{},"id":"0da65dd3-5702-4c74-91e1-71733066a74f","type":"BasicTickFormatter"},{"attributes":{"line_alpha":{"value":0.1},"line_color":{"value":"#1f77b4"},"line_width":{"value":4},"xs":{"field":"xs"},"ys":{"field":"ys"}},"id":"75db6381-cd4f-4161-9926-ec219d3bd761","type":"MultiLine"},{"attributes":{"callback":null,"column_names":["xs","ys","line_color","line_alpha"],"data":{"line_alpha":[0.8,0.3],"line_color":["firebrick","navy"],"xs":[[1,3,2],[3,4,6,6]],"ys":[[2,1,4],[4,7,8,5]]}},"id":"2e6d3a2c-3d54-4b8a-984d-9d620aa7febe","type":"ColumnDataSource"},{"attributes":{"formatter":{"id":"d5ced699-d662-4c31-9b6a-793d97c998c8","type":"BasicTickFormatter"},"plot":{"id":"77eaaafa-b380-4c45-832a-65faea06bb98","subtype":"Figure","type":"Plot"},"ticker":{"id":"132532f4-248b-4037-9069-7d27a093e89a","type":"BasicTicker"}},"id":"5e62dbcd-09f9-410b-9b19-c8f420b90bfb","type":"LinearAxis"},{"attributes":{"bottom_units":"screen","fill_alpha":{"value":0.5},"fill_color":{"value":"lightgrey"},"left_units":"screen","level":"overlay","line_alpha":{"value":1.0},"line_color":{"value":"black"},"line_dash":[4,4],"line_width":{"value":2},"plot":null,"render_mode":"css","right_units":"screen","top_units":"screen"},"id":"5ba3c58f-6a2a-4af8-bb1a-bb6add5cc76d","type":"BoxAnnotation"},{"attributes":{"dimension":1,"plot":{"id":"77eaaafa-b380-4c45-832a-65faea06bb98","subtype":"Figure","type":"Plot"},"ticker":{"id":"132532f4-248b-4037-9069-7d27a093e89a","type":"BasicTicker"}},"id":"120afe85-61ea-4894-8366-9d5b0887adde","type":"Grid"},{"attributes":{"line_alpha":{"field":"line_alpha"},"line_color":{"field":"line_color"},"line_width":{"value":4},"xs":{"field":"xs"},"ys":{"field":"ys"}},"id":"e0d6dab9-8df6-4abb-b825-b273548f408a","type":"MultiLine"},{"attributes":{},"id":"8a36f571-dd09-4aed-980c-e19037c9b24a","type":"LinearScale"},{"attributes":{},"id":"41d2e0a6-2feb-4437-bb35-efcea6c1c813","type":"BasicTicker"},{"attributes":{"plot":null,"text":""},"id":"01d880cf-b868-49b4-b91b-bec60d5de6d2","type":"Title"},{"attributes":{},"id":"132532f4-248b-4037-9069-7d27a093e89a","type":"BasicTicker"},{"attributes":{},"id":"9da9e3b4-e359-4786-bd7c-daf86e94c3bf","type":"LinearScale"},{"attributes":{},"id":"5974d4bb-2135-4a2a-ae1d-33193cf46b77","type":"PanTool"},{"attributes":{},"id":"4d082f4c-d578-4258-ada6-3f36133784c8","type":"WheelZoomTool"},{"attributes":{"overlay":{"id":"5ba3c58f-6a2a-4af8-bb1a-bb6add5cc76d","type":"BoxAnnotation"}},"id":"9faa6e3c-28e7-497a-a09a-d8ca67e6dffd","type":"BoxZoomTool"}],"root_ids":["77eaaafa-b380-4c45-832a-65faea06bb98"]},"title":"Bokeh Application","version":"0.12.10"}};
var render_items = [{"docid":"998040af-6ec7-4d0a-9512-892e668e543b","elementid":"46dc4d68-63cf-4288-aa48-347675c82cc3","modelid":"77eaaafa-b380-4c45-832a-65faea06bb98"}];
root.Bokeh.embed.embed_items(docs_json, render_items);
}
if (root.Bokeh !== undefined) {
embed_document(root);
} else {
var attempts = 0;
var timer = setInterval(function(root) {
if (root.Bokeh !== undefined) {
embed_document(root);
clearInterval(timer);
}
attempts++;
if (attempts > 100) {
console.log("Bokeh: ERROR: Unable to embed document because BokehJS library is missing")
clearInterval(timer);
}
}, 10, root)
}
})(window);
});
};
if (document.readyState != "loading") fn();
else document.addEventListener("DOMContentLoaded", fn);
})();
</script>
分区:
<div class="bk-root">
<div class="bk-plotdiv" id="46dc4d68-63cf-4288-aa48-347675c82cc3"></div>
</div>
最佳答案
你可以添加 .bk-root { height: auto; }
(或 initial
)到你的 CSS 来解决这个问题。 Bokeh 将其根元素的 width
和 height
设置为 100%,以允许 scale_*
和 stretch_*
大小调整模式以填充最大可用空间。但是,纵横比保留模式可能会为您提供类似于此处观察到的结果。
关于python - Bokeh django plot 嵌入 : large amount of white space in generated div tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46994903/
我想更改 plotly(_express) 图中的构面标签。剧情如下: import plotly.express as px tips = px.data.tips() fig = px.scatt
我正在尝试使用 plotly.js 在 map 上绘制数据。我知道您可以通过以下方式获得一个国家/地区的 map : layout = dict( title = '',
关于 this page暗示他们有一些默认的色标,例如“Viridis”。我终其一生都找不到一个网页来记录这些命名的色标是什么。 最佳答案 问题是我是英国人并且正确拼写了颜色。色标可在 https:/
在下面的示例中,我在一个 plotly 子图中有四个箱形图。此示例中的四个箱形图中的每一个都有 3 个变量:股票、债券和现金。在每个箱线图中,我希望股票以相同的颜色(例如蓝色)显示,债券以相同的颜色(
我有一个 plotly plot,当数据发生变化时,我想删除 plot 并生成一个新 plot。为此,我这样做: $('#heatmap2').empty() 然后我重新生成我的 plotly 。但是
有许多问题和答案以一种或另一种方式涉及这个主题。有了这个贡献,我想清楚地说明为什么一个简单的方法,比如 marker = {'color' : 'red'}将适用于 plotly.graph_obje
这可能是一个非常愚蠢的问题,但是当使用 .plot() 绘制 Pandas DataFrame 时,它非常快并且会生成具有适当索引的图形。一旦我尝试将其更改为条形图,它似乎就失去了所有格式并且索引
我用 plotly (express) 生成了很多图像,并将它们以 png 格式保存在本地目录中。我想创建一个带有 plotly dash 的仪表板。我生成的图像有很多依赖关系:这就是我不想将代码包含
最近,我正在学习Plotly express和Altair/Vega-Lite进行交互式绘图。他们两个都令人印象深刻,我想知道他们的优点和缺点是什么。尤其是对于创建交互式地块,它们之间有什么大差异,何
在 plotly 中,我可以创建一个直方图,例如in this example code from the documentation : import plotly.express as px df
来自 Matlab 我正在努力弄清楚为什么以下不起作用: plot(x=rand(10),y=rand(10)) 正确生成图表。 x=rand(10) y=rand(10) plot(x,y) 产生错
我和一位同事一直在尝试设置自定义图例标签,但到目前为止都失败了。下面的代码和详细信息 - 非常感谢任何想法! 笔记本:toy example uploaded here 目标:将图例中使用的默认比率值
我正在使用 Plotly python 库生成一个带有几个 fiddle 图和几个填充散点图的图形。无论什么订单我都有个人fig.add_trace在我的代码中调用, fiddle 图总是在散点图后面
我将图表的大小配置为 Shiny 但图表之间仍有空白区域 它们在配置高度和宽度之前显示为旧区域 这是我的代码 plot1_reactive % layout(xaxis = xaxis,
我想弄清楚如何组织一个包含多个应用程序的破折号项目。所有示例都是单页应用程序,我希望将多个破折号组织为一个项目,由 gunicorn 运行(在 docker 容器内): dash-project/
我之前做了一些解决方法来在 Julia Plotly 中实现精彩的子图,但目前正在努力解决一个更复杂的问题。下面有三种方法可以完成这项工作。 draw1 完美地完成了,但不适用于我的情况,draw2
我的子图之间有很大的空间。在 matplotlib 中,有一种称为紧密布局的布局可以消除这种情况。 plotly 有没有类似的布局?我正在 iPython 笔记本中绘图,因此空间有限。请参阅下图中的空
我正在尝试获取我提前生成的 cbrewer Reds 颜色图。但是,当我尝试使用它时,我仍然得到一些默认的颜色图。我究竟做错了什么?这是 plotly :https://plot.ly/~smirno
我一直在使用 plot.ly 并希望将多个跟踪分组到图例中的同一个键。 我有显示有关特定用户的数据的子图。我想让每个键代表一个用户,而不是 user.data1、user.data2 等。 这是我现在
我有下面这张图,我想把除点和三角形以外的所有东西都去掉,意思是横纵轴上的数字和小竖线,我该怎么做? 这是图片: 这是我的代码: x0 = np.average(triangleEdges,axis=0
我是一名优秀的程序员,十分优秀!