rgb2cm - Fix RGB color data in Painter's mode
Painter's mode rendering is required for copying a figure to the clipboard as an EMF (vector format) or printing to vector-format files such as PDF and EPS. However, if the colours of any patches in your figure are represented using CData and an RGB colour code, these will not show in the copied figure. You may also get a warning like:
Warning: RGB color data not yet supported in Painter's mode
The solution is to change these specific patches to use an index into the colormap. That's what this script does. For each patch using RGB, it adds those colours to the colormap and changes the patch to use a colormap index.