Python) How can I make this into a dynamic graph that continues at one interval at a time by year? Here is what I have for a static graph: import pandas as pd import numpy as np df = pd.DataFrame([[1901,311.71 ,300.39], [1902 ,305.73, 295.99], [1903 ,252.25, 291.93], [1904 ,261.43, 288.55], [1905 ,321.01, 286.21], [1906 ,320.3, 285.23], [1907 ,310.64, 285.81], [1908 ,263.26, 286.99], [1909 ,252.38, 287.37], [1910 ,264.94, 285.55]]) df.rename(columns={0: 'x', 1: 'y', 2: 'z'}, inplace=True) print(np.shape(df), type(df), df, sep='\n') #This will help to draw the graph. import matplotlib.pyplot as plt plt.plot(df['x'], df['y'], color='blue', label='Annual Mean') plt.plot(df['x'], df['z'], color='black', label='5-yr smooth') plt.legend() plt.show(
Python)
How can I make this into a dynamic graph that continues at one interval at a time by year?
Here is what I have for a static graph:
import pandas as pd
import numpy as np
df = pd.DataFrame([[1901,311.71 ,300.39],
[1902 ,305.73, 295.99],
[1903 ,252.25, 291.93],
[1904 ,261.43, 288.55],
[1905 ,321.01, 286.21],
[1906 ,320.3, 285.23],
[1907 ,310.64, 285.81],
[1908 ,263.26, 286.99],
[1909 ,252.38, 287.37],
[1910 ,264.94, 285.55]])
df.rename(columns={0: 'x', 1: 'y', 2: 'z'}, inplace=True)
print(np.shape(df), type(df), df, sep='\n')
#This will help to draw the graph.
import matplotlib.pyplot as plt
plt.plot(df['x'], df['y'], color='blue', label='Annual Mean')
plt.plot(df['x'], df['z'], color='black', label='5-yr smooth')
plt.legend()
plt.show()
Step by step
Solved in 4 steps with 2 images