# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import pandas as pd
from datetime import datetime
import matplotlib.pyplot as plt
from matplotlib.pyplot import cm
import seaborn as sns
from plotnine import *

df = pd.read_csv("../data/Line_Data.csv")
df["date"] = [datetime.strptime(d, "%Y/%m/%d").date() for d in df["date"]]
melt_df = pd.melt(df, id_vars = ["date"], var_name = "variable", value_name = "value")
melt_df

# ## 折线图

base_plot = (
    ggplot(melt_df, aes(x = "date", y = "value")) +
        geom_line(aes(group = "variable", colour = "variable", fill = "variable"), size = 1) +
        scale_x_date(date_labels = "%Y", date_breaks = "1 year") +
        scale_fill_hue(s = 0.90, l = 0.65, h = 0.0417, color_space = "husl") + 
        xlab("Year") +
        ylab("Value")
)
print(base_plot)

# ## 面积图

base_plot = (
    ggplot(melt_df, aes(x = "date", y = "value")) +
        geom_line(aes(group = "variable", colour = "variable"), size = 0.75) +
        geom_area(aes(group = "variable", fill = "variable"), alpha = 0.55, position = "identity") +
        scale_x_date(date_labels = "%Y", date_breaks = "1 year") +
        scale_fill_hue(s = 0.90, l = 0.65, h = 0.0417, color_space = "husl") + 
        xlab("Year") +
        ylab("Value")
)
print(base_plot)



StarcoderdataJupyterScriptsDedupFiltered