matlab 中如何把x轴坐标值设置成斜体?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab 中如何把x轴坐标值设置成斜体?相关的知识,希望对你有一定的参考价值。

matlab中设置x轴坐标值为斜体的方法为:将坐标轴刻度的 Fontangle 属性设置为 italic,关键代码为:>> set(gca,'Fontangle','italic'),效果如下图所示:


此外,如果要设置x轴标题为斜体,可以使用Latex语法 \\it 设置:

>> xlabel('\\it your-x-title')

参考技术A 已测试可以使用
示例:
x = round(rand(5,3)*10);
h=bar(x,1,'group');
set(gca,'xticklabels','benchmark1','benchmark2','benchmark3','benchmark4','benchmark5');
h = gca;
th=rotateticklabel(h, 45);%调用下面的函数,坐标倾斜45度

function th=rotateticklabel(h,rot,demo)
%ROTATETICKLABEL rotates tick labels
% TH=ROTATETICKLABEL(H,ROT) ris the calling form where H is a handle to
% the axis that contains the XTickLabels that are to be rotated. ROT is
% an optional parameter that specifies the angle of rotation. The default
% angle is 90. TH is a handle to the text objects created. For long
% strings such as those produced by datetick, you may have to adjust the
% position of the axes so the labels don't get cut off.
%
% Of course, GCA can be substituted for H if desired.
%
% TH=ROTATETICKLABEL([],[],'demo') shows a demo figure.
%
% Known deficiencies: if tick labels are raised to a power, the power
% will be lost after rotation.
%
% See also datetick.
% Written Oct 14, 2005 by Andy Bliss
% Copyright 2005 by Andy Bliss
%DEMO:
if nargin==3
x=[now-.7 now-.3 now];
y=[20 35 15];
figure
plot(x,y,'.-')
datetick('x',0,'keepticks')
h=gca;
set(h,'position',[0.13 0.35 0.775 0.55])
rot=90;
end
%set the default rotation if user doesn't specify
if nargin==1
rot=90;
end
%make sure the rotation is in the range
% 0:360 (brute force method)
% while rot>360
% rot=rot-360;
% end
% while rot<0
% rot=rot+360;
% end
%get current tick labels
a=get(h,'XTickLabel');
%erase current tick labels from figure
set(h,'XTickLabel',[]);
%get tick label positions
b=get(h,'XTick');
c=get(h,'YTick');
%make new tick labels
if rot<180
th=text(b,repmat(c(1)-.1*(c(2)-c(1)),length(b),1),a,'HorizontalAlignment','right','fontsize',14,'fontweight','bold','rotation',rot);
else
th=text(b,repmat(c(1)-.1*(c(2)-c(1)),length(b),1),a,'HorizontalAlignment','left','fontsize',14,'fontweight','bold','rotation',rot);
end
参考技术B 引号内直接写成斜体呀
  xlabel('text')
参考技术C >> ezplot('sin(x)')
>> set(gca,'Fontangle','italic')

matlab像素坐标值转换为经纬度

我在matlab中读取了一幅tif格式的遥感图像,然后在matlab中成图,最后成图的坐标轴标的是像素值,x轴是从左向右进行等间隔,y轴则是从上而下进行等间隔划分的,也即是值上面小,下面大。我现在想将坐标轴转换为经纬度坐标轴,我该怎么做?谢谢大家!

参考技术A 像素转化为经纬度不难吧
线性方程组比如开始的1像素代表50度,101像素代表100度y=ax+b
50=a+b
100=101a+b
求得a,b,像素和经纬度的转换关系就可以得到。

接下来是自定义坐标轴的问题,可以这么用
例如:
set(gca,'xtick',[1,3,6,8])%设置在1,3,6,8处出现坐标点,这里改成像素
%不知道行不行
set(gca,'xticklabel','10','20','30','40')%设置在上述坐标点出现得标
%号,当然也可以是倒序,从大到小,y轴类似,xtick->ytick本回答被提问者采纳

以上是关于matlab 中如何把x轴坐标值设置成斜体?的主要内容,如果未能解决你的问题,请参考以下文章

GUI坐标值范围设置

将几何画板x轴坐标值换成弧度制的方法

matlab如何标注出点的坐标值

求助大神,怎么去掉echarts中y轴,但是保留y轴坐标值和网格线

在matlab中怎么输入特殊符号

matlab像素坐标值转换为经纬度