Press "Enter" to skip to content

Tag: dataviz

How to Plot a Histogram with Pandas in 3 Simple Steps

In this post, we are going to learn how to plot histograms with Pandas in Python. Specifically, we are going to learn 3 simple steps to make a histogram with Pandas. Now, plotting a histogram is a good way to explore the distribution of our data.

Note, in the end of this post there’s a YouTube tutorial explaining the simple steps to plot a Histogram with Pandas.

Prerequisites

First of all, and quite obvious, we need to have Python 3.x and Pandas installed to be able to create a histogram with Pandas. Now, Python and Pandas will be installed if we have a scientific Python distribution, such as Anaconda or ActivePython, installed. On the other hand, Pandas can be installed, as many Python packages, using Pip: pip install pandas.

How to Save a Seaborn Plot as a File (e.g., PNG, PDF, EPS, TIFF)

In this short post, we will learn how to save Seaborn plots to a range of different file formats. More specifically, we will learn how to use the plt.savefig method save plots made with Seaborn to:

  1. Portable Network Graphics (PNG)
  2. Portable Document Format (PDF)
  3. Encapsulated Postscript (EPS)
  4. Tagged Image File Format (TIFF)
  5. Scalable Vector Graphics (SVG)

How to Change the Size of Seaborn Plots

In this short tutorial, we will learn how to change the figure size of Seaborn plots. For many reasons, we may need to either increase the size or decrease the size, of our plots created with Seaborn.

How to Make Seaborn Plot Bigger

Now, if we only want to know how to increase the sie of a Seaborn plot we can use matplotlib and pyplot: e.g.;

import matplotlib.pyplot as plt fig = plt.gcf() fig.set_size_inches(12, 8)

Note, that we use the set_size_inches() method to make the Seaborn plot bigger.

When do We Need to Change the Size of a Plot?

One example, for instance, when we might want to change the size of a plot could be when we are going to communicate the results from our data analysis. In this case, we may compile the descriptive statistics, data visualization, and results from data analysis into a report, or manuscript for scientific publication.

FacetGrid Plot

Here, we may need to change the size so it fits the way we want to communicate our results. Note, for scientific publication (or printing, in general) we may want to also save the figures as high-resolution images.