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
Seksjon 1. Kapittel 20
single

single

bookChallenge: Visualize Product vs Region Sales

Sveip for å vise menyen

Oppgave

Sveip for å begynne å kode

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 20
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt