Change color pdegplot/ gradient
13 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Ravi Kumar
on 9 May 2020
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
More Answers (0)
See Also
Categories
Find more on Geometry and Mesh 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!