[Matplotlib-users] scatter c=colors seems confusing and inconsistent
Neal Becker
ndbecker2 at gmail.com
Fri Apr 3 16:11:29 EDT 2020
For 2d scatter, I can pass 2d arrays as X and Y. But it seems not c=.
Here is a demonstration:
------------
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())
--------------
Without colors.flatten(), mpl will give an error. It seems to be OK with X
and Y being 2D, but not c.
In this example I have given c as a 2d array of objects, each object being
an RGBA tuple.
Is there an easier way? Preferably one that doesn't require me to
specifically allocate an empty array of objects
and then populate it with an explicit loop?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200403/64ab7993/attachment.html>
More information about the Matplotlib-users
mailing list