bugGNU Octave - Bugs: bug #36014, Wrong second axes when saved in pdf

 
 

bug #36014: Wrong second axes when saved in pdf

Submitted by:  Dik Dirk <dikdirk>
Submitted on:  Tue 27 Mar 2012 03:12:21 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: InvalidAssigned to: Ben Abbott <bpabbott>
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 30 Mar 2012 01:54:17 AM UTC, comment #7:

Ok. I'm closing this report

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
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')

Dik Dirk <dikdirk>
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).

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
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)

Dik Dirk <dikdirk>
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)

Dik Dirk <dikdirk>
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.

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
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.

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
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).

Dik Dirk <dikdirk>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #25489:  test3.pdf added by dikdirk (6KiB - application/pdf)
file #25487:  test2.pdf added by dikdirk (6KiB - application/pdf)
file #25476:  test.pdf added by dikdirk (6KiB - application/pdf)
file #25477:  bug_extra_yaxis.m added by dikdirk (480B - text/x-objective-c)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bpabbott (Posted a comment)
  • -unavailable- added by dikdirk (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 30 Mar 2012 01:54:17 AM UTCbpabbottOpen/ClosedOpen=>Closed
    Wed 28 Mar 2012 09:08:40 AM UTCdikdirkAttached File-=>Added test3.pdf, #25489
    Wed 28 Mar 2012 08:22:12 AM UTCdikdirkAttached File-=>Added test2.pdf, #25487
    Wed 28 Mar 2012 12:54:38 AM UTCbpabbottStatusNone=>Invalid
    Tue 27 Mar 2012 03:41:13 PM UTCbpabbottAssigned toNone=>bpabbott
      Release3.4.3=>dev
      Operating SystemMicrosoft Windows=>Any
    Tue 27 Mar 2012 03:12:21 PM UTCdikdirkAttached File-=>Added test.pdf, #25476
      Attached File-=>Added bug_extra_yaxis.m, #25477

    Back to the top


    Powered by Savane 3.1-cleanup1