婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > matlab xlabel位置的設置方式

matlab xlabel位置的設置方式

熱門標簽:沈陽人工外呼系統價格 沈陽防封電銷卡品牌 武漢外呼系統平臺 池州外呼調研線路 外呼系統哪些好辦 江西省地圖標注 如何申請400電話費用 富錦商家地圖標注 沈陽外呼系統呼叫系統
xlabel(‘time',‘FontSize',12);

如果沒有設置位置,默認是在中間

在xlabel中也有position用法

xlabel(‘time',‘position',[900,1870],‘FontSize',12);

此時‘time'在你設置的位置

還有一種用法是類似圖像的用法

pos=axis;%取得當前坐標軸的范圍,即[xmin xmax ymin ymax]
xlabel(‘time',‘FontSize',12, ‘Position',[pos(2) pos(3)])

x=0:pi/50:2*pi;
y=sin(x);
plot(x,y);
pos=axis;%取得當前坐標軸的范圍,即[xmin xmax ymin ymax]
xlabel('x軸','position',[pos(2) 1.15*pos(3)]);%設置x軸標簽的文本在圖的右下方,1.15這個值根據自己的需要可以調整
形成的圖

補充:Matlab作圖實例——xlabel,ylabel,title,text,plot,patch,datetime等的應用

做線性圖,并用變量標記每個點

所用數據如下:

代碼如下:

clear
clc
format compact
format shortG 
T = readtable('repayment_schedule.xlsx','ReadVariableNames',true)
T.time=datetime(datestr(T.time,'yyyy.mm.dd'),'InputFormat','yyyy.MM.dd',...
    'format','yyyy.MM.dd')
p=plot(T.time,T.m_per_month,T.time,T.m_residue)
p(1).Marker='o'
p(2).Marker='*'
box off
%讓y軸不用科學計數法顯示
h=gca
y_val=h.YTick
y_str=string(y_val) %等價于y_str=num2str(y_val')
h.YTickLabel=y_str
%橫軸日期顯示設置
h.XTick=T.time
xtickangle(45) %讓x軸的標簽逆時針旋轉45度
%畫垂直虛線
hold on
p1=plot([datetime(2018,11,20) datetime(2018,11,20)],...
    [0 30830],'Color',[0.6 0.6 0.6],'LineStyle','--')
p2=plot([datetime(2018,12,20) datetime(2018,12,20)],...
    [0 26434],'Color',[0.6 0.6 0.6],'LineStyle','--')
p3=plot([datetime(2019,01,20) datetime(2019,01,20)],...
    [0 22038],'Color',[0.6 0.6 0.6],'LineStyle','--')
p4=plot([datetime(2019,02,20) datetime(2019,02,20)],...
    [0 17641],'Color',[0.6 0.6 0.6],'LineStyle','--')
p5=plot([datetime(2019,03,20) datetime(2019,03,20)],...
    [0 13245],'Color',[0.6 0.6 0.6],'LineStyle','--')
p6=plot([datetime(2019,04,20) datetime(2019,04,20)],...
    [0 8849],'Color',[0.6 0.6 0.6],'LineStyle','--')
p7=plot([datetime(2019,05,20) datetime(2019,05,20)],...
    [0 4452.8],'Color',[0.6 0.6 0.6],'LineStyle','--')
hold off
%標注每個點
str1=string(T.m_per_month)
str2=string(T.m_residue)
text(T.time,T.m_per_month-1200,str1,'Color',[0 0.447 0.741],...
    'HorizontalAlignment','center')
text(datetime(datenum(T.time)+2,'ConvertFrom','datenum'),...
    T.m_residue+1100,str2,...
    'Color',[0.85 0.325 0.098],...
    'HorizontalAlignment','left')
%圖例
legend([p(1) p(2)],{'每月還款金額','每月還款后剩余總本息'},...
    'Location','northeast','NumColumns',1)
%各個標題
xlabel('還款時間')
ylabel('還款金額')
title({'GGG還款計劃';'2018.12.20-2019.06.20'})
print('GGG還款計劃','-dpdf')
%將數據再寫入excel
% writetable(T,'test.xlsx','WriteVariableNames',true)

做出的圖如下:

畫線形函數圖,填充一部分并畫網格

相應代碼為:

%填充并畫網格
clear
clc
v1 = [0 0; 4 0; 4 4;0 4];
f1 = [1 2 3 4];
figure
patch('Faces',f1,'Vertices',v1,...
    'EdgeColor',[0.75 0.75 0.75],'FaceColor',[0.75 0.75 0.75]);
g=gca
g.XTick=[0:4]
g.YTick=[0:4]
g.XLim=[0 4.5]
g.YLim=[0 4.5]
grid on
g.Layer = 'top';
g.GridColor=[1 1 1]
g.GridLineStyle='--'
g.GridAlpha = 1
axis square
%挖洞
v2 = [1 1;2 1;2 2;1 2];
f2 = [1 2 3 4];
patch('Faces',f2,'Vertices',v2,...
    'EdgeColor',[0.75 0.75 0.75],'FaceColor',[1 1 1]);
%畫函數圖
hold on
f1=@(t) 4*t-4
f2=@(t) 0.25*t+1
f1p=fplot(f1,[1 2],'k','LineWidth',1,'DisplayName','X的策略')
f2p=fplot(f2,[0 4],'--k','LineWidth',1,'DisplayName','Y的策略')
xlabel('X的策略')
ylabel('Y的策略')
legend([f1p f2p],{},'NumColumns',2,'FontSize',10)
%導出為PDF
% saveas(gcf,'qiyan.pdf')
print('qiyan','-dpdf')

做出的圖如下

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • matplotlib之pyplot模塊坐標軸標簽設置使用(xlabel()、ylabel())
  • python 設置xlabel,ylabel 坐標軸字體大小,字體類型
  • Matlab中plot基本用法的具體使用

標簽:呂梁 阿里 常德 黑龍江 銅川 通遼 潛江 株洲

巨人網絡通訊聲明:本文標題《matlab xlabel位置的設置方式》,本文關鍵詞  matlab,xlabel,位置,的,設置,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《matlab xlabel位置的設置方式》相關的同類信息!
  • 本頁收集關于matlab xlabel位置的設置方式的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 夏邑县| 宿松县| 太湖县| 北票市| 扶沟县| 新郑市| 昌乐县| 华蓥市| 乌兰察布市| 阜新市| 新巴尔虎右旗| 玛曲县| 香河县| 临沧市| 保定市| 通江县| 禹州市| 哈巴河县| 库尔勒市| 东山县| 湖北省| 霍城县| 武川县| 武夷山市| 章丘市| 民勤县| 茶陵县| 读书| 唐海县| 延津县| 广灵县| 三穗县| 香河县| 大方县| 进贤县| 云霄县| 老河口市| 蕉岭县| 响水县| 盐亭县| 区。|