我有以下情节:
如您所见,该图在左侧(蓝色)和右侧(红色)有一些数据。但是,我希望他们更加紧密。例如,通过剪切框区域,因为没有数据,因此“红色区域”更多地向左移动(因此更接近“蓝色区域”)。
如何进一步处理?
MWE:
x = 0:0.05:1.3
y = x;
plot(x,y,'color','k','Linewidth',1);
hold on;
x1 = [0.1:0.05:x(end)];
y1 = [0:0.05:y(end)-0.1];
plot(x1,y1,'--k','Linewidth',1);
x2 = [0:0.05:x(end)];
y2 = [0.10:0.05:y(end)+0.1];
plot(x2,y2,'--k','Linewidth',1);
xlim([0 x(end)]);
ylim([0 y(end)]);
hold on
for i = 1:9;
a = plot(P(i).mHlfA1,P(i).sHlfA1, 'bx');
hold on
b = plot(P(i).mHlfA1,P(i).sLFA1, 'bo');
hold on
c = plot(P(i).mHlfA2,P(i).sHlfA2, 'rd');
hold on
d = plot(P(i).mHlfA2,P(i).sLFA2, 'r*');
hold on;
end
答案 0 :(得分:1)
以下是使用XtickLable
进行的另一种调整(在评论中建议):
x = [1:10 200:2:230];
y = 3.*x-9;
% define the parts of he x-axis:
xgap = 11;
% pasting together the two parts:
new_x = [x(1:xgap-1) x(xgap-1)+(x(xgap:end)-x(xgap))+(x(xgap+2)-x(xgap+1))];
ax = axes;
plot(ax,new_x,y,'o');
% get the ticks to change:
left_x_tick = ax.XTick(ax.XTick<=x(xgap-1));
right_x_tick = ax.XTick(ax.XTick>x(xgap-1));
slash = left_x_tick(end)+floor((right_x_tick(1)-left_x_tick(end))/2);
ax.XTick = [left_x_tick slash right_x_tick];
% get the spacing between ticks
inc = right_x_tick - min(right_x_tick);
% create new tick labels:
new_tick = cellstr(num2str(inc.' + min(x(xgap:end))+(right_x_tick(1)-new_x(xgap))));
% replace the tick labels in the plot
ax.XTickLabel(ax.XTick>new_x(xgap)) = new_tick;
% put a // where there is a gap:
slash_loc = find(ax.XTick==slash,1,'first');
ax.XTickLabel(slash_loc) = {'//'};
ax.FontSize = 14;
之前:
和之后:
这只是解决方法的一个想法,可以根据具体需求进一步调整。