2

I plotted a graph (attached) using the python code below. The problem is that the color assigned is very hard for people to tell the difference between each data point. I would like to customize the color scale. Can anyone help with this? Thanks a lot!

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
x=[1,2,3,4,5,1,2,3,4,5]
y=[5,4,3,2,1,1,2,3,4,5]
z=[0.1,0.2,-0.1,0.3,0.05,0.1,-0.1,-0.5,0.25,-0.05]
df=pd.DataFrame({'x':x,'y':y,'z':z})
df.plot.scatter(x='x',y='y',c='z')

enter image description here

1 Answer 1

3

Pass a colormap argument to df.plot(), e.g.

df.plot.scatter(x='x',y='y',c='z', colormap='plasma')

enter image description here

From the docs for pandas.DataFrame.plot:

colormap : str or matplotlib colormap object, default None

Colormap to select colors from. If string, load colormap with that name from matplotlib.

You can check out the matplotlib colormaps (as I used above) in the colormaps_reference.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.