The documentation for set_array
is very skimpy. What does it do? What range of values can it take? How does it work in conjunction with other color-related routines and data structures?
On the collections docpage it is said to "Set the image array from numpy array A." It is described in the same way in the colormap API. That's all.
I find no mention of set_array()
(much less examples) in any of several popular books on matplotlib programming, such as Devert (2014), McGreggor (2015), Root (2015) and Tossi (2009).
Yet, if set_array()
is some arcane function that is only needed in rare cases, why does it show up so often both in matplotlib examples and in examples posted on the SciKit Learn website? Seems like a pretty mainstream function, and so it ought to have more mainstream documentation.
For example:
- Matplotlib docs: Use of
set_array()
in creation of a multi-colored line - Matplotlib docs: Line collection with masked arrays
- Scikit Learn docs: Visualization of stockmarket structure
Sifting through Stack Overflow posts that mention set_array()
I found this one, where a poster states that "set_array()
handles mapping an array of data values to RGB", and this one where posters indicate that set_array()
must be called in some cases when one is setting up a ScalarMappable
object.
I've tried experimenting with the examples I've found on-line, changing the range of values passed in to set_array()
, for example, to try to figure out what it is doing. But, at this point, I'm spending way too much time on this one dumb function. Those deeply into color maps have enough context to guess what it does, but I can't afford to take a detour that big, just to understand this one function.
Could someone please offer a quick description and maybe some links?