Osio 1. Luku 20
single
Challenge: Visualize Product vs Region Sales
Pyyhkäise näyttääksesi valikon
Tehtävä
Pyyhkäise aloittaaksesi koodauksen
Create a function plot_product_region_sales(data) that accepts a DataFrame with product, region, and sales columns and returns a seaborn grouped bar chart comparing sales across regions.
- Use
sns.catplot()withkind="bar"to create the chart, withregionon the x-axis,saleson the y-axis, and bars grouped byproductusing thehueparameter. - Set the x-axis label to
"Region"and the y-axis label to"Sales Amount"usingchart.set_axis_labels(). - Add a legend with the title
"Product"usingchart.add_legend(title="Product"). - Add a chart title that includes both the words
"Product"and"Region"usingchart.fig.suptitle(). - Call
plt.tight_layout()to adjust the layout. - Return the
chartobject at the end of the function.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 20
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme