Subplot excluded when there is overlap

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Subplot excluded when there is overlap

Daniel Sebald
It's sometimes useful to put subplots right next to one another if they
share an axis and leave but one set of tick labels for sake of space.
There's an apparent rule that subplots which lie under a plot are not
shown.  (If anyone knows of a property that changes that behavior,
please let me know.)

Because of the inexactness of floating point math, something like the
following:

figure
subplot('position', [0.15 0.2 0.8 0.2])
plot(1:50)

subplot('position', [0.15 0.4 0.8 0.2])
plot(1:50)

subplot('position', [0.15 0.6 0.8 0.2])
plot(1:50)

results in one of the subplots not displayed.  Technically there is
overlap because of the floating point limited resolution, i.e., 0.2f +
0.2f > 0.4f, or 0.4f + 0.2f > 0.6f.  But there is a certain
non-user-friendliness about making the user do something like

figure
subplot('position', [0.15 0.2 0.8 0.2-1e-10])
plot(1:50)

subplot('position', [0.15 0.4 0.8 0.2-1e-10])
plot(1:50)

subplot('position', [0.15 0.6 0.8 0.2-1e-10])
plot(1:50)

Also, sometimes the approach like above can result in the two borders in
common creating a thicker line.

Could the test for overlap be changed slightly to allow "nearly-equal"
in the formula somehow?

Dan

Topic: subplot plot graph position overlap disappear not shown

Reply | Threaded
Open this post in threaded view
|

Re: Subplot excluded when there is overlap

Pantxo
Daniel Sebald wrote
It's sometimes useful to put subplots right next to one another if they
share an axis and leave but one set of tick labels for sake of space.
There's an apparent rule that subplots which lie under a plot are not
shown.  (If anyone knows of a property that changes that behavior,
please let me know.)

Because of the inexactness of floating point math, something like the
following:

figure
subplot('position', [0.15 0.2 0.8 0.2])
plot(1:50)

subplot('position', [0.15 0.4 0.8 0.2])
plot(1:50)

subplot('position', [0.15 0.6 0.8 0.2])
plot(1:50)

results in one of the subplots not displayed.  Technically there is
overlap because of the floating point limited resolution, i.e., 0.2f +
0.2f > 0.4f, or 0.4f + 0.2f > 0.6f.  But there is a certain
non-user-friendliness about making the user do something like

figure
subplot('position', [0.15 0.2 0.8 0.2-1e-10])
plot(1:50)

subplot('position', [0.15 0.4 0.8 0.2-1e-10])
plot(1:50)

subplot('position', [0.15 0.6 0.8 0.2-1e-10])
plot(1:50)

Also, sometimes the approach like above can result in the two borders in
common creating a thicker line.

Could the test for overlap be changed slightly to allow "nearly-equal"
in the formula somehow?

Dan

Topic: subplot plot graph position overlap disappear not shown
I don't think this way of calling subplot with a fixed position is very useful, and the only difference with "axes ('position', pos)" is that the latter won't delete overlapping axes (plus subplot will add a lot of unused properties/listeners).

Pantxo
Reply | Threaded
Open this post in threaded view
|

Re: Subplot excluded when there is overlap

Daniel Sebald
On 03/12/2017 05:08 PM, Pantxo wrote:

> Daniel Sebald wrote
>> It's sometimes useful to put subplots right next to one another if they
>> share an axis and leave but one set of tick labels for sake of space.
>> There's an apparent rule that subplots which lie under a plot are not
>> shown.  (If anyone knows of a property that changes that behavior,
>> please let me know.)
>>
>> Because of the inexactness of floating point math, something like the
>> following:
>>
>> figure
>> subplot('position', [0.15 0.2 0.8 0.2])
>> plot(1:50)
>>
>> subplot('position', [0.15 0.4 0.8 0.2])
>> plot(1:50)
>>
>> subplot('position', [0.15 0.6 0.8 0.2])
>> plot(1:50)
>>
>> results in one of the subplots not displayed.  Technically there is
>> overlap because of the floating point limited resolution, i.e., 0.2f +
>> 0.2f > 0.4f, or 0.4f + 0.2f > 0.6f.  But there is a certain
>> non-user-friendliness about making the user do something like
>>
>> figure
>> subplot('position', [0.15 0.2 0.8 0.2-1e-10])
>> plot(1:50)
>>
>> subplot('position', [0.15 0.4 0.8 0.2-1e-10])
>> plot(1:50)
>>
>> subplot('position', [0.15 0.6 0.8 0.2-1e-10])
>> plot(1:50)
>>
>> Also, sometimes the approach like above can result in the two borders in
>> common creating a thicker line.
>>
>> Could the test for overlap be changed slightly to allow "nearly-equal"
>> in the formula somehow?
>>
>> Dan
>>
>> Topic: subplot plot graph position overlap disappear not shown
>
> I don't think this way of calling subplot with a fixed position is very
> useful, and the only difference with "axes ('position', pos)" is that the
> latter won't delete overlapping axes (plus subplot will add a lot of unused
> properties/listeners).
>
> Pantxo

