Matlab 如何在bar3中沿X轴定位杆?

Matlab 如何在bar3中沿X轴定位杆?,matlab,graph,3d,bar-chart,Matlab,Graph,3d,Bar Chart,我试图在背景图像上使用bar3绘制条形图。虽然bar3命令能够沿Y轴移动条,但我不知道如何沿X轴方向移动条 这是我使用的示例,但仍然无法在X轴上移动条 A = [10 5 20 8]; bar3(1:4, A) xlabel('x'); ylabel('y'); 你有没有办法把横杆移到你想要的位置?谢谢 可以在创建条形图后修改其X坐标,并将其移动到需要的任何位置。下面的示例移动示例中的4个条,输出img如下所示 f = figure; ax = axes ( 'parent', f ); A

我试图在背景图像上使用bar3绘制条形图。虽然bar3命令能够沿Y轴移动条,但我不知道如何沿X轴方向移动条

这是我使用的示例,但仍然无法在X轴上移动条

A = [10 5 20 8];
bar3(1:4, A)
xlabel('x'); ylabel('y');

你有没有办法把横杆移到你想要的位置?谢谢

可以在创建条形图后修改其X坐标,并将其移动到需要的任何位置。下面的示例移动示例中的4个条,输出img如下所示

f = figure;
ax = axes ( 'parent', f );
A = [10 5 20 8];
h = bar3(ax, 1:4, A );
xlabel('x'); 
ylabel('y');
% create some new positions for the xdata
index = randperm(4);
% the xdata is blocks on 6x4 coordinates
start = 1;
for ii=1:4
  finish = start+5;
  % for each block of data update the x co-ordinate
  %   this will "move" if along the x-axis
  h.XData(start:finish,:)=h.XData(start:finish,:)+index(ii);
  start = finish+1;
end
% Update the xlim of the axes to display them
ax.XLim = [0 5];

你说的“移动”这些条是什么意思?我的意思是将它们放置在X轴一侧所需的位置。