From c3464d3556f8a2ca2499f22fd5ec23632df1457c Mon Sep 17 00:00:00 2001 From: SaaiVenkat Date: Mon, 19 Feb 2024 08:47:05 -0600 Subject: [PATCH] docs(countplot): add example using seaborn --- .../count/seaborn/example_sns_count_plot.html | 364 ++++++++++++++++++ .../count/seaborn/example_sns_count_plot.py | 34 ++ maidr/maidr.py | 4 + 3 files changed, 402 insertions(+) create mode 100644 example/count/seaborn/example_sns_count_plot.html create mode 100644 example/count/seaborn/example_sns_count_plot.py diff --git a/example/count/seaborn/example_sns_count_plot.html b/example/count/seaborn/example_sns_count_plot.html new file mode 100644 index 0000000..92bb3b2 --- /dev/null +++ b/example/count/seaborn/example_sns_count_plot.html @@ -0,0 +1,364 @@ + + + + MAIDR + + + + +
+ + + + + + 2024-02-19T08:42:09.381744 + image/svg+xml + + + Matplotlib v3.8.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/example/count/seaborn/example_sns_count_plot.py b/example/count/seaborn/example_sns_count_plot.py new file mode 100644 index 0000000..56d815f --- /dev/null +++ b/example/count/seaborn/example_sns_count_plot.py @@ -0,0 +1,34 @@ +import os + +import matplotlib.pyplot as plt +import maidr +import seaborn as sns + + +def get_filepath(filename: str) -> str: + current_file_path = os.path.abspath(__file__) + directory = os.path.dirname(current_file_path) + return os.path.join(directory, filename) + + +def plot(): + # Load the Titanic dataset + titanic = sns.load_dataset("titanic") + + # Create a countplot + count_plot = sns.countplot(x="class", data=titanic) + + # Set the title and show the plot + plt.title("Passenger Class Distribution on the Titanic") + + return count_plot + + +def main(): + count_plot = plot() + count_maidr = maidr.bar(count_plot) + count_maidr.save(get_filepath("example_sns_count_plot.html")) + + +if __name__ == "__main__": + main() diff --git a/maidr/maidr.py b/maidr/maidr.py index 9c949b8..c4cc0c0 100644 --- a/maidr/maidr.py +++ b/maidr/maidr.py @@ -14,5 +14,9 @@ def bar(plot: Axes | BarContainer) -> Maidr: return FigureManager.create_maidr(fig, plot, plot_type) +def count(plot: Axes | BarContainer) -> Maidr: + return bar(plot) + + def close() -> None: pass