Here is what my csv file looks like:
I skipped the first 4 rows because they contained no data. Once at row 5 I used pandas to get the data line by line. This part I think I got but I want to be able to organize the data for column 'Date' so that on the x-axis they appear as Jan, Feb, March... but not sure how this is done with Pandas as pd.
I also want to be able to label the y-axis with 'Evapotranspiration (inches)' and have a title at the top that reads 'Eden_7'. So far there is a ledgend in the top right corner that I don't want there. Not sure how to remove. Lastly I want the threshold for the y-axis range to be from 1 to 7 not 1 to 8.
Here is the code I have working so far:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
dataset = pd.read_csv('1541544819_et.csv', skiprows=4)
dataset[['Date', '2A300 Potential evapotranspiration (millimeters)']].set_index('Date').plot(figsize=(15, 8))
And so far this works almost perfect except for the details mentioned above.
Here is what the graph looks like:
This is what I am trying to have my final graph look like. Just the bottom one:
Updated code:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
df = pd.read_csv('1541544819_et.csv', skiprows=4)
plt.xticks(range(11), ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Nov','Dec'], rotation=45)
ax = df.plot()
ax.set_ylabel("Evapotranspiration (inches)")
Thank you
You're going to want to play with the format of the dates - you can look at strptime and strftime or look into MatPlotLib formatting for axis stuff . You can also plot the dataframe directly in MatPlotLib and have additional options to fix the legend labeling and control more parameters. Here's a starting guide .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.