- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个多面板 Bokeh 图,使用 Bokeh 服务器(Bokeh 0.12.14)渲染。我正在运行一个带有按钮小部件 (on_click()
) 的函数,该函数修改我的 gridplot
布局、添加一些标签并导出自定义的 .png 图像。在函数中,我使用 curdoc().hold()
,然后使用 curdoc().clear
,对图形进行修改并构建一个新的 gridplot
。然后,我将 curdoc().add_root(gridplot)
与修改后的 gridplot 布局一起使用,并运行 export_png(curdoc())
。
导出后,我再次运行 curdoc().clear()
,重建原始 gridplot
布局,并使用 curdoc() 恢复原始文档.add_root(gridplot)
。最后以 curdoc().unhold()
结束。
一切正常,除了我不知道如何删除为 .png 导出创建的自定义标签。我添加了几个标签,例如:
season_label = Label(x=start_display, y=35, x_units='data', y_units='data',
text= '%s - %s' % (starting_year, starting_year+1),
render_mode='css', text_font_style='bold',
text_font_size='14px', text_baseline='middle', text_align='left')
newsnow_extra_fig.add_layout(season_label)
有没有办法从图中删除布局?
最佳答案
作为一种解决方法,我发现可以将文本注释添加为 Div widgets ,而不是 Labels 。然后,我使用 gridplot() 在预期图形的上方或下方添加小部件。例如:
div_1 = bkm.widgets.Div(text="""My text annotation {} - {}""".format(starting_year, starting_year+1),
width=1400, height=27, style={'background-color':'white'})
div_wb_1 = widgetbox(div_1)
grid = gridplot(div_wb_1,
fig_1,
fig_2,
div_wb_2,
ncols=1)
导出 .png 后,我可以通过重新定义没有 div 小部件框的 grid
来重建原始文档:
grid = gridplot(fig_1,
fig_2,
ncols=1)
但是,当我将 gridplot()
(包括 div)添加到 curdoc()
,然后 export_png(curdoc())
,div 小部件和图形之间的背景是透明的(即使在 html 中定义了 'background-color':'white'
)——我需要整个 .png 的白色背景。为了解决这个问题,我打开图像,使用 PIL(Python 图像库)将背景编辑为白色,然后重新保存图像。对于点击“导出图像”小部件按钮的客户端来说,这使得整个服务器端过程比我希望的要慢得多。
我将其发布为我自己问题的答案,因为它解决了问题,但是如果可能的话,简单地从图中删除标签布局会很棒!
仅供引用,here是我的网络应用程序,使用此答案来实现“导出图像”按钮的功能。
关于python - 更新 curdoc() 后从 Bokeh Fig 中删除 Label 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48912681/
我试图在字符串中显示 sig figs,我找到了 '{:.2f}'.format(x) 样式,只要我有sig figs 在代码中作为整数,但如果 sig figs 的数量包含在变量中,我似乎无法使这种
我正在尝试将 png 图像添加到使用 python 中的 matplotlib 创建的绘图中。 这是我的剧情代码 import matplotlib as mpl mpl.use('Agg') imp
我没怎么用过 Matplotlib。根据某人的建议,我尝试尽可能多地使用面向对象的范例编写一些绘图代码---因此尝试使用纯 Matplotlib(即不依赖 pyplot)来生成一些简单的图形。 我的代
我问并回答了我自己的问题,所以我会把它贴在这里以防万一 如果您想要 Rmarkdown 或 Bookdown 中的数字表格,并且您想使用 Markdown 格式,则不能将其放在 Rmarkdown 块
对于 pdf 图形, fig.width 和 fig.height 块选项仅更改我的 Word 文档中 2"x2"图形的比例。我似乎无法控制 pdf 图形的大小,因为我可以使用从 R Markdown
经过多次搜索,我发现了很多与此类似的问题,但是我仍然无法得到copyobj()简单地复制一个特定的子对象/句柄。 (注意:我是 MATLAB 图形的新手,所以我对图形/句柄的术语/理解可能有误。请随时
我有一个用于启动的 fig 配置 电话 docker 容器(app、redis、mongo、postgre 等...) 当我跑 fig up一切都好。 Name Command
我正在使用 fig 通过 boot2docker 主机 vm 挂载我的 OS X 目录。我正在使用已经提供的用户目录。尝试以下操作: /code/Tryme.txt - “你好” 卷:/Users//
考虑以下玩具示例: import numpy as np d = np.random.rand(160,100) import matplotlib.pyplot as plt fig, ax = p
所以我正在将三个不同的文本 block 写到一个图中: 第一个我想用粗体、大白字写: texttitle = "My Figure" fig.text(0.8, 0.8, texttitle, col
我想编辑保存为 .fig(MATLAB 的默认格式)文件的 MATLAB 图形的某个属性。 我在脚本中创建了很多图形密集型图形,因此我选择不显示它们,方法是使用 set(0,'DefaultFigur
我有一个图形文件 (scatter.fig) 。该图有许多使用 scatter() 的散点绘图仪。现在我只有这个图文件,我需要增加所有散点的标记大小。手动尝试过,但非常困难。 有没有办法我可以做类似的
我有一些代码可以生成许多 MATLAB 图形。在我的程序结束时,我想在报告中发布这些数字。我有一个传递给 publish() 的脚本,它使用 openfig() 将图形包含在文档中。 这会导致这些数字
面向对象的matplotlib的大多数示例都获得带有类似内容的Axis对象 import matplotlib.pyplot as plt fig1 = plt.figure() ax1 = fig1
我已经在Docker的fig.yml文件中配置了Zookeeper和Kafka容器。两个容器都可以正常运行。但是在发送了许多消息之后,我的应用程序/ zk-client挂起了。在检查zookeeper
我正在尝试在 Plotly 中制作一个折线图,带有虚线和标记线。在这种情况下,我希望代表“加拿大”的线被点缀。我已经想出如何更改宽度和颜色,但无法弄清楚如何使线条变成虚线。我原来的 DF 大得多,所以
我已经将一个 matlab 图保存为 .fig 文件,当我试图打开它时它没有打开。我不知道为什么?所以如果有人能帮助我。 这是用来保存图形的代码: h=figure('visible','off');
我正在尝试在 Plotly 中制作一个折线图,带有虚线和标记线。在这种情况下,我希望代表“加拿大”的线被点缀。我已经想出如何更改宽度和颜色,但无法弄清楚如何使线条变成虚线。我原来的 DF 大得多,所以
我有一个简单的 Node 程序app.js 我将包含文件夹的 app.js 文件安装到 Docker 容器中。 当我fig up时,它就起作用了。 但是,当我更改 app.js 的内容并再次执行 fi
我是 Matlab 和 R 的用户。Matlab 的一大优点是,可以将图形保存为 .fig 文件格式。这允许所有用户在以后随时重新打开图形,因此可以对图形进行微小的调整,或者可以以其他格式(jpg、t
我是一名优秀的程序员,十分优秀!