Matlab怎么绘制酷炫坐标区域

发布时间:2022-05-20 09:05:50 作者:iii
来源:亿速云 阅读:124

这篇文章主要介绍“Matlab怎么绘制酷炫坐标区域”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Matlab怎么绘制酷炫坐标区域”文章能帮助大家解决问题。

使用方式

首先说明一下函数咋用:假设编写了如下函数:

t=0:0.35:3*pi;
plot(t,sin(t),'Marker','d','LineWidth',2,'Color',[102,194,166]./255)
hold on
plot(t,cos(t./2),'Marker','o','LineWidth',2,'Color',[252,140,97]./255)
plot(t,t,'Marker','^','LineWidth',2,'Color',[140,161,204]./255)

Matlab怎么绘制酷炫坐标区域

在最后一行调用工具函数进行修饰,例如:

prettyAxes().ggray2()

或者:

prettyAxes(gca).ggray2()

修饰效果:

Matlab怎么绘制酷炫坐标区域

其他炫酷的背景

prettyAxes().dark()

Matlab怎么绘制酷炫坐标区域

prettyAxes().dark2()

Matlab怎么绘制酷炫坐标区域

prettyAxes().economist()

Matlab怎么绘制酷炫坐标区域

prettyAxes().gbase()

Matlab怎么绘制酷炫坐标区域

prettyAxes().gbase2()

Matlab怎么绘制酷炫坐标区域

prettyAxes().ggray()

Matlab怎么绘制酷炫坐标区域

prettyAxes().ggray2()

Matlab怎么绘制酷炫坐标区域

prettyAxes().wsj()

Matlab怎么绘制酷炫坐标区域

目前只有这些主题,之后可能会更新.mat文件,请使用如下命令获取可用主题列表:

prettyAxes().theme()

该命令会返回可用主题的函数名:

dark  dark2  economist  gbase  gbase2  ggray  ggray2  wsj  

注意事项

对于dark,dark2,economist,wsj这几种风格,其背景色并不是白色,一般情况下保存图片图窗的背景会是默认白色,即下图这样:

Matlab怎么绘制酷炫坐标区域

想要连figure窗口的背景颜色一起保存需要设置figure窗口的InvertHardcopy属性为'off',本函数已经设置好了这个属性,因此直接点击如下按钮保存即可:

Matlab怎么绘制酷炫坐标区域

另外当文件解压完成后后,将当前文件夹添加到搜索路径可以在任意文件夹使用该工具函数:

Matlab怎么绘制酷炫坐标区域

代码展示及mat文件获取

完整代码其实没啥东西,但还是展示一下吧,大部分信息都存储在.mat文件,完整代码及.mat文件请公众号后台回复关键词:PAX

完整代码展示:

function PAX=prettyAxes(ax) 
% @author:slandarer
% ==================================
% 展示所有可选axes主题 
% prettyAxes().theme()
% ----------------------------------
% prettyAxes(ax).dark()
% prettyAxes().ggray()

if nargin<1
    ax=[];
end

% 从mat文件中读取函数集合
axesTheme=load('axesTheme.mat');
axesTheme=axesTheme.theme;
% 结构体函数构造
for L=1:length(axesTheme.List)
    PAX.(axesTheme.List{L})=@()setAxesTheme(ax,axesTheme,axesTheme.List{L});
end
PAX.theme=@()showAxesTheme(axesTheme);
% =========================================================================
    % 坐标区域修饰基础函数
    function setAxesTheme(tAxes,axesTheme,Name)
        ax=tAxes;
        if isempty(ax)
            ax=gca;
        end
        % 读取函数信息
        sli=0;slii=0;
        tBaseStr=axesTheme.(Name);
        tBaseFunc=axesTheme.([Name,'_F']);
        eval([tBaseStr{:}])

        if ~isempty(tBaseFunc)
            % 设置鼠标移动回调
            set(ax.Parent,'WindowButtonMotionFcn',@bt_move_axes);
        end
        
        % 鼠标移动回调函数
        function bt_move_axes(~,~)
            eval([tBaseFunc{:}])
        end
    end
% -------------------------------------------------------------------------
    % 输出可用风格列表函数
    function showAxesTheme(axesTheme)
        for i=1:length(axesTheme.List)
            fprintf('%s  ',axesTheme.List{i})
        end
        fprintf('\r\n');
    end
end

关于“Matlab怎么绘制酷炫坐标区域”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注亿速云行业资讯频道,小编每天都会为大家更新不同的知识点。

推荐阅读:
  1. 几个炫酷的IDEA插件
  2. Python 绘制酷炫的三维图步骤详解

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

matlab

上一篇:Python中静态方法,类方法,属性方法怎么使用

下一篇:ASP.NET Core怎么获取正确查询字符串参数

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》