Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tutusjtu authored May 1, 2022
1 parent 2a0e9ae commit 0d82190
Show file tree
Hide file tree
Showing 29 changed files with 1,806 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Axes3DView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Axes3DView(handleMyAxes)
%控制视角、坐标轴平行等
%目前这些参数对1个图优化较好
set(handleMyAxes,'View',[45 15]);
handleMyAxes.XLabel.Rotation=-16;
handleMyAxes.YLabel.Rotation=16;
handleMyAxes.ZLabel.Rotation=90;
handleMyAxes.XLabel.HorizontalAlignment='right';
handleMyAxes.YLabel.HorizontalAlignment='left';
handleMyAxes.ZLabel.HorizontalAlignment='center';
handleMyAxes.ZGrid='off';
handleMyAxes.YLabel.VerticalAlignment='bottom';
end
Binary file added FigureBest_Pre(GUI).mlappinstall
Binary file not shown.
25 changes: 25 additions & 0 deletions axesfillfigure.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function axesfillfigure(figNum)
%% 放大笛卡尔坐标轴区域以填满figure区域
if nargin==0
figNum=get(get(groot,'CurrentFigure'),'Number');
warning('未找到图片,处理您的当前图片');
end
figHandle=fignum2handle(figNum);
axesHandle=findall(figHandle,'Type','axes');
if isempty(axesHandle)
return
end

%% 主要程序
for iaxesHandle=1:length(axesHandle)
ax = axesHandle(iaxesHandle);
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = (outerpos(1) + ti(1))*1.2;
bottom = (outerpos(2) + ti(2))*1;
ax_width = (outerpos(3) - ti(1) - ti(3))*1;
ax_height = (outerpos(4) - ti(2) - ti(4));
ax.Position = [left bottom ax_width ax_height];
shg
end
end
24 changes: 24 additions & 0 deletions choiceColorOrder.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function co=choiceColorOrder(iColor)
%绘图色系
switch iColor
case 21
co=[255 59 59;7 7 7];%二色红黑配图
case 22
co=[254 129 125;129 184 223];%二色红蓝配图
case 4
co=[23 23 23;6 233 6;255 28 0;0 37 255];%四色配色
case 3
co=[77 133 189;247 144 61;89 169 90];%三色配色
case 5
co=[1 86 153;250 192 15;243 118 74;95 118 74;95 198 201;79 89 109];%五色配色
case 6
co=[203 180 123;91 183 205; 71 120 185;84 172 117;197 86 89;117 114 181];%六色配色
case 42%红色(默认)
co=[224 160 158;0 0 0;117 36 35;161 47 47];
case 43%绿色色卡
co=[160 191 124;101 147 74;64 116 52;3 35 14];
otherwise
disp('该色卡不存在,采用默认值')
co=[255 59 59;7 7 7];
end
end
18 changes: 18 additions & 0 deletions colorchange.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function [iColorOrder,iColorMap]=colorchange(figNum,iColorOrder,iColorMap)
%% 更改配色方案
if nargin==2
iColorMap=iColorOrder;
elseif nargin==1
iColorOrder=42;
iColorMap=42;
end
figHandle=fignum2handle(figNum);
axesHandles=findall(figHandle,'Type','axes');
myColorOrder=colorlist(iColorOrder);
myColorMap=colorlist(iColorMap);
for iaxesHandles=1:length(axesHandles)
axesHandles(iaxesHandles).ColorOrder=repmat(myColorOrder,20,1);
axesHandles(iaxesHandles).Colormap=repmat(myColorMap,20,1);
end%对坐标轴进行循环
shg
end
25 changes: 25 additions & 0 deletions colorlist.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function color=colorlist(iColorOrder)
%绘图色系选择
switch iColorOrder
case 21
color=[255 59 59;7 7 7];%二色红黑配图
case 22
color=[254 129 125;129 184 223];%二色红蓝配图
case 4
color=[23 23 23;6 233 6;255 28 0;0 37 255];%四色配色
case 42%红色(默认)
color=[224 160 158;0 0 0;117 36 35;161 47 47];
case 43%绿色色卡
color=[160 191 124;101 147 74;64 116 52;3 35 14];
case 3
color=[77 133 189;247 144 61;89 169 90];%三色配色
case 5
color=[1 86 153;250 192 15;243 118 74;95 118 74;95 198 201;79 89 109];%五色配色
case 6
color=[203 180 123;91 183 205; 71 120 185;84 172 117;197 86 89;117 114 181];%六色配色
otherwise
disp('该色卡不存在,采用默认值')
color=[224 160 158;0 0 0;117 36 35;161 47 47];
end
color=color/255;
end
76 changes: 76 additions & 0 deletions controlAll.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
function controlAll(iNumber)
%function controlAll(iNumber)
if nargin==0
iNumber=get(gcf,'Number');
end
%% 全局变量
global isOut; %是否输出图片
global name; %输出图片名称
global iColor; %选择ColorOrder色系
global Dimention; %选择2/3维度绘图
global idrawType %以何种风格绘图1,2,3...
%...........................%更新中

