{"id":246,"date":"2024-08-20T15:40:08","date_gmt":"2024-08-20T15:40:08","guid":{"rendered":"http:\/\/bentus\/?p=246"},"modified":"2024-08-21T12:01:40","modified_gmt":"2024-08-21T12:01:40","slug":"gsoc-2024-bivariate-colormaps-summary","status":"publish","type":"post","link":"http:\/\/bentus\/gsoc-2024-bivariate-colormaps-summary\/","title":{"rendered":"GSOC 2024 – Bivariate Colormaps – Summary"},"content":{"rendered":"\n
Color mapping with multiple channels has long been a requested feature<\/a> in Matplotlib, one this Google Summer of Code project (GSOC) has attempted to address, the figures below shows the desired functionality:<\/p>\n\n\n While a complete solution for bivariate color mapping has not been merged to main at the time of writing, the intention is to have it in place for the 3.10 release of Matplotlib (~October 2024). This represents a delay of the project as compared to the original timeline, caused by a change in the scope of the project. <\/p>\n\n\n\n Originally, this GSOC project was based on replacing Representing data with color lies at the root of many of the plotting methods in Matplotlib. In practice, this is handled by the class What @timhoffm<\/a> argued<\/a> was that the Changing the class hierarchy would have major positive implications:<\/p>\n\n\n\n The proposed architecture change is as follows:<\/p>\n\n\n Where the These changes are implemented in the New data \u2192 color pipeline<\/a> PR, and the (slightly outdated) video shows how multiple images that share a colorizer behave.<\/p>\n\n\n\n<\/figure><\/div>\n\n\n
<\/figure>\n\n\n\n\n\n\n\n
cm.ScalarMappable<\/code> with a vector version
,cm.VectorMappable<\/code>, (relevant PR<\/a>). However, with the involvement of the API lead @timhoffm<\/a> and project lead @tacasawell<\/a> it was decided to rework the
data\u2192color<\/code> pipeline before implementing bivariate color mapping.<\/p>\n\n\n\n
Color by numbers (advanced version)<\/h2>\n\n\n\n
cm.ScalarMappable<\/code> which handles normalization (converting data to a 0-1 scale through
colors.Normalize<\/code>) and color mapping (converting the 0-1 encoding to colors through
colors.Colormap<\/code>).
cm.ScalarMappable<\/code> is therefore at the root of the inheritance tree, together with `artist.Artist`. The figure below shows all the top-level plotting methods that use the data\u2192color transformation.<\/p>\n\n\n\n
<\/figure>\n\n\n\n
data\u2192color<\/code> pipeline may be shared by multiple elements in the same figure, but the current class hierarchy (subclassing
cm.ScallarMappable<\/code>) is not conducive to this use case, i.e. the user must manually add callbacks<\/a> between different graphical objects to obtain functionality such as syncing the colormaps across plots<\/p>\n\n\n\n
\n
data\u2192color<\/code> pipeline<\/li>\n\n\n\n
data\u2192color<\/code> pipeline\u00b9 (i.e. more modular code)<\/li>\n\n\n\n
<\/figure><\/div>\n\n\n
data\u2192color<\/code> transformation is contained in the new
colorizer.Colorizer<\/code> module, and one colorizer can control the
data\u2192color<\/code> pipeline for multiple plots:
<\/p>\n\n\n\n<\/figure>\n\n\n\n