-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
multi_scale.py
35 lines (25 loc) · 1.1 KB
/
multi_scale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'''This example shows a graph with multiple scales on y-axis.
This can be used to depict values in two different units.
.. bokeh-example-metadata::
:apis: bokeh.plotting.figure.line, bokeh.plotting.figure.circle, bokeh.plotting.figure.add_layout
:keywords: scale
'''
from bokeh.io import show
from bokeh.models import LinearAxis, LinearScale, Range1d
from bokeh.plotting import figure
source = {
"t": [0, 1, 2, 3, 4],
"v": [1, 10, 100, 1000, 10000],
}
f = figure(y_axis_type="log")
f.yaxis.axis_label = "Log"
f.yaxis.axis_label_text_color = "blue"
f.extra_y_ranges = {"linear": Range1d(-1000, 20000)}
f.extra_y_scales = {"linear": LinearScale()}
ax = LinearAxis(y_range_name="linear", axis_label="Linear", axis_label_text_color="red")
f.add_layout(ax, "left")
f.line(x="t", y="v", line_width=2, source=source, color="blue")
f.circle(x="t", y="v", size=5, line_width=2, source=source, color="blue")
f.line(x="t", y="v", line_width=2, source=source, y_range_name="linear", color="red")
f.circle(x="t", y="v", size=5, line_width=2, source=source, y_range_name="linear", color="red")
show(f)