Transparency value in colormap
62 views (last 30 days)
Show older comments
For matching the color of data to colorbar, I need to define a colormap with 4 columns,
last column includes transparency, How can I define that?
0 Comments
Accepted Answer
DGM
on 27 Apr 2022
Edited: DGM
on 27 Apr 2022
Colormaps and colorbars do not support RGBA formats (as far as I know). Transparency is handled separately by the AlphaData property on objects that support it.
It doesn't make any sense that you would need RGBA colormaps to "match color of data to the colorbar". The apparent color of a semitransparent colored element is a function of its own color and the color of objects beneath it. What do you expect to be beneath your graphics object and/or colorbar, and why would you require alpha blending the two in a scheme to reinvent basic colormapping? The mapping provided with colormaps/colorbars is 1D. Are you expecting to be able to implement a 2D mapping process by having alpha as an extra map dimension? If so, this tangent might be of interest.
Come to think of it, what sort of graphics object are you trying to do this on?
5 Comments
DGM
on 29 Apr 2022
Moved: DGM
on 6 Mar 2023
I think a hypothetical 1D RGBA colormapping process is conceivable. The ordering would simply be dependent on the relative locations of the colors in the colormap -- which could be any arbitrary trajectory in N dimensions.
I think the problem is in the rendering and usability. The only way you can visualize transparency is by putting something beneath it. So I see two possibilities:
- The colorbar is rendered over a test pattern and the plot (e.g. a surface) is rendered over whatever is behind it (including itself). In this case, I don't think it's reasonable to expect any ability to visually correlate a particular semitransparent color with the corresponding point in the colorbar to any practical degree of accuracy.
- The colorbar and plot object are rendered over identical solid color fields for sake of consistency and readability. In this case, transparency can simply be eliminated from the colormapping process entirely.
The first case might not be too big of a stretch if the requirements are minimal, the transparency is constant, and the background uncomplicated. It might not be the best, but it's easy enough to read something quantized like a transparent contourf() plot over a grayscale map, so maybe there are other cases that would be manageable.
I suppose that brings up another interpretation. Even if the alpha is constant and the background grayscale, how should the colorbar be presented?
- As a 1D strip at 100% alpha (the normal behavior)
- As a 1D strip at the chosen alpha, atop a uniform field at some (e.g. 50%) gray level
- As a 2D patch that represents the colormap at the chosen alpha over a 0% to 100% gray sweep
Just throwing that out there.
More Answers (0)
See Also
Categories
Find more on Blue in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!