%% figure窗口设置
handleMyFigure=controlFigure(iNumber);
if isempty(handleMyFigure)
return
end

%% axes坐标轴相关设置
%
% 获取所有的axes对象(剔除legend对象)
handleMyAxes=findobj(handleMyFigure.Children,'Type','Axes');
mMyAxes=size(handleMyAxes,1);
nMyAxes=size(handleMyAxes,2);
% 需要选择是否三维绘图
switch Dimention
case 3
dimentionControl=ones(mMyAxes,nMyAxes);
case 2
dimentionControl=zeros(mMyAxes,nMyAxes);
otherwise
disp('待开发')
end

for iMyAxes=1:mMyAxes
for jMyAxes=1:nMyAxes
%设置坐标轴的属性
handleMyAxes(iMyAxes,jMyAxes)=controlAxes(handleMyAxes(iMyAxes,jMyAxes),iColor);
%controlAxes(handleMyAxes,iColor);
%3D才调用,用于调整视图旋转
%控制坐标轴标签与轴平行,针对三维图,如果是三维图,请打开
if dimentionControl(iMyAxes,jMyAxes)==1
Axes3DView(handleMyAxes(iMyAxes,jMyAxes));
end
end
end

%% 曲线曲面控制(未完成.......)
for iMyAxes=1:mMyAxes
for jMyAxes=1:nMyAxes
handleMyDraw=handleMyAxes(iMyAxes,jMyAxes).Children;
nMyDraw=size(handleMyDraw,1)*size(handleMyDraw,2);
%生成绘图循环标记
myLineType=repmat({'-';'--';':'; '-.'},nMyDraw,1);%生成线型符号向量
myMarkerType=repmat({'s';'o';'<';'d';'>'},nMyDraw,1);%生成标记符号向量
myco=repmat(handleMyAxes(iMyAxes,jMyAxes).ColorOrder,[nMyDraw,1]);%修改线条颜色
for iMyDraw=1:nMyDraw
%开始针对不同的曲线曲面进行优化,输入任意曲线曲面的句柄
handleMyDraw(iMyDraw)=controlMatchElement(handleMyDraw(iMyDraw),iColor,myLineType{iMyDraw},...
myMarkerType{iMyDraw},myco(iMyDraw,:),idrawType);
end%对一个坐标轴中的每个线或者是每个面等绘图元素循环
end%对figure中的每一列循环
end%对figure中的每一行进行循环

