gradio2 / app.py
maty0505's picture
modified 2
81bf60b verified
raw
history blame contribute delete
734 Bytes
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
# Gradioインターフェースの定義
iface = gr.Interface(
fn=plot_passenger_trends,
inputs=[],
outputs=gr.components.Plot(label="JRの乗客数の推移")
)
if __name__ == "__main__":
iface.launch()