필터 지우기
필터 지우기

Transparency value in colormap

조회 수: 74 (최근 30일)
Zahra Yousefi Darani
Zahra Yousefi Darani 2022년 4월 27일
이동: DGM 2023년 3월 6일
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?

채택된 답변

DGM
DGM 2022년 4월 27일
편집: DGM 2022년 4월 27일
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
DGM
DGM 2022년 4월 29일
이동: DGM 2023년 3월 6일
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.
Zahra Yousefi Darani
Zahra Yousefi Darani 2022년 5월 6일
이동: DGM 2023년 3월 6일
Great! Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by