How to add a legend in a Matplotlib chart?

In today’s hands on data visualization tutorial we’ll learn how to insert a legend into an existing chart. Rendering a Matplotlib chart We’ll use Python and the Matplotlib library to draw a simple line chart. In our example we would like to show the revenue from B2B vs B2C sales of an imaginary company during … Read more

How to save a chart figure in Matplotlib and Seaborn?

In today’s data visualization tutorial we’ll learn how to save a Matplotlib plot as a graphic file so you can later on embed into a website, presentation, Excel spreadsheet or documents. Creating our Matplotlib chart We’ll first go ahead and create our plot using Python and Matplotlib. Note that we’ll also use Numpy to generate … Read more

How to plot multiple lines with Python, Seaborn and Matplotlib?

Today we’ll learn to draw a bit more sophisticated lineplots that display multiple lines. We’ll provide examples leveraging the two popular Python Data Visualization libraries: Matplotlib and Seaborn. Importing libraries Create dummy data We’ll use numpy to quickly generate simple x,y coordinate data. Matplotlib multiple line graph We’ll use the Matplotlib to generate a simple … Read more

How to create a Scatter plot in Pandas with Python?

In this Data Visualization tutorial we’ll learn how to quickly render and customize custom charts using Python and the Pandas library. It’s important to note that the Pandas plotting capabilities are a subset from those available in Matplotlib, a powerful Data Visualization library, which we have covered in other tutorials. Python scatter plots example – … Read more

How to plot DataFrame groupby values?

Today we’ll learn how to quickly plot a chart to easily visualize aggregated data. We’ll first go ahead and create a DataFrame from data that we have aggregated. If you want to follow along this example, you can download the source csv file from this location. The tutorial assumes that you have placed the hr_data.csv … Read more