%% 输出图形
if isOut==1
myExportFigure(handleMyFigure,name,'-dtiff');
%function myExportFigure(handleMyFigure,name,format)
end
%clc;
if isOut==1
disp('已完成!已保存图片!');
else
disp('已完成!未保存!');
end
88 changes: 88 additions & 0 deletions controlAxes.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
function handleMyAxes=controlAxes(handleMyAxes,iColor)
if nargin==1
iColor=4;
end
%% 颜色控制ColorOrder
% %绘图色系
% switch iColor
% case 21
% co=[255 59 59;7 7 7];%二色红黑配图
% case 22
% co=[254 129 125;129 184 223];%二色红蓝配图
% case 4
% co=[23 23 23;6 233 6;255 28 0;0 37 255];%四色配色
% case 3
% co=[77 133 189;247 144 61;89 169 90];%三色配色
% case 5
% co=[1 86 153;250 192 15;243 118 74;95 118 74;95 198 201;79 89 109];%五色配色
% case 6
% co=[203 180 123;91 183 205; 71 120 185;84 172 117;197 86 89;117 114 181];%六色配色
% otherwise
% disp('色卡不存在,采用默认值')
% co=[255 59 59;7 7 7];
% end
co=choiceColorOrder(iColor);
set(handleMyAxes,'ColorOrder',co/255,'NextPlot','add');
colormap(handleMyAxes,co/255);
%% 坐标轴参数
%Latex解释器中似乎不支持中文
%书写标签和标题
set(handleMyAxes.XLabel,'Interpreter','latex');
set(handleMyAxes.YLabel,'Interpreter','latex');
set(handleMyAxes.ZLabel,'Interpreter','latex');
set(handleMyAxes.Title,'Interpreter','latex');
if isempty(handleMyAxes.XLabel.String)
handleMyAxes.XLabel.String='$\bf xxxXXX\ {label\ in\ Latex}$';
end
if isempty(handleMyAxes.YLabel.String)
handleMyAxes.YLabel.String='$\bf yyyYYY\ {label\ in\ Latex}$';
end
if isempty(handleMyAxes.ZLabel.String)
handleMyAxes.ZLabel.String='$\bf zzzZZZ\ {label\ in\ Latex}$';
end
if isempty(handleMyAxes.Title.String)
handleMyAxes.Title.String='$\ \bf{Figure\ Title}\ f(x)$';%标题加粗了
end
%设置坐标轴标签字体和字号
myFontNameLabel='Arial';
handleMyAxes.XLabel.FontName=myFontNameLabel;
handleMyAxes.YLabel.FontName=myFontNameLabel;
handleMyAxes.ZLabel.FontName=myFontNameLabel;
myFontSizeLabel=12;
handleMyAxes.XLabel.FontSize=myFontSizeLabel;
handleMyAxes.YLabel.FontSize=myFontSizeLabel;
handleMyAxes.ZLabel.FontSize=myFontSizeLabel;
%%设置坐标轴刻度字体和字号
myFontName='Arial';
handleMyAxes.FontName=myFontName;
myFontSize=12;
handleMyAxes.FontSize=myFontSize;
handleMyAxes.FontWeight='Bold';
%打开坐标轴边框
handleMyAxes.Box='on';
%设置坐标轴边框线宽
handleMyAxes.LineWidth=1.5;
%设置grid
handleMyAxes.XGrid='on';
handleMyAxes.YGrid='on';
handleMyAxes.ZGrid='on';
handleMyAxes.GridLineStyle='--';
%小刻度
handleMyAxes.XMinorTick='on';
handleMyAxes.YMinorTick='on';
handleMyAxes.ZMinorTick='on';
%hold on属性
handleMyAxes.NextPlot='add';
%光照效果
%handleMyAxes.AmbientLightColor='w';
%% 图例控制与生成
%Legend图例
%创建Legend句柄
% if size(handleMyAxes.Legend,1)==0
handleLegend=legend(handleMyAxes,'show');
% else
% handleLegend=handleMyAxes.Legend;
% disp('注意!二次操作图像是否有影响');
% end
controlLegend(handleLegend);
end
46 changes: 46 additions & 0 deletions controlBarBoldNoColor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function handleMyDraw=controlBarBoldNoColor(handleMyDraw,iColor)
%设置柱状图的格式
% 读取色卡
co=choiceColorOrder(iColor);
handleMyDraw.LineWidth=1.5;
handleMyDraw.EdgeColor=[0 0 0];
% handleMyDraw.AlignVertexCenters='on';%锐化边线
%反设坐标轴属性以适应当前柱形图
handleMyDraw.Parent.LineWidth=1.5;
handleMyDraw.Parent.Box='on';
handleMyDraw.Parent.XGrid='on';
handleMyDraw.Parent.YGrid='on';
handleMyDraw.Parent.ZGrid='on';
handleMyDraw.Parent.GridLineStyle='--';
handleMyDraw.Parent.GridAlpha=0.2;%网格线的透明度
handleMyDraw.Parent.GridColor=[.2 .2 .2];
handleMyDraw.Parent.GridAlpha=0.2;
handleMyDraw.Parent.Color='w';
handleMyDraw.Parent.FontWeight='bold';%改为正常粗细
%图例
% handleMyDraw.Parent.Legend.Location='northwest';
% handleMyDraw.Parent.Legend.Box='off';
% handleMyDraw.Parent.Legend.FontWeight='normal'%改为正常粗细
%修改标签字体(改为不加粗版本)
%有那么多if是为了避免刷新已经有的文字
if isempty(handleMyDraw.Parent.XLabel.String)
handleMyDraw.Parent.XLabel.String='$\rm xxxXXX\ {label\ in\ Latex}$';
end
if isempty(handleMyDraw.Parent.YLabel.String)
handleMyDraw.Parent.YLabel.String='$\rm yyyYYY\ {label\ in\ Latex}$';
end
if isempty(handleMyDraw.Parent.ZLabel.String)
handleMyDraw.Parent.ZLabel.String='$\rm zzzZZZ\ {label\ in\ Latex}$';
end
if isempty(handleMyDraw.Parent.Title.String)
handleMyDraw.Parent.Title.String='$\ \rm{Figure\ Title}\ f(x)$';
end


