Skip to content

Instantly share code, notes, and snippets.

@whiledoing
Created January 21, 2020 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whiledoing/89a1b79389dfd3fb7112747559c7cfdb to your computer and use it in GitHub Desktop.
Save whiledoing/89a1b79389dfd3fb7112747559c7cfdb to your computer and use it in GitHub Desktop.
[bokeh-snippets] bokeh snippets #python #bokeh #visualization
import numpy as np
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
# Call once to configure Bokeh to display plots inline in the notebook.
output_notebook()
N = 4000
x = np.random.random(size=N) * 100
y = np.random.random(size=N) * 100
radii = np.random.random(size=N) * 1.5
# x越大,红色越多;y越大,绿色越多;构造递增的颜色频谱
colors = ["#%02x%02x%02x" % (r, g, 150) for r, g in zip(np.floor(50+2*x).astype(int), np.floor(30+2*y).astype(int))]
p = figure()
p.circle(x, y, radius=radii, fill_color=colors, fill_alpha=0.6, line_color=None)
show(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment