diff --git a/contrib/plotting-visualization/images/seaborn-basics1.png b/contrib/plotting-visualization/images/seaborn-basics1.png new file mode 100644 index 0000000..bedcee9 Binary files /dev/null and b/contrib/plotting-visualization/images/seaborn-basics1.png differ diff --git a/contrib/plotting-visualization/index.md b/contrib/plotting-visualization/index.md index f4e7e2a..3192f03 100644 --- a/contrib/plotting-visualization/index.md +++ b/contrib/plotting-visualization/index.md @@ -4,4 +4,6 @@ - [Introducing Matplotlib](matplotlib-introduction.md) - [Bar Plots in Matplotlib](matplotlib-bar-plots.md) - [Pie Charts in Matplotlib](matplotlib-pie-charts.md) -- [Line Charts in Matplotlib](matplotlib-line-plot.md) +- [Line Charts in Matplotlib](matplotlib-line-plots.md) +- [Introduction to Seaborn and Installation](seaborn-intro.md) +- [Getting started with Seaborn](seaborn-basics.md) diff --git a/contrib/plotting-visualization/seaborn-basics.md b/contrib/plotting-visualization/seaborn-basics.md new file mode 100644 index 0000000..42df552 --- /dev/null +++ b/contrib/plotting-visualization/seaborn-basics.md @@ -0,0 +1,39 @@ +Seaborn helps you explore and understand your data. Its plotting functions operate on dataframes and arrays containing whole datasets and internally perform the necessary semantic mapping and statistical aggregation to produce informative plots. Its dataset-oriented, declarative API lets you focus on what the different elements of your plots mean, rather than on the details of how to draw them. + +Here’s an example of what seaborn can do: +```Python +# Import seaborn +import seaborn as sns + +# Apply the default theme +sns.set_theme() + +# Load an example dataset +tips = sns.load_dataset("tips") + +# Create a visualization +sns.relplot( + data=tips, + x="total_bill", y="tip", col="time", + hue="smoker", style="smoker", size="size", +) +``` +Below is the output for the above code snippet: + +![Seaborn intro image](images/seaborn-basics1.png) + +```Python +# Load an example dataset +tips = sns.load_dataset("tips") +``` +Most code in the docs will use the `load_dataset()` function to get quick access to an example dataset. There’s nothing special about these datasets: they are just pandas data frames, and we could have loaded them with `pandas.read_csv()` or build them by hand. Many users specify data using pandas data frames, but Seaborn is very flexible about the data structures that it accepts. + +```Python +# Create a visualization +sns.relplot( + data=tips, + x="total_bill", y="tip", col="time", + hue="smoker", style="smoker", size="size", +) +``` +This plot shows the relationship between five variables in the tips dataset using a single call to the seaborn function `relplot()`. Notice how only the names of the variables and their roles in the plot are provided. Unlike when using matplotlib directly, it wasn’t necessary to specify attributes of the plot elements in terms of the color values or marker codes. Behind the scenes, seaborn handled the translation from values in the dataframe to arguments that Matplotlib understands. This declarative approach lets you stay focused on the questions that you want to answer, rather than on the details of how to control matplotlib. diff --git a/contrib/plotting-visualization/seaborn-intro.md b/contrib/plotting-visualization/seaborn-intro.md new file mode 100644 index 0000000..6e0a7d8 --- /dev/null +++ b/contrib/plotting-visualization/seaborn-intro.md @@ -0,0 +1,41 @@ +Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. + +## Seaborn Installation +Before installing Matplotlib, ensure you have Python installed on your system. You can download and install Python from the [official Python website](https://www.python.org/). + +Below are the steps to install and setup Seaborn: + +1. Open your terminal or command prompt and run the following command to install Seaborn using `pip`: + +```bash +pip install seaborn +``` + +2. The basic invocation of `pip` will install seaborn and, if necessary, its mandatory dependencies. It is possible to include optional dependencies that give access to a few advanced features: +```bash +pip install seaborn[stats] +``` + +3. The library is also included as part of the Anaconda distribution, and it can be installed with `conda`: +```bash +conda install seaborn +``` + +4. As the main Anaconda repository can be slow to add new releases, you may prefer using the conda-forge channel: +```bash +conda install seaborn -c conda-forge +``` + +## Dependencies +### Supported Python versions +- Python 3.8+ + +### Mandatory Dependencies + - [numpy](https://numpy.org/) + - [pandas](https://pandas.pydata.org/) + - [matplotlib](https://matplotlib.org/) + +### Optional Dependencies + - [statsmodels](https://www.statsmodels.org/stable/index.html) for advanced regression plots + - [scipy](https://scipy.org/) for clustering matrices and some advanced options + - [fastcluster](https://pypi.org/project/fastcluster/) for faster clustering of large matrices