Plt.axhline(25, color = 'red', linewidth = 2, label = 'Median Salary')Īdding horizontal and vertical lines to the plot Subplots: Plt.axvline(2013, color = 'cyan', linewidth = 2, label = 'Median Age') Plt.plot(year, avgTemp, label = 'Average') Plt.plot(year, maxTemp, label = 'Maximum') Plt.plot(year, minTemp, label = 'Minimum') Manually we can add vertical and horizontal lines in the plot using following commands:Īs it is a line, we can tweak its appearance by adjusting appropriate parameters, which are demonstrated in the graph below: year = That will tell use something abour distribution. Sometimes it is good to show median or qurtile range of data on line plot. This code will generate graph as shown here:įormatting line parameters as string Add Horizontal and Vertical Lines: We will pass list of year for x-axis and list of minimum temprature in that year import matplotlib.pyplot as plt Import numpy as np Passing lists as argument to plot: Let us also import the numpy library as np, which is used to create and plot arrays in future. We will be using functions from pyplot package of matplotlib library. In this article, we will see in detail how we can create and customize line chart using matplotlib.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |