Change color pdegplot/ gradient

조회 수: 11 (최근 30일)
Arthur
Arthur 2020년 5월 8일
댓글: Arthur 2020년 5월 9일
I'm working on a project where it's useful to view the geometry and the gradient at the same time, but need a way to change the color of at least one of them.
I've written you guys some lines to show what I'd want to do
model = createpde;
R = [3,4,-2,-2,2,2,-3,3,3,-3]';
C = [1,0,0,1]';
C = [C;zeros(length(R)-length(C),1)];
gm = [R,C];
sf = 'R+C';
ns = char('R','C');
ns = ns';
[dl1,~] = decsg(gm,sf,ns);
geometryFromEdges(model,dl1);
applyBoundaryCondition(model,'dirichlet','Edge',[1,2,3,4],'u',0);
applyBoundaryCondition(model,'dirichlet','Edge',[5,6,7,8],'u',-10);
specifyCoefficients(model,'m',0,'d',0,'a',0,'c',5,'f',0,'face',1);
specifyCoefficients(model,'m',0,'d',0,'a',0,'c',5,'f',-2,'face',2);
mesh = generateMesh(model);
res = solvepde(model);
figure()
pdeplot(model,'FlowData',[res.XGradients,res.YGradients],'ColorMap',gray);
hold on
pdegplot(model,'FaceLabels','off','EdgeLabels','off','VertexLabels','off');
axis equal
hold off
The problem with this code is that both the gradient and the edges are in red, and this isn't that easy to read.
Can you tell me how to change preferably 2, but at least 1 of these colors?
Thanks

채택된 답변

Ravi Kumar
Ravi Kumar 2020년 5월 9일
One workaround would be switch the order of plots:
figure()
pdegplot(model,'FaceLabels','off','EdgeLabels','off','VertexLabels','off');
axis equal
hold on
pdeplot(model,'FlowData',[res.XGradients,res.YGradients]);
hold off
Regards,
Ravi
  댓글 수: 1
Arthur
Arthur 2020년 5월 9일
I did not see the answer being this easy.
Thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by