Taraf_timeline / app_gradio.py
FDSRashid's picture
Upload app_gradio.py
768a4d5
raw
history blame
1.53 kB
# -*- coding: utf-8 -*-
"""app_gradio.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1hRynOROyrpbf0wKKcizHOXeZhx3Xo51M
"""
import numpy as np
import plotly.express as px
import pandas as pd
import gradio
import plotly.graph_objects as go
taraf_s = pd.read_csv('/content/drive/MyDrive/Hadith Project/taraf_by_year.csv')
taraf_s = taraf_s.sort_values(['City', 'Year'], ascending=True)
cities = taraf_s['City'].unique().tolist()
min_year = int(taraf_s['Year'].min())
max_year = int(taraf_s['Year'].max())
def plot_timeline(citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
filtered = taraf_s[taraf_s['City'].isin(citi) & (taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)]
fig = px.line(data_frame = filtered, x = 'Year', y = 'Taraf', title = "Tarafs per Year", color = 'City' )
fig.update_layout(title_font_color = 'red', title_x = .5)
return fig
app = gradio.Interface(plot_timeline,
[gradio.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
gradio.Slider(min_year, max_year, value = 0, label = 'Begining', info = 'Choose the first year to display Tarafs'),
gradio.Slider(min_year, max_year, value = 400, label = 'End', info = 'Choose the last year to display Tarafs')
],
gradio.Plot()).launch(share = True)