How can I replace the three YLABEL (degree of membership) to only one?

1 次查看(过去 30 天)
Dear Mathcoders,
I am digging into this issue, I just want to:
  1. remove the three independent YLABELs (degree of membership)
  2. then, re-write only one "degree of membership" that covers the three inputs
  3. reduce the space among the three of them horizontally
Thank you in advance

采纳的回答

Johannes Hougaard
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 个评论
Johannes Hougaard
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,

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by