Reputation: 111
I am trying to plot a surface. However, I do not much understand how to change the color of the plot. I have studied and tried various options without much success. Here is the code for the surface plot:
clear all;
[X,Y]=meshgrid(-10:.1:10);
p=X;
[X, Y] = meshgrid(-20:.2:20);
q=Y;
a = 10;
b = 20;
Z=2*a.*p+p.^2-2*b.*q-q.^2;
figure;
H=surf(p,q,Z)
xlim([-10 10]);
ylim([-20 20]);
% colormap jet;
hold on;
view([150 25]);
xlabel('p');
ylabel('q');
zlabel('The Data Z');
print -r600 -depsc Figure.eps;
I have tried different colormap
with jet
, winter
or hsv
arguments. I have also tried various options similar to the following:
c = jet(6);
colormap(c);
However, all I get is a figure with dark shade like the following:
I would like to change the colors of the surface plot to something lighter, e.g. shades of light blue, cyan or light green. Any help with this will be much appreciated.
Thanks in advance,
A.
Upvotes: 1
Views: 4017
Reputation: 6863
You are predominantly seeing the edges right now, which are black by default. There is a couple things you can do.
H.EdgeColor = 'none';
H.EdgeAlpha = 0.5;
surf
, set the edge color to 'none'
, plot your data with a rough meshgrid using mesh
to show lines, making it easier to see the plane. % generate data
a = 10;
b = 20;
xv = -10:.1:10;
yv = -20:.2:20;
[X,Y]=meshgrid(xv,yv);
Z=2*a.*X+X.^2-2*b.*Y-Y.^2;
% make data more course.
xv_course = -10:1:10;
yv_course = -20:1:20;
[Xc,Yc]=meshgrid(xv_course,yv_course);
Zc = 2*a.*Xc+Xc.^2-2*b.*Yc-Yc.^2;
figure(1); clf;
Hs = surf(X,Y,Z, 'EdgeColor', 'none');
colormap cool
hold on;
Hm = mesh(Xc,Yc,Zc, 'EdgeColor', 'k', 'FaceColor', 'none');
view([150 25]);
xlabel('x');
ylabel('y');
zlabel('The Data Z');
Upvotes: 3