简体   繁体   English

在Bokeh中调整matplotlib标记大小?

[英]Adjust matplotlib marker size in Bokeh?

I was looking at this matplotlib scatter plot example: https://matplotlib.org/examples/shapes_and_collections/scatter_demo.html 我正在看这个matplotlib散点图示例: https : //matplotlib.org/examples/shapes_and_collections/scatter_demo.html

"""
Simple demo of a scatter plot.
"""
import numpy as np
import matplotlib.pyplot as plt


N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radii

plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()

It generates this figure: 它生成此图: 在此处输入图片说明

I tried to accomplish the same in Bokeh by leveraging matplotlib: 我试图通过利用matplotlib在Bokeh中实现相同的目的:

import numpy as np
import matplotlib.pyplot as plt
from bokeh.plotting import output_file, show
from bokeh import mpl

N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radii

plt.scatter(x, y, s=area, c=colors, alpha=0.5)

output_file("scatter_demo.html")

show(mpl.to_bokeh())

But it generates this figure: 但是它产生了这个数字: 在此处输入图片说明

How do I adjust the radii of the circles? 如何调整圆的半径? I'm sure it can be accomplished with pure Bokeh, but I'm looking to do a more advanced plot with Bokeh, which relies on Matplotlib, so I'm looking to use show(mpl.to_bokeh()) . 我敢肯定,可以使用纯Bokeh来实现,但是我希望使用依赖Matplotlib的Bokeh进行更高级的绘制,因此我希望使用show(mpl.to_bokeh()) Thanks! 谢谢!

Also I'm getting this warning, when running the Bokeh script: 当运行Bokeh脚本时,我也收到此警告:

/Users/tc9/lib/python3.6/site-packages/bokeh/core/compat/bokeh_renderer.py:263: UserWarning: Path marker shapes currently not handled, defaulting to Circle
  warnings.warn("Path marker shapes currently not handled, defaulting to Circle")
/Users/tc9/lib/python3.6/site-packages/matplotlib/artist.py:233: MatplotlibDeprecationWarning: get_axes has been deprecated in mpl 1.5, please use the
axes property.  A removal date has not been set.
  stacklevel=1)

EDIT: The equivalent Bokeh demo example of a scatter plot is here: http://docs.bokeh.org/en/latest/docs/gallery/color_scatter.html 编辑:散点图的等效Bokeh演示示例在这里: http : //docs.bokeh.org/en/latest/docs/gallery/color_scatter.html

It produces this figure: 它产生此图: 在此处输入图片说明

I am compelled to advise you that as of Bokeh 0.12.5 (to be released later this week), Bokeh's MPL compat support is being wholly deprecated. 我不得不告诉您,从Bokeh 0.12.5 (本周晚些时候发布)开始,Bokeh的MPL compat支持将被完全弃用。 It will be removed completely on the occasion of Bokeh 1.0 and will receive no updates in the intervening time (all examples and docs that relate to it are also removed). 在Bokeh 1.0时,它将被完全删除,并且在此期间将不会收到任何更新(与之相关的所有示例和文档也都将被删除)。

It's possible that in the future a rigorous and standardized MPL JSON standard will enable a new separate project to provide this capability in a maintainable way. 将来,严格而标准化的MPL JSON标准很有可能使新的独立项目以可维护的方式提供此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM