import matplotlib.pyplot as plt
# one line graph plotting
x = [1,2,3,4,5]
y = [320, 400, 650, 456, 870]
plt.plot(x,y)
# customizing your graph
# plt.plot(
# x, y, color="red", linestyle="dashed",
# linewidth=2, marker="o", markerfacecolor="cyan",
# markersize=14
# )
# plt.xlim(1,10) # x axis limits
# plt.ylim(1,1000) # y axis limits
plt.xlabel("Months")
plt.ylabel("Gas Bills")
plt.title("Gas bills of the months")
plt.show()
############################################
# two-lines graph plotting
x1 = [1,2,3,4,5]
y1 = [320, 400, 650, 456, 870]
plt.plot(x1,y1, label="Gas Bills")
x2 = [1,2,3,4,5]
y2 = [620, 800, 450, 556, 270]
plt.plot(x2,y2, label="Water Bills")
plt.xlabel("Months")
plt.ylabel("Billing Amount")
plt.title("Bills of the months")
plt.legend()
plt.show()
############################################
# creating a bar chart
players = [1,2,3,4,5,6]
runs = [23,120,150,170,93,99]
player_names = ["Shoaib", "Shahid", "Mohsin", "Abdur", "Wahab", "Farhat"]
plt.bar(players, runs, tick_label=player_names, width=0.6, color=["green","blue", "red"] )
plt.xlabel("Players")
plt.ylabel("Runs")
plt.title("Players of the Match")
plt.show()
Comments
Post a Comment
Write something to CodeWithAbdur!