Posts

Showing posts with the label Matplotlib Library

Plotting Graphs in Python with Matplotlib Library

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 player