您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > MATLAB强大的线条与渐变颜色设置
1渐变1.1t=[linspace(0,2*pi)nan];x=sin(t);y=cos(2*t);z=sqrt(t);%所要绘制的曲线方程patch(x,y,z,z,'edgecolor','flat','facecolor','none')view(3);gridon;colorbar1.2x=-200:5:200;y=-200:5:200;z=-200:5:200;m=linspace(0,1,length(x));fori=1:length(x);plot3(x(i),y(i),z(i),'o','color',[m(i)00])holdonend1.3柱状图填色Matlab绘制彩色柱状图(2012-09-2812:58:34)转载▼标签:彩色柱状图杂谈分类:Matlab首先,看一下效果图。默认条件下的柱状图颜色均为蓝色,现在可以绘制漂亮的柱状图以及渐变着色的柱状图。%彩色柱状图%%用到的数据n=13;Z=rand(n,1);%%默认图片bar(Z);%%简单的作图%这个图根据数据列中值的大小着色。每列中的%值越大,颜色越突出figureh=bar(Z);colormap(summer(n));ch=get(h,'Children');fvd=get(ch,'Faces');fvcd=get(ch,'FaceVertexCData');[~,izs]=sortrows(Z,1);fori=1:nrow=izs(i);fvcd(fvd(row,:))=i;endset(ch,'FaceVertexCData',fvcd)%%更加漂亮的图片%图片会以渐变的方式着色,效果非常不错figureh=bar(Z);ch=get(h,'Children');fvd=get(ch,'Faces');fvcd=get(ch,'FaceVertexCData');[zs,izs]=sortrows(Z,1);k=128;%准备生成128*3行的colormapcolormap(summer(k));%这样会产生一个128*3的矩阵,分别代表[RGB]的值%检视数据whoschfvdfvcdzsizs%%NameSizeBytesClassAttributes%%ch1x18double%fvcd66x1528double%fvd13x4416double%izs13x1104double%zs13x1104double%shadinginterp%Neededtograduatecolorsfori=1:ncolor=floor(k*i/n);%这里用取整函数获得color在colormap中行row=izs(i);%Lookupactualrow#indatafvcd(fvd(row,1))=1;%Colorbasevertices1stindexfvcd(fvd(row,4))=1;fvcd(fvd(row,2))=color;%Assigntopverticescolorfvcd(fvd(row,3))=color;endset(ch,'FaceVertexCData',fvcd);%Applythevertexcoloringset(ch,'EdgeColor','k')2符号/线型/颜色/绘图标记bblue.point-solidggreenocircle:dottedrredxx-mark-.dashdotccyan+plus--dashedmmagenta*star(none)nolineyyellowssquarekblackddiamondwwhitevtriangle(down)^triangle(up)triangle(left)triangle(right)ppentagram正五边形hhexagram正六边形gridon坐标带网格线axison显示坐标轴相关标记axissquare显示方形的立体的length(x)=msize(x)=(m,n)meshsurf绘制三维图(网格图表面图)meshc绘制带有等值线的三维网格图[x,y]=meshgrid(x,y)holdon图形保持功能SUBPLOT(m,n,p)分子区域绘图AXIS([XMINXMAXYMINYMAX])指定坐标轴的范围x=rand(3,2)bar3(x)三维柱状图barh横向的pie饼状图pie([2435],{'North','South','East','West'})contour等值线的绘制view(az,el)、view([az,el])指定方位角和俯仰角的大小plot(x_a,0,'h','MarkerSize',16)
本文标题:MATLAB强大的线条与渐变颜色设置
链接地址:https://www.777doc.com/doc-2887474 .html