没想到叭,阴影柱状图仅仅一天就迎来了(1.5.1)版本,已经支持水平柱状图绘制!!同时本人又连夜赶制了另外两款相关的阴影图绘制函数:
来来来,后文马上介绍一下这三款函数。
另:代码开发基于polyshape
对象,阴影柱状图绘制函数理论上需要至少R2017b
及之后版本才能使用(越新越好)。(polyshape yyds)
先讲解此函数如何使用,再在此部分最后给出完整代码:
基本使用设置为角度为pi/3,80根线条进行填充:
t=0:.01:2*pi;
X=cos(t);
Y=sin(t);
plot(X,Y,'LineWidth',2);
hold on;axis equal
shadowFill(X,Y,pi/3,80);
t=0:.01:2*pi;
y=sin(t);
plot(t,y,'LineWidth',2);
hold on;axis equal
shadowFill(t,y,pi/4,80);
这个就比较复杂了,给个例子:
t=-.1:.01:pi/2;
y1=sin(t).*2;
y2=t.^2;
hold on
plot(t,y1,'LineWidth',2);
plot(t,y2,'LineWidth',2);
diffy=y1-y2;
tpos=find(diffy>=0);
T=[t(tpos(1):tpos(end)),t(tpos(end):-1:tpos(1))];
Y=[y1(tpos(1):tpos(end)),y2(tpos(end):-1:tpos(1))];
shadowFill(T,Y,pi/5,70);
t=-.1:.01:pi/2;
y1=sin(t).*2;
y2=t.^2;
hold on
plot(t,y1,'LineWidth',2);
plot(t,y2,'LineWidth',2);
diffy=y1-y2;
tpos=find(diffy>=0);
T=[t(tpos(1):tpos(end)),t(tpos(end):-1:tpos(1))];
Y=[y1(tpos(1):tpos(end)),y2(tpos(end):-1:tpos(1))];
shadowFill(T,Y,pi/5,70,'LineStyle',':','Color',[.2,.2,.9]);
function SF=shadowFill(X,Y,theta,num,varargin)
% @author : slandarer
% gzh : slandarer随笔
if theta>pi/2||theta=max(tY))=[];tYY(tYY=max(tY))=[];tYY(tYY=max(tY))=[];tYY(tYY=max(tY))=[];tYY(tYY
关注
打赏