Ah, axes() is what I'm looking for.  subplot() isn't so much an object
then, as it is an arrangement/layout utility with a no-obscure rule.

Thanks,

Dan

Reply | Threaded
Open this post in threaded view
|

Re: Subplot excluded when there is overlap

Rik-4
In reply to this post by Daniel Sebald
On 03/12/2017 06:33 AM, [hidden email] wrote:
Subject:
Subplot excluded when there is overlap
From:
Daniel J Sebald [hidden email]
Date:
03/12/2017 01:51 AM
To:
[hidden email]
List-Post:
[hidden email]
Content-Transfer-Encoding:
7bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset=utf-8; format=flowed
Message:
2

It's sometimes useful to put subplots right next to one another if they share an axis and leave but one set of tick labels for sake of space. There's an apparent rule that subplots which lie under a plot are not shown.  (If anyone knows of a property that changes that behavior, please let me know.)

Because of the inexactness of floating point math, something like the following:

figure
subplot('position', [0.15 0.2 0.8 0.2])
plot(1:50)

subplot('position', [0.15 0.4 0.8 0.2])
plot(1:50)

subplot('position', [0.15 0.6 0.8 0.2])
plot(1:50)

results in one of the subplots not displayed.  Technically there is overlap because of the floating point limited resolution, i.e., 0.2f + 0.2f > 0.4f, or 0.4f + 0.2f > 0.6f.  But there is a certain non-user-friendliness about making the user do something like

figure
subplot('position', [0.15 0.2 0.8 0.2-1e-10])
plot(1:50)

subplot('position', [0.15 0.4 0.8 0.2-1e-10])
plot(1:50)

subplot('position', [0.15 0.6 0.8 0.2-1e-10])
plot(1:50)

Also, sometimes the approach like above can result in the two borders in common creating a thicker line.

Could the test for overlap be changed slightly to allow "nearly-equal" in the formula somehow?

A slightly different take.  If you know exactly where you want the axes, why not just use axes() instead of subplot() in the code above?  Overlap won't matter since these will be independent axes rather than subplots.

You can take a look at the code in subplot.m.  When subplots overlap the function assumes that you are trying to re-plot into an existing subplot so it clears the old axes first.

--Rik
Reply | Threaded
Open this post in threaded view
|

Re: Subplot excluded when there is overlap

NJank
On Mon, Mar 13, 2017 at 2:12 AM, Rik <[hidden email]> wrote:

>
> On 03/12/2017 06:33 AM, [hidden email] wrote:
>
> figure
> subplot('position', [0.15 0.2 0.8 0.2])
> plot(1:50)
>
> subplot('position', [0.15 0.4 0.8 0.2])
> plot(1:50)
>
> subplot('position', [0.15 0.6 0.8 0.2])
> plot(1:50)
>
FYI, from a graphics output compatibility point of view. Matlab R2016b
displays all three plots with the above commands, while Octave loses
the middle one.  not that I expected one, but no difference with diff
graphics_toolkits. screencaps attached. Not sure if that's enough to
make it bug report worthy.

Matlab2016b.PNG (26K) Download Attachment
Octave4.2.1_QT.PNG (46K) Download Attachment
Octave4.2.1_fltk.PNG (18K) Download Attachment
Octave4.2.1_gnuplot.PNG (53K) Download Attachment