bugGNU Octave - Bugs: bug #31610, Text in subplot overlaps

 
 

bug #31610: Text in subplot overlaps

Submitter:  None
Submitted:  Tue 09 Nov 2010 10:09:13 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  logari81
Originator Name:  Rob Frohne Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 31 Jul 2015 05:08:56 PM UTC, comment #16: 

I try multiplot in gnuplot and default title/label placement for the terminals appears reasonably good.  So Octave must be altering something in order to make the graph area bigger, perhaps?  If that is done, then readjustment must be made for the labels.

As far as title/xlabel/ylabel placement, it's possible to specify an "offset".  That offset can be in relation to several different coordinate systems.  From the documentation:

"
It may be preceded by `first`, `second`, `graph`, `screen`,
 or `character` to select the coordinate system.  See `coordinates` for
 details.
"

Probably "graph" is the most logical one to use in this case, e.g.,

set title graph 0.5,1.05
set xlabel graph 0.5,-0.05

Something like that.  Is there some representation in the properties that is similar?  There appears to be:


get(get(gca,'title'))
...
    position =

       1.00000   1.12360   0.50000


Those positions look very similar to graph-relative coordinates.

It doesn't have to be exact, but if those 'title' position values could be mapped to

set title graph 0.50000,1.12360

it effectively puts control in the hands of the user to tweak things.  No matter what tool I've used for generating journal paper plots there is always some tweaking involved.  I'm never expecting exact label extent knowledge, but often times that isn't of critical importance, just that it is reasonable good and can be controlled.

Dan Sebald <sebald>
Sat 22 Jun 2013 01:15:14 AM UTC, comment #15: 

Fine with me.  Since we are moving away from gnuplot I don't think it makes sense to devote a lot of resources to trying to sort out this esoterica.  I'm taking your suggestion and closing this report.

Rik <rik5>
Group administrator
Fri 21 Jun 2013 02:04:04 AM UTC, comment #14: 

Rik,

I've is what renders for me using Gnuplot 4.6 patchlevel 3 and terminals "aqua", "qt" & "x11" (demo subplot 1).  Notice the "qt" terminal looks ok, "aqua" is overlapping, and "x11" is worse.

I don't think there is anything we can do to improve the rendering from the Octave side.  Although we can offset the position of the axes labels relative to where Gnuplot places them, we don't know where gnuplot actually places the axes labels or that their extents are. To make matters worse, each of Gnplot's terminals behave inconsistently.  In the past we considered replacing the axes labels with text objects, but that didn't work out since we have no way to determining the font metrics (text object's extents) for the text rendered by gnuplot :-(

The preferred solution for Octave has been to use native graphics (this is actually one of the reasons we decided to implement native graphics).

My preferred solution for Octave+Gnuplot is to allow Gnuplot to handle all these sort of things.   Which is why the Gnuplot toolkit produces a different result as compared to OpenGL when the activepositionproperty is "outerposition" (Its rendered the "gnuplot" way, not the Matlab way).  We also allow Gnuplot to handle the legend placement (using the gnuplot "key" feature).

In any event, since OpenGL is working, I'm ok with closing this (marking the Status as "Won't Fix" and the Item Group as "Matlab Compatibility"). I'm also ok with keeping it open to help avoid new reports of this "feature".

Thoughts?



Ben Abbott <bpabbott>
Group Member
Thu 20 Jun 2013 04:42:00 PM UTC, comment #13: 

The bug is still present with gnuplot 3.6.2 and an Octave tip from 6/20/13.

Rik <rik5>
Group administrator
Sun 04 Sep 2011 11:15:09 PM UTC, comment #12: 

This bug has been re-introduced.  I've marked the issue now as being against the development version of the code.  "demo subplot" works for the FLTK toolkit so I have restricted the category to be "Plotting with gnuplot"

Rik <rik5>
Group administrator
Thu 19 May 2011 07:34:36 PM UTC, comment #11: 

This bug used to be fixed with

http://hg.savannah.gnu.org/hgweb/octave/rev/c9df571efe95

for the gnuplot backend only.

I am reopening it because in the current default branch this bug seems to be present for both gnuplot and fltk again.

The regression for gnuplot occured here:
http://hg.savannah.gnu.org/hgweb/octave/rev/64ae43e0e1c0

Konstantinos Poulios <logari81>
Tue 28 Dec 2010 02:16:22 AM UTC, comment #10: 

There's been no follow up, so I'm closing this. If needed it can be reopened.

Ben Abbott <bpabbott>
Group Member
Thu 02 Dec 2010 11:47:41 PM UTC, comment #9: 

I noticed that my prior patch would change the activepositionproperty each time subplot was called ... even if the axis already existed. It also treated both gnuplot and fltk the same. I've modified it pushed this change.

http://hg.savannah.gnu.org/hgweb/octave/rev/c9df571efe95




Ben Abbott <bpabbott>
Group Member
Thu 02 Dec 2010 04:45:23 PM UTC, comment #8: 

Yes, I think the best solution is to provide a ML-compatible behavior for the fltk backend and use solution #3 for the gnuplot backend.

If you (or others) are no familiar with how ML works, see the link below.

http://www.mathworks.com/help/techdoc/creating_plots/f1-32495.html

When I get the chance, I'll push the change for the gnuplot backend.


Ben Abbott <bpabbott>
Group Member
Thu 02 Dec 2010 03:32:03 PM UTC, comment #7: 

Concerning the "replace" option, you are right, there was an error in my test case. Actually octave's subplot(r,c,n) corresponded to ML's subplot(r,c,n, 'align') and not subplot(r,c,n, 'align', 'replace') as I wrote before.

The "replace" option as implemented in your attached patch also seems to work as expected.

Concerning the solution #3 that you have implemented, it solves the problem with title overlapping in the gnuplot backend quite well but its behavior is not totally compatible with ML and besides that it doesn't work with the fltk backend, since this one doesn't take into account the "ActivePositionProperty".

Actually, as you have pointed out, ML seems to use some kind of callback to calculate the size of all axes in a grid. If you try

subplot(221)
subplot(222)
subplot(223)
subplot(224)
xlabel('me')

in ML you will see that the xlabel command affects not only the subplot 224 but also the subplots 221,222 and 223.

I think that at least for the fltk backend it shouldn't be very difficult to scan all subplots in a figure and synchronize the sizes of those that belong to the same grid (e.g. grid 22 in the example above).

I am not sure if there is already a possibility for the fltk backend to add some extra padding space around the axes box manually. If not, maybe we could provide the possibility of extra padding space in the get_boundary function of the axes object. Maybe this is also the place where the "ActivePositionProperty" could also be implemented. What do you think?

Before trying to fix anything, I will try to understand the previous work of David Batemann with respect to the colorbox issues which seem to be relevant.

One possibility would be to provide a quite ML-compatible behavior for the subplots in the fltk backend and just use your solution #3 for the gnuplot backend. Would such a backend-depended handling of subplots be an acceptable solution?

Konstantinos Poulios <logari81>
Thu 02 Dec 2010 12:55:33 PM UTC, comment #6: 

(repost)

Looking at Matlab's documentation for what "align" does …


SUBPLOT(m,n,p,'align') places the axes so that the plot boxes are aligned,
but does not prevent the labels and ticks from overlapping.


My first thought was that "align" implies that activepositionproperty is set
to "position", and that the default would be "outerposition".

However, the commands below …


h1 = subplot(2,2,1);
h2 = subplot(2,2,1,'align');
get (h1, 'ActivePositionProperty')
ans = position
get (h2, 'ActivePositionProperty')
ans = position


… indicate that, for Matlab, the activepositionproperty is always set to
"position". I think this implies that callbacks are used to set the position
of the plot box and that the position is dependent upon the position and
extents of the tick and axes labels.

Unfortunately, we don't have a reliable method to determine the position and
extents of text for gnuplot (David Batemann recently tried, so I've cc'd him).
I see three options.

  1. Patch gnuplot to provide the needed text information.
  2. Make another attempt to calculate the position and extents in

Octave.

  1. Interpret "align" to imply the activepositionproperty is "position",

and "outerposition" otherwise.

The first two options are in need of a volunteer. Once/if the text extends
are available the axes properties "position", "outerposition", and
"tightinset" will need to be properly determined. Legends are also impacted
(others that are slipping my mind?). This would require a lot of effort, which
I think would be better invested in the OpenGL backends.

The third option is a trivial fix. This will only  produce the intended
effect if all subplots have same activepositionproperty. In that case, the
effect of not specifying "align" would be identical to the commands below.


demo ("subplot", 1);
set (findobj (gcf, "type", "axes"), "activepositionproperty",
"outerposition")


If the third approach is acceptable, I can implement it.

Matlab's documentation for subplot describes the effect of "replace" as ...

If a SUBPLOT specification causes a new axes to overlap an existing axes, the
existing axes is deleted - unless the position of the new and existing axes
are identical.  For example, the statement SUBPLOT(1,2,1) deletes all existing
axes overlapping the left side of the Figure window and creates a new axes on
that side - unless there is an axes there with a position that exactly matches
the position of the new axes (and 'replace' was not specified), in which case
all other overlapping axes will be deleted and the matching axes will become
the current axes.


It looks to me like Octave is behaving correctly when "replace" is not
specified.


octave:1> h = subplot (2,2,1)
h = -1.2334
octave:2> h = subplot (2,2,1)
h = -1.2334
octave:3> h = subplot (1,2,1)
h = -5.0747


Specifying "replace" would return a new axes handle for the second subplot
command. This should be a simple fix.

I've attached a changeset adding support for the "replace" option and have included the 3rd option for
"align".


(file #22089)

Ben Abbott <bpabbott>
Group Member
Thu 02 Dec 2010 08:39:50 AM UTC, comment #5: 

(Reposting my lost message from Nov 26)
Actually the subplot command in octave misses two options comparing it with ML: 'align' and 'replace'

Interestingly, what we see in this bug is that Octave behaves like ML but with both this options enabled. That means, octave's subplot(r,c,n) corresponds to ML's subplot(r,c,n, 'align', replace') which causes axis labels to overlap.

Konstantinos Poulios <logari81>
Thu 11 Nov 2010 04:29:24 PM UTC, comment #4: 

In case anyone is interested in the axis label position tweaks I attempted, I've attached a changeset.

(file #21981)

Ben Abbott <bpabbott>
Group Member
Thu 11 Nov 2010 04:13:08 PM UTC, comment #3: 

I tried tweaking the axis label positions for the gnuplot backend, but did not get satisfactory results. Overlap still occurred in enough cases that this approach can't be a general solution.

I also noticed this problem exists for the fltk backend. I don't have any (reliable) insight into what is needed there.

Ben Abbott <bpabbott>
Group Member
Thu 11 Nov 2010 03:47:12 PM UTC, comment #2: 

The "position" of Octave's axes' plot boxes are set to approximate those in Matlab (see subplot.m:subplot_position). The spacing between the axes labels, title, tickmarks and the plot box is controlled by gnuplot. Gnuplot usually has more liberal spacing than does Matlab.

It may be possible to compensated for this by tweaking the title and axeslabel positions (I'll take a look to see if this can be done with consistent results for all terminals).

If reliable information for the text extents could be determined, then the text object positions could be explicitly set by octave. For a proper implementation this information should be provided by gnuplot, which it is not. Recently David Bateman attempted to reverse engineer this in Octave, but the result was unsatisfactory. I've cc'd David in case he'd like to comment.

The subplot command sets the activepositionproperty to "position" for each axis. As as work-around to avoid overlaping, the activepositionproperty may be set to "outerposition".


demo ("subplot", 1)
has = findall (gcf, "type", "axes")
set (hax, "activepositionproperty", "outerposition")
+verbatim+

Ben Abbott <bpabbott>
Group Member
Tue 09 Nov 2010 11:47:35 PM UTC, comment #1: 

The attached png seems to show the correct behavior with a space between the two subplots.  This is likely the result of using a different backend (-dpng) with print then the one used for onscreen display.

I can confirm an overlap on the plot displayed onscreen using the gnuplot backend and current development sources.  A quick way to reproduce the behavior is to run:

demo ("subplot");


Rik <rik5>
Group administrator
Tue 09 Nov 2010 10:09:13 PM UTC, original submission:  

Hi,

The xlabel of the top plot overlaps with the title of the bottom plot.  See example subplot_example.m file and the graphic .png that goes with it.  I'm using gnuplot on Ubuntu 10.10 for the graphic display.

There seems to be some discussion of this at:

http://octave.1599824.n4.nabble.com/Subplot-Tick-Mark-Label-td2233140.html

Thanks for all your good work!

Rob

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #28372:  gnuplot-4.6p3-qt.png added by bpabbott (85KiB - image/png)
file #28373:  gnuplot-4.6p3-x11.png added by bpabbott (36KiB - image/png)
file #28374:  gnuplot-4.6p3-aqua.png added by bpabbott (83KiB - image/png)
file #22089:  changeset.patch added by bpabbott (3KiB - fix "replace" and handle "align" in a GP manner)
file #21981:  changeset.patch added by bpabbott (3KiB - axis label position tweaks)
file #21970:  subplot_example.m added by None (181B - text/x-objcsrc)
file #21971:  subplot_example.png added by None (34KiB - image/png)

 

Carbon-Copy List
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by logari81 (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by bpabbott
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 23 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-31 mtmiller Dependencies- bugs #45666 is dependent
    2014-04-07 rik5 Dependencies- bugs #41128 is dependent
    2013-06-22 bpabbott Open/ClosedOpen Closed
    2013-06-22 rik5 Item GroupRegression Matlab Compatibility
        StatusConfirmed Wont Fix
    2013-06-21 bpabbott Attached File- Added gnuplot-4.6p3-qt.png, #28372
        Attached File- Added gnuplot-4.6p3-x11.png, #28373
        Attached File- Added gnuplot-4.6p3-aqua.png, #28374
    2013-06-20 rik5 Item GroupPerformance Regression
    2011-09-04 rik5 CategoryNone Plotting with gnuplot
        Release3.2.4 dev
    2011-05-19 logari81 StatusFixed Confirmed
        Assigned toNone logari81
        Open/ClosedClosed Open
    2010-12-28 bpabbott Open/ClosedOpen Closed
    2010-12-28 bpabbott StatusConfirmed Fixed
    2010-12-02 rik5 Carbon-CopyRemoved 72865 -
    2010-12-02 bpabbott Attached File- Added changeset.patch, #22089
    2010-11-11 bpabbott Attached File- Added changeset.patch, #21981
    2010-11-11 bpabbott Carbon-Copy- Added david bateman <dbateman@free.fr>
    2010-11-09 rik5 StatusNone Confirmed
    2010-11-09 None Attached File- Added subplot_example.m, #21970
        Attached File- Added subplot_example.png, #21971

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code