Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas scatter plot with different colors

rng = np.random.RandomState(0)
x = df['population']
y = df['Area']
colors = {'North America':'red', 'Europe':'green', 'Asia':'blue', 'Australia':'yellow'}

plt.scatter(x, y, s=100*df['population'], alpha=0.3,
            c= df['continent'].map(colors),
            cmap='viridis')
plt.colorbar();
Source by kanoki.org #
 
PREVIOUS NEXT
Tagged: #pandas #scatter #plot #colors
ADD COMMENT
Topic
Name
5+8 =