-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support seaborn bar and count plot (#12)
- Loading branch information
1 parent
4b5387e
commit fd622bd
Showing
12 changed files
with
957 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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 penguins dataset | ||
penguins = sns.load_dataset("penguins") | ||
|
||
# Create a bar plot showing the average body mass of penguins by species | ||
plt.figure(figsize=(10, 6)) | ||
b_plot = sns.barplot( | ||
x="species", y="body_mass_g", data=penguins, errorbar="sd", palette="Blues_d" | ||
) | ||
b_plot.bar | ||
plt.title("Average Body Mass of Penguins by Species") | ||
plt.xlabel("Species") | ||
plt.ylabel("Body Mass (g)") | ||
|
||
return b_plot | ||
|
||
|
||
def main(): | ||
bar_plot = plot() | ||
bar_maidr = maidr.bar(bar_plot) | ||
bar_maidr.save(get_filepath("example_sns_bar_plot.html")) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.count(count_plot) | ||
count_maidr.save(get_filepath("example_sns_count_plot.html")) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# __version__ will be automatically updated by python-semantic-release | ||
__version__ = "0.0.1" | ||
|
||
from .maidr import bar | ||
from .maidr import bar, count | ||
|
||
__all__ = ["bar"] | ||
__all__ = ["bar", "count"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters