import plotly.express as px import pandas as pd import numpy as np # Generate random data np.random.seed(42) n = 50 x = np.random.rand(n) y = np.random.rand(n) z = np.random.rand(n) * 100 # Third variable for bubble size # Create a DataFrame data = pd.DataFrame({'X': x, 'Y': y, 'Z': z}) # Create the scatter plot with bubble size with Plotly fig = px.scatter(data, x='X', y='Y', size='Z', title='Interactive Scatter Plot with Bubble Plot') # Add labels to the bubbles fig.update_traces(textposition='top center', textfont=dict(size=11)) # Update layout properties fig.update_layout( xaxis_title='X-axis', yaxis_title='Y-axis', showlegend=False ) # Display the interactive plot fig.show()