Question: A trend Graph is a graph that is used to show the trends data over a period of time. It describes a functional representation of

A trend Graph is a graph that is used to show the trends data over a period of time.
It describes a functional representation of two variables (x , y).
In which the x is the time-dependent variable whereas y is the collected data.
The graph can be in shown any form that can be via line chart, Histograms, scatter plot, bar chart, and pie-chart.
In python, we can plot these trend graphs by using matplotlib.pyplot library.
It is used for plotting a figure for the given data.
Python Practice 1->
# import all the libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Create a dataframe
data ={
"medals": [100,92,102,56,78,56,78,96],
"Time_Period": [2010,2011,2012,2013,2014,2015,2016,2017]
}
df = pd.DataFrame(data)
print(df)
# to plot the graph
df.plot(x="Time_Period", y="medals", kind="line")
plt.show()
Python Practice 2-> the following is Python code to plot a scatter plot and a bar graph using the provided data:
# Scatter plot
plt.figure(figsize=(8,6))
plt.scatter(df['Time_Period'], df['medals'], color='blue')
plt.title('Scatter Plot of Medals Over Time Period')
plt.xlabel('Time Period')
plt.ylabel('Medals')
plt.grid(True)
plt.show()
# Bar graph
plt.figure(figsize=(8,6))
plt.bar(df['Time_Period'], df['medals'], color='green')
plt.title('Bar Graph of Medals Over Time Period')
plt.xlabel('Time Period')
plt.ylabel('Medals')
plt.grid(True)
plt.show()
************************************************************************
[QUESTION TO ANSWER]-> Practice 3: student getting marks in 2010.
Consider the above Practice 1 and Practice 2 steps, we require a line graph showing 2 trends based on:
*************************************************************************
Marks achieved in 2010 by subject.
Based on 2 groups score: Semester 1 and Semester 2.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!