Created
January 21, 2020 09:40
-
-
Save whiledoing/89a1b79389dfd3fb7112747559c7cfdb to your computer and use it in GitHub Desktop.
[bokeh-snippets] bokeh snippets #python #bokeh #visualization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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