Setting colormap to lines from streamslice

조회 수: 3 (최근 30일)
Aatresh Karnam
Aatresh Karnam 2024년 1월 22일
댓글: Aatresh Karnam 2024년 1월 24일
Hi all,
I am trying to apply a colormap to a set of lines generated via streamslice.
The general approach seems to be to set all the lines to a single color through the following method:
h = streamslice(X,Y,Z,uData,vData,zData,[],[],[],5);
set(h,'Color','k');
All the streamlines are grouped in h and share the Primitive Line charateristics, hence the colormap property does not apply to them.
I have tried setting the colormap to the axis Color Order parameter before generating the streamlines but that seems to get overwitten by the default color order once I plot the streamlines. Although I use a 256 x 3 color space, the number of streamlines that are generated far exceeds this which means I cannot assign an individual color to each of the lines in h.
For context, the end result I wanted to achieve is something along the lines of the image below. Any help would be appreciated. Thanks a lot
  댓글 수: 2
vidyesh
vidyesh 2024년 1월 22일
MATLAB uses Hexadecimal Color Code which has 16,777,216 (256 x 256 x 256) possible colors.
Do the number of lines exceed this?
Aatresh Karnam
Aatresh Karnam 2024년 1월 23일
편집: Aatresh Karnam 2024년 1월 23일
My colormap is defined as an RGB triplet in 256 format (256 x 3) instead of the regular 64 x 3 colormap format. The number of lines can easily exceed that limit since for streamslice the colors are set on a per line basis from what I can see in the help section and in the few queries on the forum.

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

채택된 답변

Taylor
Taylor 2024년 1월 23일
You could just randomly generate the colors:
load wind
lineObj = streamslice(x,y,z,u,v,w,[],[],5,'noarrows');
for ii = 1:length(lineObj)
lineObj(ii).Color = [rand(1) rand(1) rand(1)];
end
  댓글 수: 1
Aatresh Karnam
Aatresh Karnam 2024년 1월 24일
I guess this will have to do for now, thanks Taylor. I might try interpolating across my custom colormap using interp1 to add in points to match the line family from streamslice. It would have been easier if the custom colormap assigned to the axis ColorOrder was not overwritten when plotting streamlines. That way the colors would keep cycling through the colormap and generate a repeating pattern.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by