Programming Language: Python. Help create line plot, line plotwith two lines, 4 subplots, y-y plot, histogram in my JupyterNotebook. My code so far is below. Please show source code andscreenshots. Please use Jupyter Notebook on Anaconda. Please useNumPy arrays and linear equations using matrices. Thank you.
Download the Excel spreadsheet file titledgovt_camp_2013_01_to_2016_03.xlsx and save it to your preferredworking directory. The directory where the Excel .xlsx file isplaced needs to be the same directory you build your Jupyternotebook in. The Excel file contains daily weather data pointsgathered from the USGS weather station in Government Camp, OR fromJan 1, 2009 to Mar 31, 2016. The weather measurements and theirunits are given in the column headers (first row) of the Excelspreadsheet.
Excel sheet:
Code so far:
Create a line plot
Once the data is cleaned up, create a line plot with Matplotlibof precipitation in inches vs. time (in days since Jan 01, 2013).Include an x-axis label, a y-axis label, and a title on your plot.Look back at the column headers in the dataframe df to determinewhich column corresponds to Precipitation (inches). Use indexing topull out all of the values from the precipitation column to buildyour plot.
The resulting plot should look something like the plotbelow:
Create a line plot with two lines
Next, create a Matplotlib line plot that shows the maximum andminimum temperatures in 2013 on two lines. Look back at thedatafrome df to determine which columns correspond to the maximumand minimum temperatures recorded each day. The maximum temp shouldbe a red line and the minimum temp should be a blue line. Include alegend that shows Max Temp and Min Temp. Include axis labels and atitle on the plot.
The resulting plot should look something like the plotbelow:
Create 4 subplots
The next task is to create a Matplotlib figure containing foursubplots that looks like the figure with four plots shown below.The four subplots should be stacked on top of each other. Eachsubplot should contain the precipitation data vs. time (day of theyear) in one year. The first subplot shows precipitation in 2013,the second subplot shows precipitation in 2014, etc. Include atitle on each subplot and a y-axis label on each subplot. On thebottom subplot (Precipitation in 2016), include an x-axislabel.
Use NumPy’s np.where() function or boolean masks to save theprecipitation data (number of inches only) exclusively for days inthe year 2013 to a NumPy array called precip_2013. Use theplt.subplots() method to plot the precip_2013 data in the firstsubplot.
Complete the same type of indexing operation on theprecipitation data for 2014, then 2015, then 2016. Create a subplotfor each year. The plot for 2016 should include an x-axis label andhave the same axis limits as the x-axis limits in the othersubplots.
Hint: When plt.subplots() is called, include the keywordargument figsize=(9,9). This keyword argument makes the figurelarger and leaves more space for the axis labels and titles of eachsubplot. Modify the numbers (9,9) to change the figure width andheight.
The resulting figure which contains four subplots, one subplotfor each year, should look something like below. The commandplt.tight_layout() can also help with subplot spacing.
y-y plot
The next plot you will build is a y-y plot. A y-y plot has twodifferent y-axes. Each set or sets of data corresponds to one ofthe separate y-axes. Y-y plots are useful when two types of datacontain the same x-values (like time) but very different scales ofy-values (like snow fall and snow depth).
Use boolean masking to save some of the snow depth data into aNumPy array called winter13_14_sd. Remember which column headerscorrespond to which measurement in the dataframe df. Refer to thedataframe or Excel file, if need be, to see which columncorresponds snow depth. Your snow depth data set should onlyinclude measurements from the first day of November 2013 to thelast day of February 2014. Slicing or indexing out snow depth datain this date range is probably be the most difficult part of thelab.
Hint: Create multiple boolean masks and then combine the booleanmasks with NumPy’s np.logical_and() and np.logical_or() functions.These two NumPy functions operate like Python’s and, or keywords,but can be applied to arrays of boolean values.
Index out the same days’ (Nov 1, 2013 to Feb 27, 2014) snow falldata and save the snow fall data in this date range to a NumPyarray called winter13_14_sf.
Use Matplotlib’s ax2 = ax1.twinx() method to plot both sets ofdata on the same plot (same x-axis), but with different y-axes.
Notice the figure has a different vertical axis on the leftcompared to the vertical axis on the right. Let Matplotlib chooseyour axis limits and line colors. Be sure to include the gridlines, x-axis label, y-axis labels, title, and legend as seen inthe figure below. It is tricky to include both entries in thelegend. Do your best, but don’t waste too much time configuring thelegend.
Histogram
The final plot to create in this lab is a histogram. A histogramis a statistical plot that shows the number of values that fallinto different value ranges, called bins. Use your winter13_14_sfNumPy array to build the histogram. Include 10 bins in thehistogram. Make sure to match all of the labels and title from theexample histogram below.
fjdsaklf;ds