Basic Matplotlib Scatter Plot From Pandas DataFrame

Viewed 19085

How to make a basic scatter plot of column in a DataFrame vs the index of that DataFrame? Im using python 2.7.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

dataframe['Col'].plot()
plt.show()

This shows a line chart of 'Col' plotted against the values in my DataFrame index (dates in this case).

But how do I plot a scatterplot rather than a line chart?

I tried

plt.scatter(dataframe['Col'])
plt.show()

But scatter() requires 2 arguments. So how do I pass the series dataframe['Col'] and my dataframe index into scatter() ?

I for this I tried

plt.scatter(dataframe.index.values, dataframe['Col'])
plt.show()

But chart is blank.

2 Answers
Related