1

I want to draw a scatterplot with the colormap of my choice.

My code:

# Create a scatter plot.
scatter = axes[1][1].scatter(
fourth.VALP, # First value to use.
fourth['TAXP'].map(taxp_convert), # Second value.
s = fourth['WGTP'].map(MinimizeSize), # Size of each point is its WGTP value 
and minimizing the size
c = fourth.MRGP, # Color of each point is its MRGP value.
marker ='o')

Result: Scatter Plot with color bar

However, I want the color to be like this:

Desired color scheme

I only know that the c parameter in axes.scatter is responsible for color, but I don't know how to change it to the desired color.

LondonRob
  • 73,083
  • 37
  • 144
  • 201

1 Answers1

3

You're doing everything correctly. The c parameter is the quantity by which the scatter points are colorized according to a colormap. It may also be used to specify the colors directly (one color per point).

If you want to change the default colormap, you may use the cmap argument. E.g.

plt.scatter(...., cmap="coolwarm")

would give you a plot like the desired one. For a complete overview check the colormaps_reference

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712