Unable to change the height of the barh.

2 ビュー (過去 30 日間)
Aksh Chordia
Aksh Chordia 2023 年 7 月 27 日
コメント済み: Star Strider 2023 年 7 月 27 日
I have a tiled layout wherein, of the tiles is like this.
The code looks like this:
y=[67 147-67 1073-147 3456-1073 5000-3456];
def=[1];
nexttile
d1=barh(def,y,3,'stacked');
axis ([0 5000 0 2]);
xlabel('Defect Size [Ohm]');
title('Defect 1 @ 100C');
set(gca,'ytick',[],'FontSize',30);
I am trying to reduce the height of the figure, but the position 'Position' is not working. Could you suggest any other way to do it.
Thank you
Aksh

採用された回答

Star Strider
Star Strider 2023 年 7 月 27 日
The tiledlayout plots will not let you do that, however subplot will.
Try this —
figure
y=[67 147-67 1073-147 3456-1073 5000-3456];
def=[1];
subplot(1,1,1)
d1=barh(def,y,3,'stacked');
axis ([0 5000 0 2]);
xlabel('Defect Size [Ohm]');
title('Defect 1 @ 100C');
set(gca,'ytick',[],'FontSize',30);
figure
y=[67 147-67 1073-147 3456-1073 5000-3456];
def=[1];
subplot(1,1,1)
d1=barh(def,y,3,'stacked');
axis ([0 5000 0 2]);
xlabel('Defect Size [Ohm]');
title('Defect 1 @ 100C');
set(gca,'ytick',[],'FontSize',30);
pos = get(gca, 'Position');
set(gca,'Position',pos.*[1 1.25 1 0.25])
Experiment to get the result you want.
.
  2 件のコメント
Aksh Chordia
Aksh Chordia 2023 年 7 月 27 日
Thank you very much.
I was using subplot previously and then switched to the tiled layout because the former does not give an option for a global legend.
Is there some workaround? Can I still use tiled layout, because its legending is much simpler and elegant.
Star Strider
Star Strider 2023 年 7 月 27 日
You can use global legends with subplot similarly to the way you would create it in tiledlayout.
Try something like this —
x = 0:0.5:10;
y1 = randn(size(x,2),2);
y2 = randn(size(x,2),2);
y3 = randn(size(x,2),2);
figure
subplot(2,2,1)
plot(x,y1)
grid
hl = legend('y_1','y_2'); % Create Legend, Return Handle
subplot(2,2,2)
plot(x,y2)
grid
subplot(2,2,3)
plot(x,y3)
grid
subplot(2,2,4)
Ax = gca;
Ax.Visible = 0; % Make Axes Invisible
hl.Position = Ax.Position; % Use These Position Values For 'legend'
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by