Skip to content
Snippets Groups Projects
Commit c7fbac58 authored by niklasfranz's avatar niklasfranz
Browse files

feat: added Plotter class for plotting

parent 4eb74ea9
No related branches found
No related tags found
No related merge requests found
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from .Dataset import Dataset
class Plotter:
def __init__(self, dataset: Dataset):
self.df = dataset.get_dataframe()
def plotCategoricalBarChart(self, category1, category2, title):
ct = pd.crosstab(self.df[category1], self.df[category2])
ct_percent = ct.apply(lambda r: r/r.sum() * 100, axis=0) # Calculate percentages by row
fig, ax = plt.subplots()
ax.set_title(title)
ct_percent.plot(kind='bar', ax=ax)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment