/
__init__.py
158 lines (132 loc) · 5.9 KB
/
__init__.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import numpy as np
from ...core import (Store, Overlay, NdOverlay, Layout, AdjointLayout,
GridSpace, NdElement, GridMatrix, NdLayout)
from ...element import (Curve, Points, Scatter, Image, Raster, Path,
RGB, Histogram, Spread, HeatMap, Contours, Bars,
Box, Bounds, Ellipse, Polygons, BoxWhisker,
ErrorBars, Text, HLine, VLine, Spline, Spikes,
Table, ItemTable, Area, HSV, QuadMesh, GridImage,
VectorField)
from ...core.options import Options, Cycle
try:
from ...interface import DFrame
except:
DFrame = None
from ..plot import PlotSelector
from .annotation import TextPlot, LineAnnotationPlot, SplinePlot
from .callbacks import Callback # noqa (API import)
from .element import OverlayPlot, BokehMPLWrapper
from .chart import (PointPlot, CurvePlot, SpreadPlot, ErrorPlot, HistogramPlot,
SideHistogramPlot, BoxPlot, BarPlot, SpikesPlot,
SideSpikesPlot, AreaPlot, VectorFieldPlot)
from .path import PathPlot, PolygonPlot
from .plot import GridPlot, LayoutPlot, AdjointLayoutPlot
from .raster import (RasterPlot, ImagePlot, RGBPlot, HeatmapPlot,
HSVPlot, QuadMeshPlot)
from .renderer import BokehRenderer
from .tabular import TablePlot
Store.renderers['bokeh'] = BokehRenderer.instance()
associations = {Overlay: OverlayPlot,
NdOverlay: OverlayPlot,
GridSpace: GridPlot,
GridMatrix: GridPlot,
AdjointLayout: AdjointLayoutPlot,
Layout: LayoutPlot,
NdLayout: LayoutPlot,
# Charts
Curve: CurvePlot,
Points: PointPlot,
Scatter: PointPlot,
ErrorBars: ErrorPlot,
Spread: SpreadPlot,
Spikes: SpikesPlot,
Area: AreaPlot,
VectorField: VectorFieldPlot,
# Rasters
Image: RasterPlot,
GridImage: ImagePlot,
RGB: RGBPlot,
HSV: HSVPlot,
Raster: RasterPlot,
HeatMap: HeatmapPlot,
Histogram: HistogramPlot,
QuadMesh: QuadMeshPlot,
# Paths
Path: PathPlot,
Contours: PathPlot,
Path: PathPlot,
Box: PathPlot,
Bounds: PathPlot,
Ellipse: PathPlot,
Polygons: PolygonPlot,
# Annotations
HLine: LineAnnotationPlot,
VLine: LineAnnotationPlot,
Text: TextPlot,
Spline: SplinePlot,
# Tabular
Table: TablePlot,
ItemTable: TablePlot,
NdElement: TablePlot}
if DFrame is not None:
associations[DFrame] = TablePlot
Store.register(associations,
'bokeh')
AdjointLayoutPlot.registry[Histogram] = SideHistogramPlot
AdjointLayoutPlot.registry[Spikes] = SideSpikesPlot
try:
import pandas # noqa (Conditional import)
Store.register({BoxWhisker: BoxPlot,
Bars: BarPlot}, 'bokeh')
except ImportError:
pass
try:
from ..mpl.seaborn import TimeSeriesPlot, BivariatePlot, DistributionPlot
from ...interface.seaborn import Bivariate, TimeSeries, Distribution
Store.register({Distribution: PlotSelector(lambda x: 'bokeh',
[('mpl', DistributionPlot),
('bokeh', BokehMPLWrapper)],
True),
TimeSeries: PlotSelector(lambda x: 'bokeh',
[('mpl', TimeSeriesPlot),
('bokeh', BokehMPLWrapper)],
True),
Bivariate: PlotSelector(lambda x: 'bokeh',
[('mpl', BivariatePlot),
('bokeh', BokehMPLWrapper)], True)},
'bokeh')
except ImportError:
pass
point_size = np.sqrt(6) # Matches matplotlib default
Cycle.default_cycles['default_colors'] = ['#30a2da', '#fc4f30', '#e5ae38',
'#6d904f', '#8b8b8b']
options = Store.options(backend='bokeh')
# Charts
options.Curve = Options('style', color=Cycle(), line_width=2)
options.Scatter = Options('style', color=Cycle(), size=point_size, cmap='hot')
options.Points = Options('style', color=Cycle(), size=point_size, cmap='hot')
options.Histogram = Options('style', line_color='black', fill_color=Cycle())
options.ErrorBars = Options('style', color='black')
options.Spread = Options('style', fill_color=Cycle(), fill_alpha=0.6, line_color='black')
options.Spikes = Options('style', color='black')
options.Area = Options('style', color=Cycle(), line_color='black')
options.VectorField = Options('style', line_color='black')
# Paths
options.Contours = Options('style', color=Cycle())
options.Path = Options('style', color=Cycle())
options.Box = Options('style', color='black')
options.Bounds = Options('style', color='black')
options.Ellipse = Options('style', color='black')
options.Polygons = Options('style', color=Cycle())
# Rasters
options.Image = Options('style', cmap='hot')
options.GridImage = Options('style', cmap='hot')
options.Raster = Options('style', cmap='hot')
options.QuadMesh = Options('style', cmap='hot', line_alpha=0)
options.HeatMap = Options('style', cmap='RdYlBu_r', line_alpha=0)
# Annotations
options.HLine = Options('style', line_color=Cycle(), line_width=3, line_alpha=1)
options.VLine = Options('style', line_color=Cycle(), line_width=3, line_alpha=1)
# Define composite defaults
options.GridMatrix = Options('plot', shared_xaxis=True, shared_yaxis=True,
xaxis=None, yaxis=None)