How can I replace the three YLABEL (degree of membership) to only one?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Dear Mathcoders,
I am digging into this issue, I just want to:
- remove the three independent YLABELs (degree of membership)
- then, re-write only one "degree of membership" that covers the three inputs
- reduce the space among the three of them horizontally
Thank you in advance
採用された回答
I would think that you could just skip your ylabel and use an annotation textbox in stead
Moving your axes up and down is managed in the .Position(2) of your individual axes.
Does this work for you?
fh = figure;
ah(1) = subplot(3,1,1);
plot(linspace(-8*pi,pi*8,318),sin(linspace(-8*pi,pi*8,318)));
xlabel("Sine wave")
ah(2) = subplot(3,1,2);
plot(linspace(-8*pi,pi*8,318),cos(linspace(-8*pi,pi*8,318)));
xlabel("Cosine wave")
ah(3) = subplot(3,1,3);
plot(linspace(-8*pi,pi*8,318),cos(linspace(-16*pi,pi*16,318)));
hold on;
plot(linspace(-8*pi,pi*8,318),cos(linspace(-15*pi,pi*16,318)));
plot(linspace(-8*pi,pi*8,318),cos(linspace(-14*pi,pi*16,318)));
plot(linspace(-8*pi,pi*8,318),cos(linspace(-13*pi,pi*16,318)));
plot(linspace(-8*pi,pi*8,318),cos(linspace(-12*pi,pi*16,318)));
xlabel("Waves")
str = "This is a string"; % Define your ylabel
tb = annotation(fh,"textbox","position",[ah(1).Position(1)*0.8 0.18 0.5 0.3],...
"EdgeColor",'none',"String",str,"Rotation",90,"FitBoxToText",'on','FontSize',18);
ah(1).Position(2) = ah(1).Position(2) - 0.03; % Move the top axis down a bit
ah(2).Position(2) = ah(2).Position(2) - 0.02; % Move the mid axis down a smaller bit
ah(3).Position(2) = ah(3).Position(2) - 0.01; % Move the bottom axis down a smaller bit still

8 件のコメント
Firstly, thank you for your help, but I receive an error message when applying your code. I apologize if I did not clarify that these figures come from an APP in MATLAB named Fuzzy Logic designer, I am trying to remove the ylabel self-created three-axis name for just one that as your plot covers the three of them.
clear all
clc
fh=figure;
fis=readfis('ABM_FL_MoM_Def.fis');
ah(1)=subplot(3,1,1);
plotmf(fis,'input',1)
ah(2)=subplot(3,1,2);
plotmf(fis,'input',2)
ah(3)=subplot(3,1,3);
plotmf(fis,'input',3)
hold on
str = "This is a string"; % Define your ylabel
tb = annotation(fh,"textbox","position",[ah(1).Position(1)*0.8 0.18 0.5 0.3],...
"EdgeColor",'none',"String",str,"Rotation",90,"FitBoxToText",'on','FontSize',18);
ah(1).Position(2) = ah(1).Position(2) - 0.03; % Move the top axis down a bit
ah(2).Position(2) = ah(2).Position(2) - 0.02; % Move the mid axis down a smaller bit
ah(3).Position(2) = ah(3).Position(2) - 0.01; % Move the bottom axis down a smaller bit still
Error using matlab.graphics.shape.TextBox
Unrecognized property Rotation for class TextBox.
Error in annotation (line 143)
h = matlab.graphics.shape.TextBox(aargs{:});
Error in PlotMembership (line 19)
tb = annotation(fh,"textbox","position",[ah(1).Position(1)*0.8 0.18 0.5 0.3],...
I have been able to delete the former ylabel self-created three-axis name by using
set(gca, 'Ylabel',[])
Nonetheless, the error message continuos
Error using matlab.graphics.shape.TextBox
Unrecognized property Rotation for class TextBox.
Error in annotation (line 143)
h = matlab.graphics.shape.TextBox(aargs{:});
Error in PlotMembership (line 22)
tb = annotation(fh,"textbox","position",[ah(1).Position(1)*0.8 0.18 0.5 0.3],...
What version of MATLAB are you running? As seen above the code is running in 2022a
Sorry, it is 2021a
Ah yeah...then I can replicate the error.
But unfortunately I can't fix it without updating to 2022a
I think you misuderstood what I wrote before. my version is 2021a, actually
Yeah, I got that - and when I ran the code in 2021a I could replicate the error you posted, but not in 2022a.
Apparently the 'rotation' property of a textbox annotation is a feature that has been introduced some time between the 2021a release and the 2022a release - and I couldn't find another way to rotate the textbox which would work in 2021a.
Maybe you could use 'text' in stead of annotation, but that takes an axes not a figure as its parent which may make the positioning impossible,
Ok, thanks!...
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Subplots についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
