Can someone give a short/simple example of how to plot a 2D-array with bokeh? Something similar to imshow()
in matplotlib. I did not find a good examples given in the bokeh gallery.
a = np.array([[1,2], [3, 4]])
imshow(a) # but with bokeh
plotting : A high level interface for creating visual glyphs. The dataset used for generating bokeh graphs is collected from Kaggle. To create scatter circle markers, circle() method is used. To create a single line, line() method is used.
Pandas-Bokeh provides a Bokeh plotting backend for Pandas, GeoPandas and Pyspark DataFrames, similar to the already existing Visualization feature of Pandas. Importing the library adds a complementary plotting method plot_bokeh() on DataFrames and Series.
Advertisements. Most of the plotting methods in Bokeh API are able to receive data source parameters through ColumnDatasource object. It makes sharing data between plots and 'DataTables'. A ColumnDatasource can be considered as a mapping between column name and list of data.
Thanks Adian! That was a good direction. Here is a minimal example.
import numpy as np
from bokeh.plotting import figure, show
a = np.array([[1,2], [3, 4]])
p = figure(x_range=(0, 2), y_range=(0, 2))
# must give a vector of image data for image parameter
p.image(image=[a], x=0, y=0, dw=2, dh=2, palette="Spectral11")
show(p)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With