plotly.scatter python code example

Example 1: scatter plot plotly

import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
                 size='petal_length', hover_data=['petal_width'])
fig.show()

Example 2: matplotlib scatter

# Import packages
import matplotlib.pyplot as plt
%matplotlib inline

# Create the plot
fig, ax = plt.subplots()

# Plot with scatter()
ax.scatter(x, y)

# Set x and y axes labels, legend, and title
ax.set_title("Title")
ax.set_xlabel("X_Label")
ax.set_ylabel("Y_Label")

Tags: