Challenge: 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.
123456789101112131415161718import 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()
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.
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
matplotlibto plot the data. - Proper labeling of axes and title.
- Use of markers and gridlines on the plot.
Løsning
Tak for dine kommentarer!
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Fantastisk!
Completion rate forbedret til 5
Challenge: Earnings Trend Visualizer
Stryg for at vise menuen
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.
123456789101112131415161718import 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()
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.
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
matplotlibto plot the data. - Proper labeling of axes and title.
- Use of markers and gridlines on the plot.
Løsning
Tak for dine kommentarer!