加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

matlab坐标轴标注和特殊字体

(2011-09-22 16:52:53)
标签:

matlab

坐标轴

特殊字符

设置

杂谈

分类: 学习资料收藏

set(gca,'XTick',[0:pi/3:2*pi]) 设置所要显示坐标轴刻度,
set(gca,'XTickLabel',[0:pi/3:2*pi]) 给这些数据加标签

gca是单词Get current axes handle的缩写,获得坐标轴句柄。(不知道matlab为什么不自动对应数据加标签,还需要多一条命令)出来的图形

 

坐标轴标注:

1. 控制坐标轴尺度长度:set(gca,'XLim',[-pi/2 pi])

2. 定制自己想标注的刻度:

(1)set(gca,'XTick',[-pi/2:pi/4:pi]) %%%坐标轴最小值,步长,最大值

(2)set(gca,'XTickLabel',{'-pi/2' '-pi/4:' '0' 'pi/4' 'pi/2' 'pi*3/4' 'pi'})

3. 反转坐标轴:set(gca,'XDir','reverse')

4. 上下标及latex公式

输下标:_{wb}

输上标:^{0.5}

输latex公式:

text('Interpreter','latex',...

'String','$$\int_0^x\!\int_y dF(u,v)$$',...

'Position',[.5 .5],...

'FontSize',16)

在Matlab中输入上标、下标、特殊符号或字体:

bf,\it,\rm表示黑体,斜体,正体字符

上标用 ^(指数),下标用 _(下划线)

调用方式为: ^{任意字符}, _{任意字符}, 注意{}的使用!

希腊字母等特殊字符用 \加拼音如:

α \alpha β \beta γ \gamma θ \theta Θ \Theta

Г \Gamma δ \delta Δ \Delta ξ \xi Ξ \Xi Ω \Ommiga

η \elta ε \epsilong ζ \zeta μ \miu υ \nu τ \tau

λ \lamda Λ \Lamda π \pi Π \Pi σ \sigma Σ \Sigma

φ \phi Φ \Phi ψ \psi Ψ \Psi χ \chi ω \ommiga

< \leq > \geq 不等于 \neq << \ll >> \gg

正负 \pm 左箭头 \leftarrow 右箭头 \rightarrow 上箭头 \uparrow

体会以下两例:

figure, title('\zeta^{-t}sint');

figure, title('x~{\chi}_{\alpha}^{2}(3)');

 

source: http://www.zdh1909.com/html/matlab/14642_2.html

范围设置:
 a. axis([xmin xmax ymin ymax])设置坐标轴在指定的区间
 b. axis auto 将当前绘图区的坐标轴范围设置为MATLAB自动调整的区间
 c. axis manual 冻结当前坐标轴范围,以后叠加绘图都在当前坐标轴范围内显示
 d. axis tight 采用紧密模式设置当前坐标轴范围,即一用户数据范围为坐标轴范围
 比例:
 a. axis equal 等比例坐标轴
 b. axis square 以当前坐标轴范围为基础,将坐标轴区域调整为方格形
 c. axis normal 自动调整纵横轴比例,使当前坐标轴范围内的图形显示达到最佳效果
 范围选项和比例设置可以联合使用,默认的设置为axis auto normal
 
4.坐标轴刻度设置
 set(gca, ’XTick’, [0 1 2]) X坐标轴刻度数据点位置
 set(gca,'XTickLabel',{'a','b','c'}) X坐标轴刻度处显示的字符
 set(gca,'FontName','Times New Roman','FontSize',14)设置坐标轴刻度字体名称,大小
 ‘FontWeight’,’bold’ 加粗 ‘FontAngle’,’italic’ 斜体
 对字体的设置也可以用在title, xlabel, ylabel等中
 
5.图例
 legend('a','Location','best') 图例位置放在最佳位置
 
6.更多的设置可以在绘图窗口中打开绘图工具,Inspector… 中查找
 
Various line types, plot symbols and colors may be obtained with
 PLOT(X,Y,S) where S is a character string made from one element
 from any or all the following 3 columns:
 
             blue          point                 solid
              green          circle             dotted
              red              x-mark          -. dashdot
              cyan          plus             -- dashed
              magenta       star          (none)   no line
              yellow           square
              black          diamond
              white          triangle (down)
                               triangle (up)
                               triangle (left)
                               triangle (right)
                               pentagram
                               hexagram
 
 在使用Matlab时,经常需要将得到的数值表达成二维或三维图像。
 
plot(vector1,vector2)可以用来画两个矢量的二维图,例如
 
x=1:0.1:2*pi;
 
plot(x,sin(x))可以画正弦函数在0-2pi的上的图像。
 
plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。下面是一些属性的说明
               blue(蓝色)          point(点)          solid(实线)
               green(绿色)         circle(圆圈)       dotted(点线)
               red(红色)           x-mark(叉号)    -.    dashdot (点画线)
               cyan(墨绿色)        plus(加号)       --    dashed(虚线)
               magenta(紫红色) *     star(星号)      (none) no line
               yellow(黄色)        square(正方形)
               black(黑色)         diamond(菱形)
                                   triangle (down)
                                   triangle (up)
                                   triangle (left)
                                   triangle (right)
                                   pentagram
                                   hexagram
 例如,plot(x,y,'.r')表示用点来画图,点的颜色是红色。

plot函数可以接一些参数,来改变所画图像的属性(颜色,图像元素等)。下面是一些属性的说明
 
              blue(蓝色)          point(点)          solid(实线)
 
              green(绿色)         circle(圆圈)       dotted(点线)
 
              red(红色)           x-mark(叉号)    -.    dashdot (点画线)
 
              cyan(墨绿色)        plus(加号)       --    dashed(虚线)
 
              magenta(紫红色) *     star(星号)      (none) no line
 
              yellow(黄色)        square(正方形)
 
              black(黑色)         diamond(菱形)
 
                                  triangle (down)
 
                                  triangle (up)
 
                                  triangle (left)
 
                                  triangle (right)
 
                                  pentagram
 
                                  hexagram
 
 
 
    Example
 
       x = -pi:pi/10:pi;
 
       y = tan(sin(x)) - sin(tan(x));
 
       plot(x,y,'--rs','LineWidth',2,...
 
                       'MarkerEdgeColor','k',...
 
                       'MarkerFaceColor','g',...
 
                       'MarkerSize',10)
 
           xlabel('x');
 
           ylabel('y');
 
·         用Matlab画图时,有时候需要对各种图标进行标注,例如,用“+”代表A的运动情况,“*”代表B的运动情况。

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有