Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Visualize Product vs Region Sales | Automating Reports and Visual Insights
Python Automation for Reports and Visual Insights
Sektion 1. Kapitel 20
single

single

bookChallenge: Visualize Product vs Region Sales

Stryg for at vise menuen

Opgave

Swipe to start coding

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() with kind="bar" to create the chart, with region on the x-axis, sales on the y-axis, and bars grouped by product using the hue parameter.
  • Set the x-axis label to "Region" and the y-axis label to "Sales Amount" using chart.set_axis_labels().
  • Add a legend with the title "Product" using chart.add_legend(title="Product").
  • Add a chart title that includes both the words "Product" and "Region" using chart.fig.suptitle().
  • Call plt.tight_layout() to adjust the layout.
  • Return the chart object at the end of the function.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 20
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt