How to plot two DataFrame columns in pandas?

Today we will learn how to plot multiple specific columns of a pandas DataFrame against each other in pandas bar, scatter, line and histogram charts. We will start by importing the pandas library and then create an example DataFrame. Plot two columns in the same scatter chart Creating a scatter with pandas is relatively simple. … Read more

How to plot multiple pandas time series in a chart?

In today’s data visualization we will learn how to plot multiple time series on the same chart with pandas. Time series is basically information that is time dependent such as prices, inventory, sales etc’. In our example, we would like to plot revenue, expenses and ultimately profit for a fictitious business. We’ll use a line … Read more

How to plot vertical lines in Pandas and matplotlib?

In this Data Visualization tutorial, we will learn how to draw one or multiple vertical lines using matplotlib and Pandas. Drawing vertical lines in Pandas and Matplotlib The plt.axvline() method allows to easily add vertical lines to plots we rended using matplotlib, pandas and Seaborn. Here’s a simple example: Step #1: Import Data Analysis libraries … Read more

How to draw a scatter plot for multiple DataFrame columns?

In today’s data visualization tutorial we’ll learn how during exploratory data analysis, we can use Python to subset two or columns from a pandas DataFrame and draw a simple scatter chart to detect outlier observations. Create example data We’ll start by importing the pandas data analysis library which we’ll use to render the scatter chart. … Read more

How to plot an horizontal line in Pandas charts?

In this short tutorial we will learn how to use Python and the Pandas library to draw an horizontal line that runs in parallel to the x axes. Create Example Data As we typically do, we will start by importing the necessary Data Analysis libraries and create some example data that we will use. Create … Read more

Solve the TypeError no numeric data to plot in Pandas

In today’s tutorial we’ll learn how to troubleshoot a common plotting error that you might encounter when working in Pandas and trying to plot your data during its pre processing for data analysis. Reproducing the problem In order to reproduce the error, we will first construct a very simple DataFrame. Your Python development environment (Jupyter, … Read more

How to add a legend in a Matplotlib chart?

Use the following code to a graph rendered using the Python Matplotlib visualization library: 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 last year. We’ll use … Read more