#Lineplot from a wide-form dataset using seaborn library
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#conda install -c anaconda seaborn
import seaborn as sns
sns.set_theme(style="whitegrid")
def main():
rs = np.random.RandomState(365)
values = rs.randn(365, 4).cumsum(axis=0)
dates = pd.date_range("1 1 2016", periods=365, freq="D")
data = pd.DataFrame(values, dates, columns=["A", "B", "C", "D"])
data = data.rolling(7).mean()
sns.lineplot(data=data, palette="tab10", linewidth=2.5)
plt.savefig("ex386.png", dpi=100)
plt.show()
if __name__ == '__main__':
main()
Like this:
Like Loading...
Related
Recent Comments