首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >剪/删除部分情节

剪/删除部分情节
EN

Stack Overflow用户
提问于 2016-08-17 16:22:44
回答 1查看 701关注 0票数 2

我有以下情节:

正如你所看到的,这个图在左边(蓝色)和右边(红色)有一些数据。然而,我希望他们能更紧密地相处。例如,通过切割方框区域,因为没有数据,因此“红色区域”更多地移到左边(从而更接近“蓝色区域”)。

如何进一步进行?

MWE:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-17 21:40:39

下面是使用XtickLable的另一种调整(与注释中所建议的)

代码语言:javascript
复制
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;

这是之前

后的

这只是一个解决办法,可以根据具体需要进一步调整。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39001771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档