Session-2: Data Science Tools¶
We were indtroduced to open source Data Science tools like Javascript,Rust, Jupyter, Python, Pacakage management, git, NumPy, SciPy, Numba, Jax, PyTorch, Matplotlib, etc.
My Data Visualizations_Matplotlib¶
In [3]:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("datasets/yearly-fire.csv")
years = df["Category"]
fire_counts = df["Fire Counts"]
fig, ax = plt.subplots(figsize=(10,5))
line, = ax.plot(years, fire_counts, marker='o')
annot = ax.annotate("", xy=(0,0), xytext=(20,20),
textcoords="offset points",
bbox=dict(boxstyle="round", fc="w"),
arrowprops=dict(arrowstyle="->"))
annot.set_visible(False)
def update_annot(ind):
x, y = line.get_data()
idx = ind["ind"][0]
annot.xy = (x[idx], y[idx])
text = f"Year: {x[idx]}\nFires: {y[idx]}"
annot.set_text(text)
def hover(event):
vis = annot.get_visible()
if event.inaxes == ax:
cont, ind = line.contains(event)
if cont:
update_annot(ind)
annot.set_visible(True)
fig.canvas.draw_idle()
else:
if vis:
annot.set_visible(False)
fig.canvas.draw_idle()
fig.canvas.mpl_connect("motion_notify_event", hover)
plt.xlabel("Year")
plt.ylabel("Fire Counts")
plt.title("Fire Counts Over the Years")
plt.grid(True)
plt.show()