八度图形 xticklabel 固定和旋转
我使用的是 Octave 5.2.0。使用plotyy创建双轴图(在子图中) 我使用 text() 函数创建了 xticklabels,给了我一个带有 ypositions 和 xtick (旋转)的对象。 我的问题是,当我使用“平移”移动子图 1 的曲线(例如向下)时,xticklabel 也会向相同方向移动,直到它们在第二个图之后被隐藏,并且我必须向相反方向移动曲线再次见到他们。 第二个问题。如果不使用 text() 函数,是否无法进行 xticklabelrotation,因为这非常慢(4000 个日期需要 5 分钟)。我包含了部分代码。和 2 张图片(向上移动曲线后的 1 张)。感谢您的帮助。
function plotKoersIndicSub(varargin)
[labelsVrX,labelsVrXNrs,xDateEpoch]=prepXVrPlot(varargin(dateKol)); [dateKol,P1Y1Kol,P1Y2Kol,P2Y1Kol,P2Y2Kol,labP1Y1,labP1Y2,labP2Y1,labP2Y2]=splitVarargin(varargin,nargin);
clf
hax1 =subplot (2, 1, 1);
[ax,hCurve1,hCurve2] = plotyy (xDateEpoch,varargin(P1Y1Kol(1)){:},xDateEpoch,varargin(P1Y2Kol(1)){:}, @plot, @plot);
fig=gcf();
set(fig,'units','centimeters'); set(fig,'position',[19,2.8,15,15]);
set(hCurve1, "linestyle", ":"); set(hCurve1,'LineWidth',2); set(hCurve1,'Color','blue');
set(hCurve2, "linestyle", "-"); set(hCurve2,'LineWidth',2); set(hCurve2,'Color','red');
hYlab1=ylabel(ax(1), labP1Y1); set (hYlab1, "fontsize", 14);
hYlab2=ylabel(ax(2), labP1Y2); set (hYlab2, "fontsize", 14);
k1Mx=max(varargin(P1Y1Kol(1)){:});k2Mx=max(varargin(P1Y2Kol(1)){:});
k1Min=min(varargin(P1Y1Kol(1)){:});k2Min=min(varargin(P1Y2Kol(1)){:});
ylim(ax(1),[k1Min k1Mx]);ylim(ax(2),[k2Min k2Mx]);
linkaxes(ax,'x');
set(gca,'xticklabel',labelsVrXNrs);
h = get(gca,'xlabel');
xlabelposition = get(h,'position');
yposition = xlabelposition(2); % yposition = 0.80090
yposition = repmat(yposition,columns(xDateEpoch),1);
set(gca,'xtick',[]);
hnew = text(xDateEpoch, yposition, labelsVrX);% 5 minutes!! / 4000 dates
set(hnew,'fontsize',14);
set(hnew,'rotation',90,'horizontalalignment','right');
结束功能
I'am using Octave 5.2.0. to create a double axed plot with plotyy (in a subplot)
I created xticklabels with text() function, giving me an object with ypositions and xtick (rotated).
My problem is that when I move the curves of the subplot 1 (e.g. down) using the 'pan', the xticklabels move also in the same direction until they are hidden after the second plot and I have to move the curve in the opposite direction to see them again.
Second question. Is there no xticklabelrotation possible without using the text() function because this is very slow (5 min for 4000 dates). I include a part of the code. and 2 pictures (1 after moving the curve UP).Thanks for helping.
function plotKoersIndicSub(varargin)
[labelsVrX,labelsVrXNrs,xDateEpoch]=prepXVrPlot(varargin(dateKol)); [dateKol,P1Y1Kol,P1Y2Kol,P2Y1Kol,P2Y2Kol,labP1Y1,labP1Y2,labP2Y1,labP2Y2]=splitVarargin(varargin,nargin);
clf
hax1 =subplot (2, 1, 1);
[ax,hCurve1,hCurve2] = plotyy (xDateEpoch,varargin(P1Y1Kol(1)){:},xDateEpoch,varargin(P1Y2Kol(1)){:}, @plot, @plot);
fig=gcf();
set(fig,'units','centimeters'); set(fig,'position',[19,2.8,15,15]);
set(hCurve1, "linestyle", ":"); set(hCurve1,'LineWidth',2); set(hCurve1,'Color','blue');
set(hCurve2, "linestyle", "-"); set(hCurve2,'LineWidth',2); set(hCurve2,'Color','red');
hYlab1=ylabel(ax(1), labP1Y1); set (hYlab1, "fontsize", 14);
hYlab2=ylabel(ax(2), labP1Y2); set (hYlab2, "fontsize", 14);
k1Mx=max(varargin(P1Y1Kol(1)){:});k2Mx=max(varargin(P1Y2Kol(1)){:});
k1Min=min(varargin(P1Y1Kol(1)){:});k2Min=min(varargin(P1Y2Kol(1)){:});
ylim(ax(1),[k1Min k1Mx]);ylim(ax(2),[k2Min k2Mx]);
linkaxes(ax,'x');
set(gca,'xticklabel',labelsVrXNrs);
h = get(gca,'xlabel');
xlabelposition = get(h,'position');
yposition = xlabelposition(2); % yposition = 0.80090
yposition = repmat(yposition,columns(xDateEpoch),1);
set(gca,'xtick',[]);
hnew = text(xDateEpoch, yposition, labelsVrX);% 5 minutes!! / 4000 dates
set(hnew,'fontsize',14);
set(hnew,'rotation',90,'horizontalalignment','right');
endfunction
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论