

Pandas allows you to customize your scatter plot by changing colors, adding titles, and more. Under the hood, Pandas uses Matplotlib, which can make customizing your plot a familiar experience.
#PANDAS PLOT SCATTER USE INDEX HOW TO#
Python -mtimeit -s 'import pandas as pd import matplotlib.pyplot as plt'ġ00000000 loops, best of 3: 0.0125 usec per loopįinally, the reason the example you linked in comments doesn't need the call to matplotlib is because it is being run interactively in an iPython notebook, not in a script. If you just pass a series from a dataframe as the 'data' parameter, seaborn will automatically use the index as the x values. MaIn this tutorial, you’ll learn how to use Pandas to make a scatter plot. import numpy as npīut all you are doing there is finding somewhere that matplotlib has been imported in pandas, and calling the same show function from there.Īre you trying to avoid calling matplotlib in an effort to speed things up? If so then you are really not speeding anything up, since pandas already imports pyplot: python -mtimeit -s 'import pandas as pd'ġ00000000 loops, best of 3: 0.0122 usec per loop import pandas as pd import matplotlib.pylab as plt. For example: sc2 df.plot.scatter(xdf.delta, ydf. NOTE: This no longer works in modern versions of pandas, and I still recommend importing matplotlib separately, as in the example above. To add on to the discussion, I am going to demonstrate three plotting methods (from most straightforward to least) using the first five points of your data frame. I have a simple Pandas dataframe: delta, starthour, and endhour are all numpy.int64: type(df.delta0) ->numpy.int64 Whenever I try to use the Pandas methods to do a scatter plot, I get 'Inde圎rror: indices are out-of-bounds'.

In older versions of pandas, you were able to find a backdoor to matplotlib, as in the example below. The usual way to do things is to import matplotlib.pyplot and call show from there: import numpy as np I could be wrong but I think labeldf.index will not work when your index is unique text labels you want to plot individually. Once you have made your plot, you need to tell matplotlib to show it.
