1

I was looking at this matplotlib scatter plot example: 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: enter image description here

I tried to accomplish the same in Bokeh by leveraging matplotlib:

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: enter image description here

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()). Thanks!

Also I'm getting this warning, when running the Bokeh script:

/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

It produces this figure: enter image description here

bigreddot
  • 33,642
  • 5
  • 69
  • 122
tommy.carstensen
  • 8,962
  • 15
  • 65
  • 108

1 Answers1

2

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. 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).

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.

bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • I'll resort fully to Bokeh and try to achieve similar looking plots with it. Matplotlib can't handle millions of points anyway. I need to look into Datashader for this. Bokeh is cool! Thanks for developing it! Learning curve not too steep. – tommy.carstensen Mar 21 '17 at 11:53
  • Thanks for the kind words. Please drop by the mailing list if we can ever help https://groups.google.com/a/continuum.io/forum/#!forum/bokeh – bigreddot Mar 21 '17 at 12:33