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 to visualize the relationship between two sets of data.
Technology Stack : Bokeh, NumPy, Pandas
Code Type : Data visualization
Code Difficulty : Intermediate
import numpy as np
import pandas as pd
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource
from bokeh.layouts import gridplot
def plot_scatter_data(x, y):
# Create a ColumnDataSource for the data
source = ColumnDataSource(data=dict(x=x, y=y))
# Create a figure
p = figure(title="Scatter Plot", tools="pan,wheel_zoom,box_zoom,reset", width=800, height=600)
# Add a scatter plot
p.scatter('x', 'y', source=source, color='blue', alpha=0.6, size=10)
# Display the plot
show(p)
# Example usage
x = np.random.normal(0, 1, 100)
y = np.random.normal(0, 1, 100)
plot_scatter_data(x, y)