• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

matlab 画图技巧

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

**Matlab中的坐标轴设置技巧**
  
axisoff;      %去掉坐标轴 
axistight;     %紧坐标轴 
axisequal;     %等比坐标轴 
axis([-0.1, 8.1, -1.1, 1.1]);   % 坐标轴的显示范围 
x = -pi/2:0.01:pi;  
plot(x,sin(x))            % 先绘制个基本图形 
% gca: gca, h=figure(...); 
set(gca, \'XLim\',[-pi/2pi]);     % X轴的数据显示范围 
set(gca,\'XTick\',[-pi/2:pi/4:pi]);   % X轴的记号点  
set(gca,\'XTickLabel\',{\'-pi/2\' \'-pi/4:\' \'0\' \'pi/4\' \'pi/2\' \'pi*3/4\'\'pi\'})   % X轴的记号 
set(gca,\'XGrid\',\'on\');                                        % X轴的网格 
set(gca,\'XDir\',\'reverse\');                                        % 逆转X轴 
set(gca,\'XColor\',\'red\');                                        % X轴的颜色 
set(gac,\'Xscale\',\'log\')                                              % x轴以log 形式显示 xlim(min,max)  
 
matlab画图设置图片大小以及线宽和字号命令,该文章讲述了matlab画图设置图片大小以及线宽和字号命令. 
set(gcf,\'Units\',\'centimeters\',\'Position\',[1010 7 5]);     %设置图片大小为7cm×5cm 
%get hanlde to current axis返回当前图形的当前坐标轴的句柄, 
%(the first element is the relative distance of the axes to the left edge ofthe figure,... 
%the second the vertical distance from the bottom, and then the width andheight; 
set(gca,\'Position\',[.13 .17 .80 .74]);        %设置xy轴在图片中占的比例 
set(get(gca,\'XLabel\'),\'FontSize\',8);             %图上文字为8 point或小5号 
set(get(gca,\'YLabel\'),\'FontSize\',8);            
set(get(gca,\'TITLE\'),\'FontSize\',8); 
set(gca,\'fontsize\',8); 
set(gca,\'linewidth\',0.5); %坐标线粗0.5磅 
set(gca,\'box\',\'off\');%Controls the box around the plotting area 
set(get(gca,\'Children\'),\'linewidth\',1.5);%设置图中线宽1.5磅 

  • 设计图

  • 代码


%%  普通的实现
%clear all;
% x=[8,16,32,64,128,256,512,1024,4096];
% y=[0.525,0.725,0.855,0.93,0.938,0.92,0.91,0.90,0.88];
% plot(x,y);
% xlabel(\'the number of reduced dimension\')
% ylabel(\'mean average precision\')
% axis([0 4100 0.5 1])
% %set(gca,\'xticklabel\',{\'8\',\'16\',\'32\',\'64\',\'128\',\'256\',\'512\',\'1024\',\'4096\'})

%% 技巧改进
clear all;
close all
x1={\'8\',\'16\',\'32\',\'64\',\'128\',\'256\',\'512\',\'1024\',\'2048\',\'4096\'};
x=1:10;
y=[0.525,0.725,0.855,0.93,0.938,0.92,0.91,0.90,0.89,0.88];
figure
set(gcf,\'color\',\'w\')
plot(x,y,\'r.-\',\'linewidth\',2);
set(gca,\'xticklabel\',x1)
xlabel(\'the number of reduced dimension\')
ylabel(\'mean average precision\')
axis([0.5 10.5 0.5 1]) %左右留点余地
%设置网格线的线型,使用gridlinestyle属性,默认为虚线,可以改为实线
%axes(\'GridLineStyle\', \'-\')
grid on
set(gca, \'GridLineStyle\' ,\'-\')

set(gca,\'xtick\',[1,2,3,4,5,6,7,8,10]);
%set(gca,\'XGrid\',\'on\');
%set(gca,\'XTickMode\',\'manual\',\'XTick\',[1,4,8,128,512,4096])
hold on
plot(x,y,\'b.\',\'markersize\',20);
debug=1;

%saveas(gcf, \'E:\myfigure\', \'eps\') %保存为矢量图

%% 设计思路
% figure;
% clc;
% clear all;
% x = [1,5,13,30,48,77,100,142];  
% ind=1:length(x);  
% y1 =[1.3,2.1,3.6,4.7,7.8,8.0,8.3,8.1];  
% y2 =[0.9,1.8,5.6,6.4,8.5,9.8,9.3,9.9];  
%   
% plot(ind,y1,\'s-\',ind,y2,\'s-\');  
% set(gca,\'XTick\',ind);  
% set(gca,\'XTickLabel\',{\'1\',\'5\',\'13\',\'30\',\'48\',\'77\',\'\',\'142\'});  

%)坐标轴的标尺属性:\'Xtick\',\'Ytick\',\'Ztick\'
%------ 标度的位置,值为向量\'Xticklabel\',\'Yticklabel\',\'Zticklabel\'
%------ 轴上标度的符号,它的值为与标度位置向量同样大
%用\'xtick\'属性设置x轴 刻度的位置
%用\'xticklabel\'来指定刻度的值,


  • 结果

  • 还有几个细节没有解决

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Tokio,Rust异步编程实践之路发布时间:2022-07-18
下一篇:
堆排序 Rust实现发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap