Contributors:
Agenda:
License: Creative Commons Attribution-ShareAlike 4.0 International
Q&A - OTR Discord #Jupyterthon #WORKSHOP DAY 2 - VISUALIZING DATA
This is not intended to be a comprehensive overview of Visualization in Python/Jupyter. There are many libraries and techniques not covered here. These are just a few options that we've used and liked and give you a lot of scope.
Resources:
Cheatsheets :
Refer Bar Plots section for more examples and options to customize
import matplotlib.pyplot as plt
plt.style.use("fivethirtyeight")
import pandas as pd
logons_full_df = pd.read_pickle("../data/host_logons.pkl")
net_full_df = pd.read_pickle("../data/az_net_comms_df.pkl")
logons_full_df.head()
# Preprocess the data- Group by LogonType and count the no of accounts
logontypebyacc = logons_full_df.groupby(['LogonType'])['Account'].count()
logontypebyacc.head()
logontypebyacc.plot(kind='bar')
#Preprocess dataframe by
logonaccountbyday = logons_full_df.set_index('TimeGenerated').resample('D')['Account'].count()
logonaccountbyday.head()
logonaccountbyday.plot(figsize = (20,8))
import matplotlib.pyplot as plt
plt.style.use("seaborn-whitegrid")
plt.figure(figsize = (20,8))
plt.plot(logonaccountbyday, marker='o')
plt.title("Daily trend of account logons")
plt.xlabel("Date")
plt.ylabel("Logon Count")
# another example of customization with plot
# plt.plot(logonaccountbyday, color='green', marker='o', linestyle='dashed',linewidth=2)
plt.show()
is a very flexible JS visualization framework. Beautiful interactive charts but somewhat complex.
Example Bokeh Ridge plot
is a higherlevel, declarative layer built on top of Bokeh (or MatplotLib)
Example Holoviews Violin plot
is some of Holoviews functionality implemented as a pandas extension.
conda install -c pyviz hvplot
pip install hvplot
import hvplot.pandas
count_of_logons = logons_full_df[["TimeGenerated", "Account"]].groupby("Account").count()
count_of_logons.hvplot.barh(height=300)