|
import gradio as gr |
|
import matplotlib.pyplot as plt |
|
import pandas as pd |
|
|
|
|
|
data = { |
|
'年月': ['2023-01', '2023-02', '2023-03', '2023-04', '2023-05', '2023-06'], |
|
'乗客数': [1200, 1500, 1700, 1600, 1800, 2000] |
|
} |
|
|
|
df = pd.DataFrame(data) |
|
|
|
def plot_passenger_trends(): |
|
fig, ax = plt.subplots() |
|
ax.plot(df['年月'], df['乗客数'], marker='o') |
|
ax.set_title('JRの乗客数の推移') |
|
ax.set_xlabel('年月') |
|
ax.set_ylabel('乗客数 (千人)') |
|
return fig |
|
|
|
|
|
iface = gr.Interface( |
|
fn=plot_passenger_trends, |
|
inputs=[], |
|
outputs=gr.components.Plot(label="JRの乗客数の推移") |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|
|
|