Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Earnings Trend Visualizer | Analyzing and Visualizing Freelance Data
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.

Uppgift

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

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 3

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

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

Svep för att visa menyn

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.

Uppgift

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

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 3
some-alt