[Matplotlib-users] scatter c=colors seems confusing and inconsistent
Eric Firing
efiring at hawaii.edu
Fri Apr 3 16:39:56 EDT 2020
Neal,
You can use the built-in color-mapping, like this:
import matplotlib.pyplot as plt
import numpy as np
A = np.array
import colorcet as cc
cmap = cc.m_rainbow
x = A([[0,.25], [0.5, 0.75]])
y = x**2
plt.scatter (x, y, c=x, cmap=cmap)
-------
Eric
On 2020/04/03 10:11 AM, Neal Becker wrote:
> import matplotlib.pyplot as plt
> import numpy as np
> A = np.array
>
> import colorcet as cc
> cmap = cc.m_rainbow
>
> x = A([[0,.25], [0.5, 0.75]])
> y = x**2
> colors = np.empty (x.shape, dtype=object)
> for i in range(2):
> for j in range(2):
> colors[i,j] = cmap(x[i,j])
>
> plt.scatter (x, y, c=colors.flatten())
More information about the Matplotlib-users
mailing list