import plotly.graph_objects as go
import pandas as pd
# Create your DataFrame
data = {
'Catégorie': ['A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C'],
'number episodes': [10, 5, 7, 15, 9, 12, 8, 6, 11],
'Podcasts': [20, 15, 30, 10, 25, 18, 12, 22, 28]
}
df = pd.DataFrame(data)
# Create the scatter plot
scatter = go.Scatter(
x=df['number episodes'],
y=df['Podcasts'],
mode='markers', # 'markers' for scatter plot
marker=dict(size=10, color='blue'), # Customize marker size and color
text=df['Catégorie'], # Show 'Catégorie' on hover
hoverinfo='text', # Show 'Catégorie' on hover
)
# Create the layout
layout = go.Layout(
title='Scatter Plot with Plotly',
xaxis=dict(title='Number of Episodes'),
yaxis=dict(title='Podcasts'),
)
# Create the figure and show the plot
fig = go.Figure(data=[scatter], layout=layout)
fig.show()