You can download this code by clicking the button below.
This code is now available for download.
This function creates a scatter plot using the Bokeh library. It uses ColumnDataSource to handle the data and draws the scatter plot using the scatter method.
Technology Stack : Bokeh, ColumnDataSource, Scatter plot
Code Type : The type of code
Code Difficulty : Intermediate
import numpy as np
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource
import pandas as pd
def create_scatter_plot(data):
# Create a ColumnDataSource from the DataFrame
source = ColumnDataSource(data)
# Create a new plot with a title and axis labels
p = figure(title="Scatter Plot", x_axis_label='X-axis', y_axis_label='Y-axis')
# Add a scatter renderer to the plot
p.scatter('x', 'y', source=source)
# Display the results
show(p)
# Sample data for demonstration
data = {
'x': [1, 2, 3, 4, 5],
'y': [5, 6, 2, 3, 8]
}