You can download this code by clicking the button below.
This code is now available for download.
This function uses the Plotly's GraphObjects module to create a scatter plot and displays it in the browser.
Technology Stack : Plotly, Python
Code Type : Function
Code Difficulty : Intermediate
import plotly.graph_objects as go
import random
def generate_random_scatter_plot(x, y):
# Create a trace
trace = go.Scatter(x=x, y=y, mode='markers+lines')
# Create data list
data = [trace]
# Create layout
layout = go.Layout(title='Random Scatter Plot',
xaxis=dict(title='X Axis'),
yaxis=dict(title='Y Axis'))
# Plot the figure
fig = go.Figure(data=data, layout=layout)
fig.show()
# Example usage:
# generate_random_scatter_plot([1, 2, 3, 4, 5], [2, 3, 5, 7, 11])