Moving a Seaborn scatter plot to Plotly Express

Fill in the blanks · Basic · §9.1 From static figures to exploration

The table beaches holds the daytime temperature (°C) and the number of visitors (thousands) at two beaches, Gyeongpo and Haeundae. Draw the scatter plot that the Seaborn code in the comment drew, with a single px function.

Split the point colors by beach, and color them as the dictionary beach_colors says. Fill in the three blanks with a function name and two arguments. Grading changes the visitor counts and the order of the beaches and draws the chart again.

Target figure for Moving a Seaborn scatter plot to Plotly Express
Target figure

Code with blanks

import pandas as pd
import plotly.express as px

beaches = pd.DataFrame({
    "temp": [24, 26, 28, 30, 32, 24, 26, 28, 30, 32],
    "beach": ["Gyeongpo"] * 5 + ["Haeundae"] * 5,
    "visitors": [12, 18, 25, 31, 34, 20, 27, 33, 41, 45],
})
beach_colors = {"Gyeongpo": "#009E73", "Haeundae": "#CC79A7"}

# The Seaborn line it replaces: sns.scatterplot(data=beaches, x="temp", y="visitors", hue="beach", palette=beach_colors, ax=ax)
fig = ____(beaches, x="temp", y="visitors", ____, ____,
                 title="Temperature and beach visitors")
fig.show()

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.