annotate example/iris.py @ 187:8aec5ebb2d19

whitespace
author Jeff Hammel <k0scist@gmail.com>
date Fri, 21 Jul 2017 12:50:17 -0700
parents 4372fb852384
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
171
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 from bokeh.sampledata.iris import flowers
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 from bokeh.plotting import *
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 output_file("iris.html", title="iris.py example")
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 colormap = {'setosa': 'red', 'versicolor': 'green', 'virginica': 'blue'}
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 flowers['color'] = flowers['species'].map(lambda x: colormap[x])
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 #setting the name kwarg will give this scatter plot a user
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 #friendly id, and the corresponding embed.js will have a nice name
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 #too
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 scatter(flowers["petal_length"], flowers["petal_width"],
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 color=flowers["color"], fill_alpha=0.2, size=10, name="iris")
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
4372fb852384 add example file
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 show()