octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bounds on position for text()


From: Michael D Godfrey
Subject: Re: bounds on position for text()
Date: Wed, 09 Feb 2011 13:11:47 -0800
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7

On 02/09/2011 01:08 PM, bpabbott wrote:
On Feb 09, 2011, at 03:52 PM, Michael D Godfrey <address@hidden> wrote:

On 02/09/2011 12:19 PM, logari81 wrote:
On Wed, 2011-02-09 at 12:07 -0800, Michael D Godfrey wrote:
> On 02/09/2011 10:24 AM, bpabbott wrote: 
> > On Feb 09, 2011, at 01:14 PM, Konstantinos Poulios
> > <address@hidden> wrote:
> > 
> > 
> > > On Mon, Feb 7, 2011 at 12:37 AM, Ben Abbott <address@hidden>
> > > wrote:
> > > > On Feb 6, 2011, at 6:35 PM, Michael D Godfrey wrote:
> > > >
> > > >> On 02/06/2011 03:21 PM, Konstantinos Poulios wrote:
> > > >>> On Mon, Feb 7, 2011 at 12:16 AM, Michael D Godfrey
> > > >>>
> > > >>> <address@hidden>
> > > >>>  wrote:
> > > >>>
> > > >>>> >
> > > >>>> On 02/06/2011 02:49 PM, logari81 wrote:
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>>> On Sun, 2011-02-06 at 17:21 -0500, Ben Abbott wrote:
> > > >>>>
> > > >>>> >
> > > >>>>> >>
> > > >>>>> On Feb 6, 2011, at 4:02 PM, Michael D Godfrey wrote:
> > > >>>>>
> > > >>>>> >>
> > > >>>> >
> > > >>>>>> >> >
> > > >>>>>> A short while ago I created a bug report
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> (32311) which pointed out the fact that
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> text(x,y,"xxx') only works for x,y within the
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> axes. Matlab and legend allow writing the
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> string anywhere in the window.
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> >> >
> > > >>>>>> Since you just fixed legend, any chance
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> you could look at this?  Quite a lot of Matlab
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> code write annotations on plots using text
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> and positions this outside the axes.
> > > >>>>>>
> > > >>>>>> >> >
> > > >>>>>> >> >
> > > >>>>>> Michael
> > > >>>>>>
> > > >>>> >
> > > >>>>> >>
> > > >>>>> >>
> > > >>>>> I notice this work for the gnuplot backend, but not for the
> > > FLTK backend.
> > > >>>>>
> > > >>>>> >>
> > > >>>>> >>
> > > >>>>> It looks to me like something is checking the x/ydata values
> > > and not
> > > >>>>>
> > > >>>>> >>
> > > >>>>> rendering the result if it is outsize the axis limits.
> > > >>>>>
> > > >>>>> >>
> > > >>>>> >>
> > > >>>>> I'd expect this to be done in gl_render.cc, but don't see
> > > where it is.
> > > >>>>>
> > > >>>>> >>
> > > >>>>> I've cc'd Kostas, in case he knows where this is done.
> > > >>>>>
> > > >>>>> >>
> > > >>>>> >>
> > > >>>>> Ben
> > > >>>>>
> > > >>>>> >>
> > > >>>> >
> > > >>>> >
> > > >>>> printing of text objects is done in draw_axes_children in
> > > gl-render.cc
> > > >>>>
> > > >>>> >
> > > >>>> after the clipping property is checked.
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>>> So it works if you just set clipping off, like:
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>>> set(ht,'clipping','off')
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>>> If it would make sense we could change the default clipping
> > > to on.
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>>> Kostas
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>>> I just tried this.  It does not work.
> > > >>>>
> > > >>>> >
> > > >>>> octave:1> ht=plot(1:200)
> > > >>>>
> > > >>>> >
> > > >>>> ht = -19.142
> > > >>>>
> > > >>>> >
> > > >>>> octave:2> set(ht,'clipping','off');
> > > >>>>
> > > >>>> >
> > > >>>> octave:3> text(200,-2,'this is it')
> > > >>>>
> > > >>>> >
> > > >>>> octave:4> set(ht,'clipping','on');
> > > >>>>
> > > >>>> >
> > > >>>> octave:5> text(200,-2,'this is it')
> > > >>>>
> > > >>>> >
> > > >>>> octave:6> text(200,2,'this is it')
> > > >>>>
> > > >>>> >
> > > >>>> octave:7> text(200,20,'this is it')
> > > >>>>
> > > >>>> >
> > > >>>> octave:8> text(201,20,'this is it')
> > > >>>>
> > > >>>> >
> > > >>>> octave:9>
> > > >>>>
> > > >>>> >
> > > >>>> =========================
> > > >>>>
> > > >>>> >
> > > >>>> None of the text commands with x,y outside axes prints.
> > > >>>>
> > > >>>> >
> > > >>>> >
> > > >>> the clipping property refers to the text object, so just try:
> > > >>>
> > > >>> ht=text(200,-2,'this is it');
> > > >>> set(ht,'clipping','on');
> > > >>>
> > > >>> Kostas
> > > >>>
> > > >>>
> > > >> Right. Now it "works."  Except, where you say above 'on'
> > > >> you really need 'off'.   But, it is not like Matlab and it is a
> > > bit of
> > > >> work to obtain the text handle and set 'off' for each text use.
> > > >> So, how about default  'off.'?    Someday it might be useful
> > > >> to have a global on/off, but maybe after the release?
> > > >>
> > > >> Michael
> > > >
> > > > Matlab R2010b has the default set to "off".
> > > >
> > > > I recommend we do the same.
> > > >
> > > > Ben
> > > >
> > > >
> > > 
> > > I have taken a look at this, but I couldn't find a very easy way
> > > to
> > > change the default clipping value in the backend. This is because
> > > the
> > > clipping property is shared among many different classes and the
> > > text
> > > class doesn't have an init function which would let us override
> > > any
> > > default values of the base class.
> > > 
> > > Here we have to take a decision, should we add a init function for
> > > the
> > > text class or should we set the default value for clipping to
> > > "off" in
> > > the frontend (e.g. text.m)? Maybe John could give us some advice
> > > on
> > > that.
> > > 
> > > Kostas
> > > 
> >  
> > It looks to me like the "clipping" property needs to be removed from
> > the BASE_PROPERTIES list and added to each object.
> > 
> > 
> > This would be done in graphics.h.in. I haven't tried this myself,
> > so ... ?
> > 
> > 
> > Ben
> > 
> > 
> You might take a look at bug 32311.  There is a patch attached to it
> which
> sets the default clipping 'off'.  This comes close to matching Matlab
> behavior.
> (It appears to match with gnuplot in any case, the differences are for
> fltk.)
> The only known difference  under fltk is that if clipping is 'off' and
> you shrink
> the axes data that is then outside the axes is still visible.  I am
> not sure that
> this is a bad thing.  It appears to me that clipping is already a
> property of objects,
> like text (you have to turn it off with respect to each ht = text() in
> order for
> it to be 'off' (or 'on') for that text string.
> 
> In any case, a good first step would be to commit the patch that
> changes the
> default clipping 'off'.  It may be, in any case, that making it more
> easily selectable
> will be useful.  It might be good to allow resetting the default.
> 
> Michael
> 
the patch that you have pointed to sets clipping to off for all classes
based on base_properties. I don't think that we want that.
Who is we?  This needs more review.  It would be reasonable to allow
users choices.  And, the "defaults" should be configurable.  Now, a
set(ht,...) is required after each ht=text() command  And, this is not
explained in the Manual...   

I don't think having the clipping set to off for all objects is a good idea.

For example ...

x = -10:10;
plot (x, x)
axis ([-1, 1, -1, 1])

What is the result if the line object isn't cropped?

My understanding is that Matlab crops all graphics objects, with the exception of text objects. Is there a reason why we should deviate from Matlab?
Seems like a good start to me.

In any event, I like the idea of configurable defaults, and improvements to the manual. Should the former be added to the list of projects on the wiki?
Yes. And, include updating the Manual, of course.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]