Fri 30 Mar 2012 01:54:17 AM UTC, comment #7:
Ok. I'm closing this report
|
Thu 29 Mar 2012 08:22:37 AM UTC, comment #6:
Thank you, it is currently working in the way I want it to work. For completeness, this is the code
clf()
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
plot(x1,y1)
ax1 = gca;
ax2=axes('Color','none','XTick',[],'YAxisLocation','right','YTick',exp(get(ax1,'YTick')),'YLim',exp(get(ax1,'YLim')),'XLim',get(ax1,'XLim'),'YScale','log');
h1=ylabel(ax1,'Log Index');
h2=ylabel(ax2,'Index');
position1 = get (ax1, "position");
position2 = get (ax2, "position");
position = [max(position1(1),position2(1))0.95,max(position1(2),position2(2)),min(position1(3),position2(3))0.9,min(position1(4),position2(4))];
set ([ax1, ax2], "position", position, "activepositionproperty", "position")
set(gcf,'PaperUnits','centimeters')
set(gcf,'PaperSize', [15 12])
set(gcf,'PaperPosition',[0 0 15 12])
drawnow
saveas(gcf,'test3.pdf')
|
Wed 28 Mar 2012 12:13:42 PM UTC, comment #5:
The outerposition is the box that encompass the plotbox, tick labels, axes labels, and the title.
The position property is just the plot box.
To align the two axis plot boxes, try
If you find that the right y-axes label may gets clipped, you can decrease the value of the plotbox width, position(3).
|
Wed 28 Mar 2012 09:08:40 AM UTC, comment #4:
Thanks for all the work you are doing on octave, it's a great product!
I have also tested the following code and have set properties of ax1 to the ones of ax2 (i.e. if I understand correctly adding a label to ax2 changes the position of the axis, so then we have to relocate ax1). Afterwards I checked the settings of position, outerposition and activepositionproperty for both axes... they are the same.
The output however, is not correct or I don't understand why it is correct, see test3.pdf. I hope this helps in sorting this out.
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
plot(x1,y1)
ax1 = gca;
ax2=axes('ActivePositionProperty','outerposition','Color','none','XTick',[],'YAxisLocation','right','YTick',exp(get(ax1,'YTick')),'YLim',exp(get(ax1,'YLim')),'XLim',exp(get(ax1,'XLim')),'YScale','log');
ylabel(ax1,'Log Index')
ylabel(ax2,'Index')
set (ax1,'OuterPosition', get (ax2, 'OuterPosition'))
set (ax1,'ActivePositionProperty','outerposition')
set(gcf,'PaperUnits','centimeters')
set(gcf,'PaperSize', [15 12])
set(gcf,'PaperPosition',[0 0 15 12])
drawnow
pause(2)
saveas(gcf,'test3.pdf')
(file #25489)
|
Wed 28 Mar 2012 08:22:12 AM UTC, comment #3:
Unfortunately, this still doesn't work for me, your code produces the attachted pdf, see pdf test2.pdf.
(file #25487)
|
Wed 28 Mar 2012 12:54:38 AM UTC, comment #2:
Turns out this isn't a bug.
Since the value for the position property for ax2 never changes the updater never changes the activepositionproperty to "position".
If the ylabel for ax2 is set before "set (ax2, 'Position', get (ax1, 'Position')" then it works as intended.
While this behavior is a bit esoteric, I think Octave is working as it should, so I'm changing the status to invalid. I'll leave it open in case I've missed something or in case more discussion is merited.
|
Tue 27 Mar 2012 03:41:13 PM UTC, comment #1:
Your example has a bug in it. The "activepositionproperty" for ax1 is "outerposition" and that for ax2 is "position".
The following fixes that
However, this still does not work. The updater for "position" should be changing the "activepositionproperty" for ax2, but is not.
I'll take a look.
For now, a work around is to add the following lines.
|
Tue 27 Mar 2012 03:12:21 PM UTC, original submission:
The attached code adds an extra y-axis with a log scale on the right. However, when saved in pdf. The second axes shifts, see attatched pdf.
This bug is probably related to bug #35908, therefore I cannot test this in 3.6.1 (as explained in #35908, in 3.6.1 saving in pdf without the second axis already produces an incorrect result).
|