import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

# if using an jupyter notebook
# %matplotlib inline

palette = ["#f9bad5", "#bbbbbb", "#cceef7", "#eb1c74", "#aebf35", "#70d4b5", "#ba7a42"]
plt.rcParams['axes.color_cycle'] = palette

plt.rcParams['axes.facecolor'] = '#ffffff'

plt.rcParams.update({'font.size': 18})


# load data


# create plots
fig = plt.figure()
ax1 = fig.add_subplot(3,1,1)


g = data.groupby(["datetime"])["videostart", "visits"].sum()
g["VideosPerVisit"] = g["videostart"] / g["visits"]
ax1 = g["videostart"].plot( kind = "line", figsize = (12, 15), linewidth = 2)
ax1 = pd.rolling_mean(g, window = 7)["videostart"].plot(kind = "line", linestyle = "--", color = "#1e1e1e")
plt.ylabel("Video Initiates", color = "#eb1c74")

ax2 = fig.add_subplot(3,1,2)
ax2 = g["visits"].plot( kind = "line", figsize = (12, 15), linewidth = 2, color = palette[1])
ax2 = pd.rolling_mean(g, window = 7)["visits"].plot(kind = "line", linestyle = "--", color = "#1e1e1e")
plt.ylabel("Visits", color = palette[1])

ax3 = fig.add_subplot(3,1,3)
ax3 = g["VideosPerVisit"].plot( kind = "line", figsize = (12, 15), linewidth = 2, color = palette[2])
ax3 = pd.rolling_mean(g, window = 7)["VideosPerVisit"].plot(kind = "line", linestyle = "--", color = "#1e1e1e")
plt.ylabel("Videos Per Visit", color = palette[2])

Send a Comment

Your email address will not be published.