Unable to change the height of the barh.
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
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 Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!