Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Earnings Trend Visualizer | Analyzing and Visualizing Freelance Data
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Freelancers

bookChallenge: Earnings Trend Visualizer

In this challenge, you will create a Python script that visualizes your freelance earnings for each month using matplotlib. This exercise will help you gain practical experience in turning raw data into a clear, informative line plot—a valuable skill for freelancers who want to quickly interpret their income trends over time.

Begin by defining your earnings data. Use a Python list to represent the earnings for each month. Assign each month's name to a separate list to use as labels on the x-axis. Next, use matplotlib.pyplot to plot this data as a line graph. You will add markers to each data point for clarity, label both axes, set a descriptive title, and enable gridlines to make the plot easier to read.

123456789101112131415161718
import matplotlib.pyplot as plt # Hardcoded monthly earnings data (in USD) months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] earnings = [1200, 1350, 1600, 1550, 1700, 1800, 1750, 1900, 2100, 2200, 2000, 2300] plt.figure(figsize=(10, 6)) plt.plot(months, earnings, marker="o", color="blue", linestyle="-", linewidth=2, markersize=8) plt.title("Freelance Earnings Trend (2024)") plt.xlabel("Month") plt.ylabel("Earnings (USD)") plt.grid(True, linestyle="--", alpha=0.6) plt.tight_layout() plt.show()
copy

This script will generate a line plot showing how your freelance earnings changed month by month. The markers highlight each month's earning, and the gridlines help you compare values more easily. The labeled axes and title provide clear context, making the plot straightforward to interpret and present to clients or for your own records.

Oppgave

Swipe to start coding

Write a Python script to visualize your monthly freelance earnings as a line plot using matplotlib.

  • Define two lists: one for month names and one for earnings data.
  • Plot the earnings data as a line plot with markers for each point.
  • Add labels for the x-axis (months) and y-axis (earnings).
  • Set a title for the plot.
  • Enable gridlines for clarity.

Your code will be tested for:

  • Correct use of matplotlib to plot the data.
  • Proper labeling of axes and title.
  • Use of markers and gridlines on the plot.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 3

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

Suggested prompts:

Can you explain how to customize the plot colors or styles?

How can I save the generated plot as an image file?

What should I do if my earnings data is in a CSV file instead of a list?

bookChallenge: Earnings Trend Visualizer

Sveip for å vise menyen

In this challenge, you will create a Python script that visualizes your freelance earnings for each month using matplotlib. This exercise will help you gain practical experience in turning raw data into a clear, informative line plot—a valuable skill for freelancers who want to quickly interpret their income trends over time.

Begin by defining your earnings data. Use a Python list to represent the earnings for each month. Assign each month's name to a separate list to use as labels on the x-axis. Next, use matplotlib.pyplot to plot this data as a line graph. You will add markers to each data point for clarity, label both axes, set a descriptive title, and enable gridlines to make the plot easier to read.

123456789101112131415161718
import matplotlib.pyplot as plt # Hardcoded monthly earnings data (in USD) months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] earnings = [1200, 1350, 1600, 1550, 1700, 1800, 1750, 1900, 2100, 2200, 2000, 2300] plt.figure(figsize=(10, 6)) plt.plot(months, earnings, marker="o", color="blue", linestyle="-", linewidth=2, markersize=8) plt.title("Freelance Earnings Trend (2024)") plt.xlabel("Month") plt.ylabel("Earnings (USD)") plt.grid(True, linestyle="--", alpha=0.6) plt.tight_layout() plt.show()
copy

This script will generate a line plot showing how your freelance earnings changed month by month. The markers highlight each month's earning, and the gridlines help you compare values more easily. The labeled axes and title provide clear context, making the plot straightforward to interpret and present to clients or for your own records.

Oppgave

Swipe to start coding

Write a Python script to visualize your monthly freelance earnings as a line plot using matplotlib.

  • Define two lists: one for month names and one for earnings data.
  • Plot the earnings data as a line plot with markers for each point.
  • Add labels for the x-axis (months) and y-axis (earnings).
  • Set a title for the plot.
  • Enable gridlines for clarity.

Your code will be tested for:

  • Correct use of matplotlib to plot the data.
  • Proper labeling of axes and title.
  • Use of markers and gridlines on the plot.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 3
some-alt