diff --git a/Axes3DView.m b/Axes3DView.m new file mode 100644 index 0000000..103ea6d --- /dev/null +++ b/Axes3DView.m @@ -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 diff --git a/FigureBest_Pre(GUI).mlappinstall b/FigureBest_Pre(GUI).mlappinstall new file mode 100644 index 0000000..6860cbc Binary files /dev/null and b/FigureBest_Pre(GUI).mlappinstall differ diff --git a/axesfillfigure.m b/axesfillfigure.m new file mode 100644 index 0000000..ddf3915 --- /dev/null +++ b/axesfillfigure.m @@ -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 diff --git a/choiceColorOrder.m b/choiceColorOrder.m new file mode 100644 index 0000000..8ec2579 --- /dev/null +++ b/choiceColorOrder.m @@ -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 \ No newline at end of file diff --git a/colorchange.m b/colorchange.m new file mode 100644 index 0000000..f10ee15 --- /dev/null +++ b/colorchange.m @@ -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 \ No newline at end of file diff --git a/colorlist.m b/colorlist.m new file mode 100644 index 0000000..bf25274 --- /dev/null +++ b/colorlist.m @@ -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 \ No newline at end of file diff --git a/controlAll.m b/controlAll.m new file mode 100644 index 0000000..8d08699 --- /dev/null +++ b/controlAll.m @@ -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 \ No newline at end of file diff --git a/controlAxes.m b/controlAxes.m new file mode 100644 index 0000000..eacd55c --- /dev/null +++ b/controlAxes.m @@ -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 \ No newline at end of file diff --git a/controlBarBoldNoColor.m b/controlBarBoldNoColor.m new file mode 100644 index 0000000..905de40 --- /dev/null +++ b/controlBarBoldNoColor.m @@ -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 \ No newline at end of file diff --git a/controlBarLightColor.m b/controlBarLightColor.m new file mode 100644 index 0000000..b84b770 --- /dev/null +++ b/controlBarLightColor.m @@ -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 \ No newline at end of file diff --git a/controlFigure.m b/controlFigure.m new file mode 100644 index 0000000..ead8527 --- /dev/null +++ b/controlFigure.m @@ -0,0 +1,45 @@ +function handleMyFigure=controlFigure(iNumber,iColumn) +%% 缺省参数 +%function handleMyFigure=controlFigure(iNumber) +if nargin==0 + iNumber=get(gcf,'Number'); + iColumn=1; +elseif nargin==1 + iColumn=1; +end + +handleMyFigure=findobj('Type', 'figure','Number',iNumber); + +if isempty(handleMyFigure) + iNumberCell=inputdlg('重新输入正确的figure数字(一次一个数)','输入错误',[1 50]) ; + iNumber=str2num(iNumberCell{1}); + handleMyFigure=findobj('Type', 'figure','Number',iNumber); + if isempty(handleMyFigure) + clc; + [IconData,IconCMap]=imread('tutu.jpg'); + msgbox('数字输入错误,程序自动退出(开发者公众号:tutongdao)','error','custom',IconData,IconCMap);pause(1); + return + end +end + +%% figure窗口设置 +% 输入:figure句柄,默认当前gcf +% 返回:修改后的figure句柄 +handleMyFigure.Name='图图的绘图格式'; +handleMyFigure.Units='centimeters'; %改为厘米为单位 +%打印属性 和图片属性相仿 +handleMyFigure.PaperUnits='centimeters'; +if iColumn==1 + %设置图片的大小,双栏选择[10, 10, 9, 6.75]cm,[相对位置 宽度高度] + handleMyFigure.Position=[10, 4, 19, 14.25]; + handleMyFigure.PaperPosition=[10, 4, 19, 14.25]; +else + handleMyFigure.Position=[10, 10, 9, 6.75]; + handleMyFigure.PaperPosition=[10, 10, 9, 6.75]; +end + +handleMyFigure.Resize='off'; +handleMyFigure.Color='w'; %将图形背景设置为白色 + +handleMyFigure.InvertHardcopy='off';%保存图像坐标背景色 +end \ No newline at end of file diff --git a/controlLegend.m b/controlLegend.m new file mode 100644 index 0000000..712cd1f --- /dev/null +++ b/controlLegend.m @@ -0,0 +1,17 @@ +function handleLegend=controlLegend(handleLegend,isVisible) +if nargin==1 + isVisible='on'; +end +%设置图例的排布方式 +%!!!!图例的位置相对于figure而不是相对于axes的!!!! +handleLegend.Location='northeast'; %图例方位 +handleLegend.Orientation='vertical'; %图例垂直排布 +% handleLegend.NumColumns=1; %图例列数 +%handleLegend.Position(3)=0.1; %只改变图例宽度 +handleLegend.FontName='Arial'; +handleLegend.FontSize=12; +handleLegend.LineWidth=1.5; +handleLegend.Box='on'; +handleLegend.Visible=isVisible; +return +end \ No newline at end of file diff --git a/controlLine.m b/controlLine.m new file mode 100644 index 0000000..57a9f72 --- /dev/null +++ b/controlLine.m @@ -0,0 +1,25 @@ +function handleMyDraw=controlLine(handleMyDraw,myLineType,myMarkerType,myco,iColor) +%% 设置线条的格式 +handleMyDraw.Color=myco; +handleMyDraw.LineWidth=1.5; +handleMyDraw.MarkerSize=5; +handleMyDraw.LineStyle=myLineType; +handleMyDraw.Marker=myMarkerType; +handleMyDraw.MarkerFaceColor='w'; +handleMyDraw.Parent.Color='w'; +handleMyDraw.Parent.GridColor=[0.2 0.2 0.2]; +handleMyDraw.Parent.GridAlpha=0.2;%网格线的透明度 +%% 初始化文字信息 +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 +end \ No newline at end of file diff --git a/controlLineLightColor.m b/controlLineLightColor.m new file mode 100644 index 0000000..fe60792 --- /dev/null +++ b/controlLineLightColor.m @@ -0,0 +1,27 @@ +function handleMyDraw=controlLineLightColor(handleMyDraw,myLineType,myMarkerType,myco,iColor) +%% 设置线条的格式 +handleMyDraw.Color=myco; +handleMyDraw.LineWidth=1; +handleMyDraw.MarkerSize=5; +handleMyDraw.LineStyle=myLineType; +handleMyDraw.Marker='none'; +handleMyDraw.MarkerFaceColor='none'; +%% 反设坐标轴属性以适应当前柱形图 +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]; +co=choiceColorOrder(iColor); +handleMyDraw.Parent.Color=([1 1 1]-co(1,:)/255)*0.9+co(1,:)/255; +handleMyDraw.Parent.FontWeight='normal';%改为正常粗细 +%% 图例 +% handleMyDraw.Parent.Legend.Location='northeast'; +% handleMyDraw.Parent.Legend.FontWeight='normal'%改为正常粗细 +% handleMyDraw.Parent.Legend.LineWidth=0.5; +% handleMyDraw.Parent.Legend.Color='none'; +% handleMyDraw.Parent.Legend.EdgeColor='none'; +end \ No newline at end of file diff --git a/controlMatchElement.m b/controlMatchElement.m new file mode 100644 index 0000000..817038b --- /dev/null +++ b/controlMatchElement.m @@ -0,0 +1,38 @@ +function handleMyDraw=controlMatchElement(handleMyDraw,iColor,myLineType,myMarkerType,myco,idrawType) +if nargin==5 + idrawType=1; +end +switch handleMyDraw.Type + + case 'line' %控制线图 line:plot函数等 + if idrawType==1 + controlLineLightColor(handleMyDraw,myLineType,myMarkerType,myco,iColor); + elseif idrawType==2 + controlLine(handleMyDraw,myLineType,myMarkerType,myco,iColor); + else + disp('在controlMatch中无此方案') + return + end + case 'surface' %三维面图 + if idrawType==1 + controlSurfaceLightColor(handleMyDraw,iColor);%绘制轻线条上色的条形图 + elseif idrawType==2 + controlSurfaceBoldNoColor(handleMyDraw,iColor);%绘制粗线条无颜色图 + else + disp('在controlMatch中无此方案') + return + end + case {'bar','histogram','text'} %二维条形图 + if idrawType==1 + controlBarLightColor(handleMyDraw,iColor);%绘制轻线条上色的条形图 + elseif idrawType==2 + controlBarBoldNoColor(handleMyDraw,iColor); + else + disp('在controlMatch中无此方案'); + return + end + otherwise + return + disp('未针对当前图线做出特别优化') +end +end \ No newline at end of file diff --git a/controlSurfaceBoldNoColor.m b/controlSurfaceBoldNoColor.m new file mode 100644 index 0000000..ed6e86c --- /dev/null +++ b/controlSurfaceBoldNoColor.m @@ -0,0 +1,38 @@ +function handleMyDraw=controlSurfaceBoldNoColor(handleMyDraw,iColor) +%设置柱状图的格式 +%设置柱状图的格式 +% 读取色卡 +co=choiceColorOrder(iColor); +handleMyDraw.LineWidth=1; +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.Color='w'; +handleMyDraw.Parent.FontWeight='bold';%改为正常粗细 +%图例 +% handleMyDraw.Parent.Legend.Location='east'; +% 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 +end \ No newline at end of file diff --git a/controlSurfaceLightColor.m b/controlSurfaceLightColor.m new file mode 100644 index 0000000..1b7c35f --- /dev/null +++ b/controlSurfaceLightColor.m @@ -0,0 +1,37 @@ +function handleMyDraw=controlSurfaceLightColor(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.9+co(1,:)/255; +handleMyDraw.Parent.FontWeight='normal';%改为正常粗细 +%图例 +% handleMyDraw.Parent.Legend.Location='east'; +% 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 +end \ No newline at end of file diff --git a/fignum2handle.m b/fignum2handle.m new file mode 100644 index 0000000..e83576a --- /dev/null +++ b/fignum2handle.m @@ -0,0 +1,21 @@ +function figHandle=fignum2handle(figNum) +%% 此函数将图形左上角的数字转换为图形句柄输出 +% function figHandle=figNumtofigHandle(figNum) +% figNum是标量数字 + +if nargin==0 & ~isempty(get(groot,'CurrentFigure')) + figHandle=gcf; + warning('未找到图片,处理您的当前图片'); + return +elseif nargin==0 & isempty(get(groot,'CurrentFigure')) + warndlg('不存在任何图片!'); + return +end + +%% 主要的程序代码 +figHandle=findall(groot,'Type','figure','Number',figNum); +if isempty(figHandle) + warndlg('未找到!'); + figHandle.delete; +end +end \ No newline at end of file diff --git a/figurebestgui.fig b/figurebestgui.fig new file mode 100644 index 0000000..4c5faac Binary files /dev/null and b/figurebestgui.fig differ diff --git a/figurebestgui.m b/figurebestgui.m new file mode 100644 index 0000000..e8ea821 --- /dev/null +++ b/figurebestgui.m @@ -0,0 +1,937 @@ +function varargout = figurebestgui(varargin) +% FIGUREBESTGUI MATLAB code for figurebestgui.fig +% FIGUREBESTGUI, by itself, creates a new FIGUREBESTGUI or raises the existing +% singleton*. +% +% H = FIGUREBESTGUI returns the handle to a new FIGUREBESTGUI or the handle to +% the existing singleton*. +% +% FIGUREBESTGUI('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in FIGUREBESTGUI.M with the given input arguments. +% +% FIGUREBESTGUI('Property','Value',...) creates a new FIGUREBESTGUI or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before figurebestgui_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to figurebestgui_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help figurebestgui + +% Last Modified by GUIDE v2.5 30-Jun-2020 18:31:29 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @figurebestgui_OpeningFcn, ... + 'gui_OutputFcn', @figurebestgui_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before figurebestgui is made visible. +function figurebestgui_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to figurebestgui (see VARARGIN) + +% Choose default command line output for figurebestgui +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes figurebestgui wait for user response (see UIRESUME) +% uiwait(handles.FB); + + +% --- Outputs from this function are returned to the command line. +function varargout = figurebestgui_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes on button press in start. +function start_Callback(hObject, eventdata, handles) + +set(handles.remind,'String','美化进行中......'); + +iNumberVector=str2num(handles.iNumber.String); +global iColor; +global idrawType; +global name; +global Dimention; +global isOut; +iColor=getappdata(handles.color,'Color'); +idrawType=getappdata(handles.iDrawType,'iDrawType'); +name=string(getappdata(handles.name,'name')); +Dimention=getappdata(handles.is3D,'is3D'); +isOut=getappdata(handles.isOut,'isOut'); +if ~isempty(iNumberVector) + for i=1:length(iNumberVector) + controlAll(iNumberVector(i)); + end +else + f=gcf; + controlAll(f.Number); +end + +if isOut==1 + set(handles.remind,'String',['美化已经完成!','并且已经保存!']); +else + set(handles.remind,'String',['美化已经完成!','但是未保存!如需保存,请勾选“输出”']); +end + + + + + + +function iNumber_Callback(hObject, eventdata, handles) +% hObject handle to iNumber (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of iNumber as text +% str2double(get(hObject,'String')) returns contents of iNumber as a double + + +% --- Executes during object creation, after setting all properties. +function iNumber_CreateFcn(hObject, eventdata, handles) +% hObject handle to iNumber (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% -------------------------------------------------------------------- +function Untitled_1_Callback(hObject, eventdata, handles) +% hObject handle to Untitled_1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +close(findall(0,'tag','Msgbox_ ')); + +% -------------------------------------------------------------------- +function ICON1_Callback(hObject, eventdata, handles) +% hObject handle to ICON1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +h=imshow('tutu.jpg'); +f=h.Parent.Parent; +f.Name='开发者信息:微信公众号'; +f.Resize='off'; +f.Position=[100 100 400 400]; +f.NumberTitle='off'; +f.MenuBar='none' +shg; +% axis off; + + +% --- Executes on selection change in iDrawType. +function iDrawType_Callback(hObject, eventdata, handles) +% hObject handle to iDrawType (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = cellstr(get(hObject,'String')) returns iDrawType contents as cell array +% contents{get(hObject,'Value')} returns selected item from iDrawType +T=0; +switch hObject.Value + case 1 + T=2; + case 2 + T=1; + case 3 + T=2; +end +setappdata(hObject,'iDrawType',T); + + +% --- Executes during object creation, after setting all properties. +function iDrawType_CreateFcn(hObject, eventdata, handles) +% hObject handle to iDrawType (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu controls usually have a white background on Windows. +% See ISPC and COMPUTER. + +setappdata(hObject,'iDrawType',2); + +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end +set(hObject,'Visible','off'); + + +% --- Executes on selection change in color. +function color_Callback(hObject, eventdata, handles) +% hObject handle to color (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: contents = cellstr(get(hObject,'String')) returns color contents as cell array +% contents{get(hObject,'Value')} returns selected item from color + +switch hObject.Value + case 1 + C=42; + case 2 + C=21; + case 3 + C=22; + case 4 + C=3; + case 5 + C=41; + case 6 + C=42; + case 7 + C=43; + case 8 + C=5; + case 9 + C=6; +end +setappdata(hObject,'Color',C); + + +% --- Executes during object creation, after setting all properties. +function color_CreateFcn(hObject, eventdata, handles) +% hObject handle to color (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: popupmenu controls usually have a white background on Windows. +% See ISPC and COMPUTER. +setappdata(hObject,'Color',21); + +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + +end +set(hObject,'Visible','off'); + + +% --- Executes on button press in result. +function result_Callback(hObject, eventdata, handles) +% hObject handle to result (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +filePath=pwd; + +winopen(filePath); + + + +function name_Callback(hObject, eventdata, handles) +% hObject handle to name (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of name as text +% str2double(get(hObject,'String')) returns contents of name as a double +%输入名字 +name=handles.name.String; +setappdata(hObject,'name',name); + +% --- Executes during object creation, after setting all properties. +function name_CreateFcn(hObject, eventdata, handles) +% hObject handle to name (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +setappdata(hObject,'name','FigureFromTuTu'); +set(hObject,'Visible','off'); +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in YesOut. +function YesOut_Callback(hObject, eventdata, handles) +% hObject handle to YesOut (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of YesOut + +Yes=handles.YesOut.Value; + +if Yes==1 + set(handles.result,'Visible','on'); + set(handles.name,'Visible','on'); + set(handles.tips_name,'Visible','on'); + set(handles.NoOut,'Value',0); + % else + % set(handles.result,'Visible','off'); + % set(handles.name,'Visible','off'); + % set(handles.tips_name,'Visible','off'); +end + + +% --- Executes during object creation, after setting all properties. +function YesOut_CreateFcn(hObject, eventdata, handles) +% hObject handle to YesOut (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + + +% --- Executes on button press in isOut. +function isOut_Callback(hObject, eventdata, handles) +% hObject handle to isOut (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of isOut +if hObject.Value==1; + set(handles.name,'Visible','on'); + set(handles.tips_name,'Visible','on'); + set(handles.result,'Visible','on'); + setappdata(hObject,'isOut',1); + set(handles.remind,'String','图片将以指定名称被保存!'); + +else + set(handles.name,'Visible','off'); + set(handles.tips_name,'Visible','off'); + set(handles.result,'Visible','off'); + setappdata(hObject,'isOut',0); + set(handles.remind,'String','当前美化不/未保存!'); +end + + + +% --- Executes on button press in is3D. +function is3D_Callback(hObject, eventdata, handles) +% hObject handle to is3D (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hint: get(hObject,'Value') returns toggle state of is3D + +if hObject.Value==1 + setappdata(hObject,'is3D',3); + set(handles.remind,'String','用于控制三维视图的角度') +else + setappdata(hObject,'is3D',2); + set(handles.remind,'String','二维作图模式') +end + + +% --- Executes during object creation, after setting all properties. +function isOut_CreateFcn(hObject, eventdata, handles) +% hObject handle to isOut (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +setappdata(hObject,'isOut',0); +set(hObject,'Visible','on'); + + +% --- Executes during object creation, after setting all properties. +function is3D_CreateFcn(hObject, eventdata, handles) +% hObject handle to is3D (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +setappdata(hObject,'is3D',2); +set(hObject,'Visible','off'); + +% --- Executes during object creation, after setting all properties. +function result_CreateFcn(hObject, eventdata, handles) +% hObject handle to result (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function tips_name_CreateFcn(hObject, eventdata, handles) +% hObject handle to tips_name (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes on button press in test. +function test_Callback(hObject, eventdata, handles) +% hObject handle to test (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.remind,'String','正在生成一些用于测试效果的图片......'); +test; +set(handles.remind,'String','测试图片生成——>已完成'); +% --- Executes on button press in singlecolumn. +function singlecolumn_Callback(hObject, eventdata, handles) +% hObject handle to singlecolumn (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.remind,'String',{'正在设置双栏格式'}); + +iNumberVector=str2num(handles.iNumber.String); +for i=1:length(iNumberVector) + handleMyFigure=findall(groot,'Type','figure','Number',iNumberVector(i)) + handleMyFigure.Name='图图的绘图格式-双栏'; + handleMyFigure.Units='centimeters'; %改为厘米为单位 + %设置图片的大小,双栏选择[10, 10, 9, 6.75]cm,[相对位置 宽度高度] + handleMyFigure.Position=[10, 10, 9, 6.75]; + handleMyFigure.Resize='off'; + handleMyFigure.Color='w'; %将图形背景设置为白色 + %打印属性 和图片属性相仿 + handleMyFigure.PaperUnits='centimeters'; + handleMyFigure.PaperPosition=[10, 10, 9, 6.75]; + handleMyFigure.InvertHardcopy='off';%保存图像坐标背景色 +end +set(handles.remind,'String',{'双栏格式设置完成,图片已规范化!'}); + + +% --- Executes on button press in doublecolumn. +function doublecolumn_Callback(hObject, eventdata, handles) +% hObject handle to doublecolumn (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.remind,'String',{'正在设置单栏格式'}); +iNumberVector=str2num(handles.iNumber.String); +for i=1:length(iNumberVector) + handleMyFigure=findall(groot,'Type','figure','Number',iNumberVector(i)) + handleMyFigure.Name='图图的绘图格式-单栏'; + handleMyFigure.Units='centimeters'; %改为厘米为单位 + %设置图片的大小,单栏选择[10, 4, 19, 14.25]cm,[相对位置 宽度高度] + handleMyFigure.Position=[10, 4, 19, 14.25]; + handleMyFigure.Resize='off'; + handleMyFigure.Color='w'; %将图形背景设置为白色 + %打印属性 和图片属性相仿 + handleMyFigure.PaperUnits='centimeters'; + handleMyFigure.PaperPosition=[10, 4, 19, 14.25]; + handleMyFigure.InvertHardcopy='off';%保存图像坐标背景色 +end +set(handles.remind,'String',{'单栏格式设置完成,图片已规范化!'}); + + +% --- Executes on button press in expert. +function expert_Callback(hObject, eventdata, handles) +% hObject handle to expert (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +name=getappdata(handles.name,'name'); + +if ~strcmp(string(name),string('FigureFromTuTu')) + disp('正在导出'); + set(handles.remind,'String',{'正在导出,格式为高分辨率PNG'}); + iNumberVector=str2num(handles.iNumber.String); + for i=1:length(iNumberVector) + handleMyFigure=findall(groot,'Type','figure','Number',iNumberVector(i)); + myExportFigure(handleMyFigure,name); + end + disp('导出成功') + set(handles.remind,'String',{'已经成功导出,可以点击快速看图!'}); + set(handles.show,'Enable','on'); +else + disp('请先打开输出开关,并输入名字') + set(handles.remind,'String',{'请先打开输出开关,并输入图片名!'}); +end + + +% --- Executes on button press in show. +function show_Callback(hObject, eventdata, handles) +% hObject handle to show (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +filePath=pwd; +fid=fopen('name_append.txt','r'); +i=1; +while feof(fid)~=1 + nameMatrix{i}=fgetl(fid); + i=i+1; +end +fclose(fid); + +for i=1:length(nameMatrix) + name=nameMatrix{i}; + if ~isempty(name) + winopen([filePath,'\',name,'.png']); + else + disp('请先打开输出开关,并输入名字'); + set(handles.remind,'String','请先打开输出开关,并输入名字'); + end +end + + + +function remind_Callback(hObject, eventdata, handles) +% hObject handle to remind (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of remind as text +% str2double(get(hObject,'String')) returns contents of remind as a double + + +% --- Executes during object creation, after setting all properties. +function remind_CreateFcn(hObject, eventdata, handles) +% hObject handle to remind (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. + +set(hObject,'String','欢迎使用图图的软件'); + +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end +set(hObject,'Visible','on'); + + +% --- Executes on button press in addlegend. +function addlegend_Callback(hObject, eventdata, handles) +% hObject handle to addlegend (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.remind,'String','为某个figure添加图例'); +modifyLegendRecognize(fignum2handle(str2num(handles.iNumber.String))); +set(handles.remind,'String','添加图例完成'); + + +% --- Executes on button press in font. +function font_Callback(hObject, eventdata, handles) +% hObject handle to font (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +figNum=str2num(handles.iNumber.String); +%(figNum,fontSize,fontName,boldType,latexType) +prompt = {'输入字号(数字):','输入字体','输入是否加粗(bold/normal):','输入解释器(latex/none)'}; +dlgtitle = '字体相关参数设置'; +dims = [1 35]; +definput = {'12','Arial','bold','none'}; +answer = inputdlg(prompt,dlgtitle,dims,definput) +fontSize=str2num(answer{1}); +fontName=answer{2} ; +boldType=answer{3} ; +latexType=answer{4} ; +fontsizenamebold(figNum,fontSize,fontName,boldType,latexType); + + + +function XL_Callback(hObject, eventdata, handles) +% hObject handle to XL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of XL as text +% str2double(get(hObject,'String')) returns contents of XL as a double + + +% --- Executes during object creation, after setting all properties. +function XL_CreateFcn(hObject, eventdata, handles) +% hObject handle to XL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +set(hObject,'Visible','off'); +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in fill. +function fill_Callback(hObject, eventdata, handles) +% hObject handle to fill (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.remind,'String','此功能慎用~'); +axesfillfigure(str2num(handles.iNumber.String)); +shg; + + +% --- Executes on button press in label. +function label_Callback(hObject, eventdata, handles) +% hObject handle to label (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.XL,'Visible','on'); +set(handles.YL,'Visible','on'); +set(handles.ZL,'Visible','on'); +set(handles.TI,'Visible','on'); +set(handles.XB,'Visible','on'); +set(handles.YB,'Visible','on'); +set(handles.ZB,'Visible','on'); +set(handles.TB,'Visible','on'); +set(handles.addXYZT,'Visible','on'); +set(handles.pushbutton15,'Visible','on'); + + + +function YL_Callback(hObject, eventdata, handles) +% hObject handle to YL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of YL as text +% str2double(get(hObject,'String')) returns contents of YL as a double + + +% --- Executes during object creation, after setting all properties. +function YL_CreateFcn(hObject, eventdata, handles) +% hObject handle to YL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function ZL_Callback(hObject, eventdata, handles) +% hObject handle to ZL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of ZL as text +% str2double(get(hObject,'String')) returns contents of ZL as a double + + +% --- Executes during object creation, after setting all properties. +function ZL_CreateFcn(hObject, eventdata, handles) +% hObject handle to ZL (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function Ti_Callback(hObject, eventdata, handles) +% hObject handle to Ti (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of Ti as text +% str2double(get(hObject,'String')) returns contents of Ti as a double + + +% --- Executes during object creation, after setting all properties. +function Ti_CreateFcn(hObject, eventdata, handles) +% hObject handle to Ti (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. + +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in addXYZT. +function addXYZT_Callback(hObject, eventdata, handles) +% hObject handle to addXYZT (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.remind,'String','添加坐标轴文字中...!如果有子图,会提示您选择坐标轴'); +axess=findall(fignum2handle(str2num(handles.iNumber.String)),'Type','axes'); +if length(axess)>=2 + set(handles.remind,'String','因为有子图,所以你有5秒钟的时间单击你要选择的坐标轴!'); + pause(5); + myAxesHandle=gca; + if strcmp(myAxesHandle.Type,'axes') + set(handles.remind,'String','选择错误,请重试一次');pause(1); + set(handles.remind,'String','因为有子图,所以你有5秒钟的时间单击你要选择的坐标轴!'); + pause(5); + myAxesHandle=gca; + if myAxesHandle.Type~='axes' + set(handles.remind,'String','再次错误,请重新来');return + end + end +elseif length(axess)==1 + myAxesHandle=axess; +else + myAxesHandle=gca; +end + +myAxesHandle.XLabel.String=handles.XL.String; +myAxesHandle.YLabel.String=handles.YL.String; +myAxesHandle.ZLabel.String=handles.ZL.String; +myAxesHandle.Title.String=handles.TI.String; +%myAxesHandle.Ti.String=handles.Ti.String; + +set(handles.remind,'String','添加已完成!'); + + + + + + + + + +% --- Executes on button press in pushbutton15. +function pushbutton15_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton15 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.XL,'Visible','off'); +set(handles.YL,'Visible','off'); +set(handles.ZL,'Visible','off'); +set(handles.TI,'Visible','off'); +set(handles.XB,'Visible','off'); +set(handles.YB,'Visible','off'); +set(handles.ZB,'Visible','off'); +set(handles.TB,'Visible','off'); +set(handles.addXYZT,'Visible','off'); +set(hObject,'Visible','off'); + +% --- Executes during object creation, after setting all properties. +function addXYZT_CreateFcn(hObject, eventdata, handles) +% hObject handle to addXYZT (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + +myAxesHandle.XLabel.String='defaultX'; +myAxesHandle.YLabel.String='defaultY'; +myAxesHandle.ZLabel.String='defaultZ'; + + + +function TI_Callback(hObject, eventdata, handles) +% hObject handle to TI (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of TI as text +% str2double(get(hObject,'String')) returns contents of TI as a double + + +% --- Executes during object creation, after setting all properties. +function TI_CreateFcn(hObject, eventdata, handles) +% hObject handle to TI (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes during object creation, after setting all properties. +function label_CreateFcn(hObject, eventdata, handles) +% hObject handle to label (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +% set(handles.XL,'Visible','off'); +% set(handles.YL,'Visible','off'); +% set(handles.ZL,'Visible','off'); +% set(handles.TI,'Visible','off'); +% set(handles.XB,'Visible','off'); +% set(handles.YB,'Visible','off'); +% set(handles.ZB,'Visible','off'); +% set(handles.TB,'Visible','off'); +% set(handles.addXYZT,'Visible','off'); +% set(handles.pushbutton15,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function pushbutton15_CreateFcn(hObject, eventdata, handles) +% hObject handle to pushbutton15 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + +% --- Executes during object creation, after setting all properties. +function XB_CreateFcn(hObject, eventdata, handles) +set(hObject,'Visible','off'); +% hObject handle to XB (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + + +% --- Executes during object creation, after setting all properties. +function YB_CreateFcn(hObject, eventdata, handles) +% hObject handle to YB (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function ZB_CreateFcn(hObject, eventdata, handles) +% hObject handle to ZB (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function TB_CreateFcn(hObject, eventdata, handles) +% hObject handle to TB (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function show_CreateFcn(hObject, eventdata, handles) +% hObject handle to show (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Enable','off'); + + +% -------------------------------------------------------------------- +function ICON2_Callback(hObject, eventdata, handles) +% hObject handle to ICON2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +h=imshow('持续说明.png'); +f=h.Parent.Parent; +f.Name='关于软件的说明'; +f.Resize='off'; +f.Position=[100 100 400 400]; +f.NumberTitle='off'; +f.MenuBar='none' +shg; + + +% -------------------------------------------------------------------- +function ICON4_Callback(hObject, eventdata, handles) +% hObject handle to ICON4 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% if password()==1; +set(handles.uibuttongroup4,'Visible','on'); +set(handles.uibuttongroup5,'Visible','on'); +set(handles.isOut,'Visible','on'); +set(handles.test,'Visible','on'); +set(handles.remind,'Visible','on'); +set(handles.is3D,'Visible','on'); +set(handles.color,'Visible','on'); +set(handles.iDrawType,'Visible','on'); +% else +% set(handles.remind,'String','密码错误!'); +% myicon = imread('tutu.jpg'); +% h=msgbox('请关注微信公众号“tutongdao”图通道回复“FBPW”获取最新密码','密码错误','custom',myicon); +% end + + + + +% -------------------------------------------------------------------- +function ICON3_Callback(hObject, eventdata, handles) +% hObject handle to ICON3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +set(handles.uibuttongroup4,'Visible','off'); +set(handles.uibuttongroup5,'Visible','off'); +set(handles.isOut,'Visible','on'); +set(handles.test,'Visible','off'); +set(handles.remind,'Visible','on'); +set(handles.color,'Visible','off'); +set(handles.iDrawType,'Visible','off'); +set(handles.is3D,'Visible','off'); +set(handles.name,'Visible','off'); +set(handles.tips_name,'Visible','off'); +set(handles.result,'Visible','off'); + + + + + + +% --- Executes during object creation, after setting all properties. +function ICON3_CreateFcn(hObject, eventdata, handles) +% hObject handle to ICON3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + + +% -------------------------------------------------------------------- +function ICON4_ButtonDownFcn(hObject, eventdata, handles) +% hObject handle to ICON4 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +% --- Executes during object creation, after setting all properties. +function uibuttongroup4_CreateFcn(hObject, eventdata, handles) +% hObject handle to uibuttongroup4 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function uibuttongroup5_CreateFcn(hObject, eventdata, handles) +% hObject handle to uibuttongroup5 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes during object creation, after setting all properties. +function test_CreateFcn(hObject, eventdata, handles) +% hObject handle to test (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called +set(hObject,'Visible','off'); + + +% --- Executes on button press in pushbutton18. +function pushbutton18_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton18 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +% -------------------------------------------------------------------- +function closeall_Callback(hObject, eventdata, handles) +% hObject handle to closeall (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +close all;clc; diff --git a/fontsizenamebold.m b/fontsizenamebold.m new file mode 100644 index 0000000..4b0ca17 --- /dev/null +++ b/fontsizenamebold.m @@ -0,0 +1,53 @@ +function [fontSize,fontName,boldType,latexType]=... + fontsizenamebold(figNum,fontSize,fontName,boldType,latexType) +%% 设置全局的字体样式 +if nargin==1 + fontSize=12; + fontName='Arial'; + boldType='bold'; + latexType='none'; +elseif nargin==0 + warndlg('请输入函数参数'); + return +end + +figHandle=fignum2handle(figNum); +%%找出所有可能含有字的位置 +%先单独处理最麻烦的刻度线数字 +axesHandles=findall(figHandle,'Type','axes'); +for iaxesHandles=1:length(axesHandles) + set(axesHandles(iaxesHandles).XLabel,'FontName',fontName,'FontSize',... + fontSize-2,'FontWeight',boldType); + set(axesHandles(iaxesHandles).YLabel,'FontName',fontName,'FontSize',... + fontSize-2,'FontWeight',boldType); + set(axesHandles(iaxesHandles).ZLabel,'FontName',fontName,'FontSize',... + fontSize-2,'FontWeight',boldType); + set(axesHandles(iaxesHandles).Title,'FontName',fontName,'FontSize',... + fontSize-2,'FontWeight',boldType); + set(axesHandles,'FontName',fontName,'FontSize',... + fontSize-2,'FontWeight',boldType); +end + + + + +XYZTHandles=findall(figHandle,'Type','text'); +legendHandles=findall(figHandle,'Type','legend'); +textBoxHanldes=findall(figHandle,'Type','textbox'); +objfontNameHandles=[XYZTHandles;legendHandles;textBoxHanldes]; +%字体粗细和编译器全局统一 +for iobjfontNameHandles=1:length(objfontNameHandles) + objfontNameHandles(iobjfontNameHandles).FontName=fontName; + objfontNameHandles(iobjfontNameHandles).Interpreter=latexType; + objfontNameHandles(iobjfontNameHandles).FontWeight=boldType; +end + +for ilegendHandles=1:length(legendHandles) + legendHandles(ilegendHandles).FontSize=fontSize-2; +end +for itextBoxHanldes=1:length(textBoxHanldes) + XYZTHandles(itextBoxHanldes).FontSize=fontSize; +end +%坐标轴与图例字号比其他小2Pt +shg +end diff --git a/main.m b/main.m new file mode 100644 index 0000000..ed9d91c --- /dev/null +++ b/main.m @@ -0,0 +1,36 @@ +%% 用法说明 +% =========================需要关注的问题================================= +% 1)关注dimentionControl矩阵,非自动化输入参量,决定了当前axes是2(默认)/3维。 +% 2)调节三维图形的视角在Axes3DView函数中(目前只有单张图优化较好,因为图例在旋转) +% =============================输出====================================== +% isOUT==0决定了图片不输出,改为1就会输出(默认输出为myFigureNmae.png) +% 更改输出的格式在myExportFigure改,比如分辨率,png?jpg?,保存的名字等 +% ============================怎么用===================================== +% 在 controlAxes函数中输入“标题,坐标轴的标签”等 +% 调节”曲线线宽”在controlLine函数中 +% “图例”的大小在controlLegend中调节handleLegend.FontSize大小改变(MATLAB会自己调好位置) +% 单张图片已经最优,多张图片注意调节字体大小等参数,默认10Pt +% 已经存在的“图例”只会修改样式不会修改内容,可以保护内容 +% 已经存在的用Latex语言写的文本不会被覆盖,但是样式不受Matlab控制,受Latex语法控制 +% 已经完美支持的图类型:plot线图系列,bar,pie,histgram.... +% 处理哪幅图?? +%% 您想处理哪一幅图???? +iNumber=1;%图片左上角数字 +%% 定义全局变量,与controlAll()中同步更新 +global isOut; %是否输出图片 +global name; %输出图片名称 +global iColor; %选择ColorOrder色系 +global Dimention; %选择2/3维度绘图 +global idrawType %以何种风格绘图1,2,3... +%................................ %更新中 + +%% 主要选择参数 +isOut=1; %是否输出图片 +name='color22style2'; %输出图片名称 +iColor=42; %选择ColorOrder色系 +Dimention=2; %选择2/3维度绘图 +idrawType=2; %以何种风格绘图1,2,3... +........................... %更新中 + %% 开始正式处理 +controlAll(iNumber); +%function handleMyFigure=controlFigure(iNumber) \ No newline at end of file diff --git a/modifyLegend.m b/modifyLegend.m new file mode 100644 index 0000000..382a5a1 --- /dev/null +++ b/modifyLegend.m @@ -0,0 +1,36 @@ +function handleLegend=modifyLegend(iNumber,isVisible,myFontSize) +%% 在给定figure中修改一个图例的样式,且可以控制图例是否显示 +% iNumber是图片左上角的数字 +% 可以仅修改图例的一些信息;如果不存在,将自动*创建一个(可选) +% 在figure层面来修饰指定的图例 +% 只修改图例,而不修改其他值 +if nargin==0 + iNumber=get(gcf,'Number'); + isVisible='on'; + myFontSize=10; +elseif nargin==1 + isVisible='on'; + myFontSize=12; +elseif nargin==2 + myFontSize=12; +end +handleFigure=findobj('Type', 'figure','Number',iNumber); + +%% 返回需要操作的图例句柄,如果没有就是返回创建后的句柄。 +handleLegend=modifyLegendRecognize(handleFigure)%基于鼠标点击 + +%% 对Legend的详细操控 +% +%设置图例的排布方式 +%!!!!图例的位置相对于figure而不是相对于axes的!!!! +handleLegend.Location='northeast'; %图例方位 +handleLegend.Orientation='vertical'; %图例垂直排布 +handleLegend.NumColumns=1; %图例列数 +%handleLegend.Position(3)=0.1; %只改变图例宽度 +handleLegend.FontName='Arial'; +handleLegend.FontSize=myFontSize; +handleLegend.LineWidth=0.5; +handleLegend.Box='on'; +handleLegend.Visible=isVisible; +shg +end diff --git a/modifyLegendRecognize.m b/modifyLegendRecognize.m new file mode 100644 index 0000000..07060b0 --- /dev/null +++ b/modifyLegendRecognize.m @@ -0,0 +1,63 @@ +function handleLegend=modifyLegendRecognize(handleFigure) +% function handleLegend=modifyLegendRecognize(handleFigure) +% 输入图形句柄或者缺省 +% 似乎输入句柄和输入iNumber等价 +if nargin==0 + handleFigure=gcf; +end + +%% 获得指定图例的句柄 +% 获取Figure(句柄handleFigure)中的指定图例.. +% 利用鼠标 +handleMyAxes=findobj(get(handleFigure,'Children'),'flat','Type','axes'); +handleLegend=findobj(get(handleFigure,'Children'),'flat','Type','Legend'); +if isempty(handleMyAxes) + disp('没有axes') + return +elseif length(handleMyAxes)>1 + + msgbox('你有“5秒钟”时间单击目标坐标轴'); + pause(6) + if ~strcmp(get(gco,'Type'),'axes') + + msgbox('选择错误,请重新选择'); + return + end +end + + +handleMyAxes=gca; + +handleLegend=legend(handleMyAxes,'show'); + +if isempty(handleLegend) + handleLegend=legend(handleMyAxes,'show'); + disp('图中无legend,已创建'); +end +%% +% myProperty=input('请输入目标图例上文字,以一行多列元胞数组的形式{'',''}: '); +% handleLegend=findobj(get(handleFigure,'Children'),'flat','Type','Legend','String',myProperty); +% if length(handleLegend)~=1 +% disp('有重复Legend,程序无法自动识别,已退出,请人为修改图例,并保证唯一性') +% handleLegend=handleLegend(1); +% return; +% end +% elseif isempty(handleLegend) +% disp('图中无legend,需要创建'); +% +% if length(handleMyAxes)>1 +% ihandleMyAxes=input('请输入创建图例的坐标轴序号: '); +% else +% ihandleMyAxes=1; +% end +% if ihandleMyAxes>length(handleMyAxes) +% disp('没有这个坐标轴,退出程序') +% return +% end +% +% gca=handleMyAxes(ihandleMyAxes) +% handleLegend=legend(gca); +% end +%关闭所有对话框 +close(findall(0,'tag','Msgbox_ ')); +end \ No newline at end of file diff --git a/modifyXYZTLabel.m b/modifyXYZTLabel.m new file mode 100644 index 0000000..887063d --- /dev/null +++ b/modifyXYZTLabel.m @@ -0,0 +1,12 @@ +function handleMyAxes=modifyXYZTLabel(handleMyAxes,XYZT) +% 点击要修改的坐标区域,可以获得handleMyAxes=gco +% XYZT为单行元胞数组,分别决定了坐标标签和标题的"内容" +set(handleMyAxes.XLabel,'Interpreter','latex'); +set(handleMyAxes.YLabel,'Interpreter','latex'); +set(handleMyAxes.ZLabel,'Interpreter','latex'); +set(handleMyAxes.Title,'Interpreter','latex'); +handleMyAxes.XLabel.String=XYZT{1}; +handleMyAxes.YLabel.String=XYZT{2}; +handleMyAxes.ZLabel.String=XYZT{3}; +handleMyAxes.Title.String=XYZT{4}; +end \ No newline at end of file diff --git a/myExportFigure.m b/myExportFigure.m new file mode 100644 index 0000000..dceacd9 --- /dev/null +++ b/myExportFigure.m @@ -0,0 +1,34 @@ +function myExportFigure(handleMyFigure,name,format) +if nargin==1 + name='myFigureName'; + format='-dpng'; +elseif nargin==2 + format='-dpng'; +end +%% 输出高质量的图片 +% 将句柄为handleMyFigure的 +% 图形窗口figure以 +% myFigureNmae的名字保存,文件格式png; +% 可选格式 +% '-dpdf' 整页可移植文档格式 (PDF) 颜色 .pdf +% '-deps' PostScript (EPS) 3 级黑白 .eps +% '-depsc' 封装的 PostScript (EPS) 3 级彩色 .eps +% '-deps2' 封装的 PostScript (EPS) 2 级黑白 .eps +% '-depsc2' 封装的 PostScript (EPS) 2 级彩色 .eps +% '-dmeta' 增强的图元文件(仅限 Windows?).emf +% '-dsvg' SVG(可伸缩向量图) .svg +% '-dps' 全页 PostScript (PS) 3 级黑白 .ps +% '-dpsc' 全页 PostScript (PS) 3 级彩色 .ps +% '-dps2' 全页 PostScript (PS) 2 级黑白 .ps +% '-dpsc2' 全页 PostScript (PS) 2 级彩色 .ps +% 分辨率600dpi +% -painters 代表生成矢量图 opengl位图 +%% + +nameappend=strcat(name,num2str(fix(rand*rand*10000)),... + num2str(fix(rand*rand*10000))); +print(handleMyFigure,nameappend,'-r800',format,'-opengl'); +fid = fopen('name_append.txt','w+'); +fprintf(fid,'%s\n',nameappend); +fclose(fid); +end \ No newline at end of file diff --git a/test.m b/test.m new file mode 100644 index 0000000..90e0cf7 --- /dev/null +++ b/test.m @@ -0,0 +1,29 @@ +% test for GUI +close all;clc +Y = magic(4); +figure +plot(Y); +figure +y = [2 4 6; 3 4 5]; +b = bar(y); + +figure +b = bar3([2 4 64 64 6; 3 4 5 6 50;6 7 8 8 15]); + +figure +subplot(211) +Y = plot(magic(4)); +subplot(212) +bar(magic(4)); + +figure +subplot(221) +b = bar([2 4 6 5 6; 3 4 5 6 5;6 7 8 8 7]); +subplot(222) +pie([1 2 3 4]); +subplot(223) +plot([1 2 3 4;4 5 7 1]); +subplot(224) +b = bar([2 4 6 6 6; 3 4 5 6 5;6 7 8 8 1]); + + diff --git a/tutu.jpg b/tutu.jpg new file mode 100644 index 0000000..3e1db83 Binary files /dev/null and b/tutu.jpg differ diff --git "a/\346\214\201\347\273\255\350\257\264\346\230\216.png" "b/\346\214\201\347\273\255\350\257\264\346\230\216.png" new file mode 100644 index 0000000..dcadec4 Binary files /dev/null and "b/\346\214\201\347\273\255\350\257\264\346\230\216.png" differ