Transparency value in colormap

80 views (last 30 days)
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?

Accepted Answer

DGM
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?

More Answers (1)

Zahra Yousefi Darani
Zahra Yousefi Darani on 28 Apr 2022
When programatically, color values ( four values, three for colours, the last for transparency) of every plot in every iteration of the loop are saved in a vector, after ending the loop, colorbar does not follow the colors of plots,
I should define a colormap based on color values that has been saved in the vector to force the colorbar to match my data,
but colormap only accepts three columns, do you have any solution for this issue? Or another way to make the colorbar matches the plotted data?
  4 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!