@@ -210,7 +210,7 @@ class BOKEHLinePlot(BOKEHPlot, LinePlot):
210
210
211
211
@classmethod
212
212
@APPEND_PLOT_DOC
213
- def plot (cls , fig , data , x , y , by : str | None = None , ** kwargs ):
213
+ def plot (cls , fig , data , x , y , by : str | None = None , plot_3d = False , ** kwargs ):
214
214
"""
215
215
Plot a line plot
216
216
"""
@@ -219,7 +219,7 @@ def plot(cls, fig, data, x, y, by: str | None = None, **kwargs):
219
219
if by is None :
220
220
source = ColumnDataSource (data )
221
221
if color_gen is not None :
222
- kwargs ["line_color" ] = next (color_gen )
222
+ kwargs ["line_color" ] = color_gen if isinstance ( color_gen , str ) else next (color_gen )
223
223
line = fig .line (x = x , y = y , source = source , ** kwargs )
224
224
225
225
return fig , None
@@ -229,7 +229,7 @@ def plot(cls, fig, data, x, y, by: str | None = None, **kwargs):
229
229
for group , df in data .groupby (by ):
230
230
source = ColumnDataSource (df )
231
231
if color_gen is not None :
232
- kwargs ["line_color" ] = next (color_gen )
232
+ kwargs ["line_color" ] = color_gen if isinstance ( color_gen , str ) else next (color_gen )
233
233
line = fig .line (x = x , y = y , source = source , ** kwargs )
234
234
legend_items .append ((group , [line ]))
235
235
@@ -245,30 +245,17 @@ class BOKEHVLinePlot(BOKEHPlot, VLinePlot):
245
245
246
246
@classmethod
247
247
@APPEND_PLOT_DOC
248
- def plot (cls , fig , data , x , y , by : str | None = None , ** kwargs ):
248
+ def plot (cls , fig , data , x , y , by : str | None = None , plot_3d = False , ** kwargs ):
249
249
"""
250
250
Plot a set of vertical lines
251
251
"""
252
252
color_gen = kwargs .pop ("line_color" , None )
253
253
if color_gen is None :
254
254
color_gen = ColorGenerator ()
255
255
data ["line_color" ] = [next (color_gen ) for _ in range (len (data ))]
256
- if by is None :
257
- source = ColumnDataSource (data )
258
- line = fig .segment (
259
- x0 = x ,
260
- y0 = 0 ,
261
- x1 = x ,
262
- y1 = y ,
263
- source = source ,
264
- line_color = "line_color" ,
265
- ** kwargs ,
266
- )
267
- return fig , None
268
- else :
269
- legend_items = []
270
- for group , df in data .groupby (by ):
271
- source = ColumnDataSource (df )
256
+ if not plot_3d :
257
+ if by is None :
258
+ source = ColumnDataSource (data )
272
259
line = fig .segment (
273
260
x0 = x ,
274
261
y0 = 0 ,
@@ -278,11 +265,27 @@ def plot(cls, fig, data, x, y, by: str | None = None, **kwargs):
278
265
line_color = "line_color" ,
279
266
** kwargs ,
280
267
)
281
- legend_items .append ((group , [line ]))
282
-
283
- legend = Legend (items = legend_items )
284
-
285
- return fig , legend
268
+ return fig , None
269
+ else :
270
+ legend_items = []
271
+ for group , df in data .groupby (by ):
272
+ source = ColumnDataSource (df )
273
+ line = fig .segment (
274
+ x0 = x ,
275
+ y0 = 0 ,
276
+ x1 = x ,
277
+ y1 = y ,
278
+ source = source ,
279
+ line_color = "line_color" ,
280
+ ** kwargs ,
281
+ )
282
+ legend_items .append ((group , [line ]))
283
+
284
+ legend = Legend (items = legend_items )
285
+
286
+ return fig , legend
287
+ else :
288
+ raise NotImplementedError ("3D Vline plots are not supported in Bokeh" )
286
289
287
290
def _add_annotations (
288
291
self ,
@@ -312,7 +315,7 @@ class BOKEHScatterPlot(BOKEHPlot, ScatterPlot):
312
315
313
316
@classmethod
314
317
@APPEND_PLOT_DOC
315
- def plot (cls , fig , data , x , y , by : str | None = None , ** kwargs ):
318
+ def plot (cls , fig , data , x , y , by : str | None = None , plot_3d = False , ** kwargs ):
316
319
"""
317
320
Plot a scatter plot
318
321
"""
@@ -466,16 +469,19 @@ class BOKEHPeakMapPlot(BOKEH_MSPlot, PeakMapPlot):
466
469
"""
467
470
468
471
def create_main_plot (self , x , y , z , class_kwargs , other_kwargs ):
469
- scatterPlot = self .get_scatter_renderer (self .data , x , y , ** class_kwargs )
472
+ if not self .plot_3d :
473
+ scatterPlot = self .get_scatter_renderer (self .data , x , y , ** class_kwargs )
470
474
471
- self .fig = scatterPlot .generate (z = z , ** other_kwargs )
475
+ self .fig = scatterPlot .generate (z = z , ** other_kwargs )
472
476
473
- if self .annotation_data is not None :
474
- self ._add_box_boundaries (self .annotation_data )
477
+ if self .annotation_data is not None :
478
+ self ._add_box_boundaries (self .annotation_data )
475
479
476
- tooltips , _ = self ._create_tooltips ({self .xlabel : x , self .ylabel : y , "intensity" : z })
480
+ tooltips , _ = self ._create_tooltips ({self .xlabel : x , self .ylabel : y , "intensity" : z })
477
481
478
- self ._add_tooltips (self .fig , tooltips )
482
+ self ._add_tooltips (self .fig , tooltips )
483
+ else :
484
+ raise NotImplementedError ("3D PeakMap plots are not supported in Bokeh" )
479
485
480
486
def create_x_axis_plot (self , x , z , class_kwargs ):
481
487
x_fig = super ().create_x_axis_plot (x , z , class_kwargs )
0 commit comments