handletexts=findall(handleMyDraw.Parent.Children,'Type','text');
for i=1:length(handletexts)
handletexts(i).EdgeColor='none';
set(handletexts(i),'FontWeight','bold');
end

end
43 changes: 43 additions & 0 deletions controlBarLightColor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function handleMyDraw=controlBarLightColor(handleMyDraw,iColor)
%设置柱状图的格式
% 读取色卡
co=choiceColorOrder(iColor);
handleMyDraw.LineWidth=0.5;
handleMyDraw.EdgeColor='w';
% handleMyDraw.AlignVertexCenters='on';%锐化边线
%反设坐标轴属性以适应当前柱形图
handleMyDraw.Parent.LineWidth=0.5;
handleMyDraw.Parent.Box='off';
handleMyDraw.Parent.XGrid='on';
handleMyDraw.Parent.YGrid='on';
handleMyDraw.Parent.ZGrid='on';
handleMyDraw.Parent.GridLineStyle='--';
handleMyDraw.Parent.GridAlpha=0.8;%网格线的透明度
handleMyDraw.Parent.GridColor=[1 1 1];
handleMyDraw.Parent.Color=([1 1 1]-co(1,:)/255)*0.8+co(1,:)/255;
handleMyDraw.Parent.FontWeight='normal';%改为正常粗细
%图例
% handleMyDraw.Parent.Legend.Location='northwest';
% handleMyDraw.Parent.Legend.Box='off';
% handleMyDraw.Parent.Legend.FontWeight='normal'%改为正常粗细
%修改标签字体(改为不加粗版本)
%有那么多if是为了避免刷新已经有的文字
if isempty(handleMyDraw.Parent.XLabel.String)
handleMyDraw.Parent.XLabel.String='$\rm xxxXXX\ {label\ in\ Latex}$';
end
if isempty(handleMyDraw.Parent.YLabel.String)
handleMyDraw.Parent.YLabel.String='$\rm yyyYYY\ {label\ in\ Latex}$';
end
if isempty(handleMyDraw.Parent.ZLabel.String)
handleMyDraw.Parent.ZLabel.String='$\rm zzzZZZ\ {label\ in\ Latex}$';
end
if isempty(handleMyDraw.Parent.Title.String)
handleMyDraw.Parent.Title.String='$\ \rm{Figure\ Title}\ f(x)$';
end

handletexts=findall(handleMyDraw.Parent.Children,'Type','text');
for i=1:length(handletexts)
handletexts(i).EdgeColor='none';
set(handletexts(i),'FontWeight','normal');
end
end
Loading

0 comments on commit 0d82190

Please sign in to comment.