bugGNU Octave - Bugs: bug #58530, missing functions: xline() and...

 
 

bug #58530: missing functions: xline() and yline()

Submitter:  Hartmut <hardy>
Submitted:  Mon 08 Jun 2020 05:56:40 PM UTC
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  In Progress Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Fri 08 Apr 2022 09:49:09 AM UTC, comment #13: 

Yes sure. I am making the required changes and will submit the patch again.
Thank you for your suggestions.

Tamandeep Singh <tamandeep>
Thu 07 Apr 2022 10:01:43 PM UTC, comment #12: 

@Tamandeep: Thank you for the patch.  I think you might want to start by borrowing the code from one of the existing plot routines like area.m because you will get a lot of the behavior that is generic to a plotting function for free.  For example, if called as

h = xline (...)

the function should return a handle to the xline object.  Also, it should always be possible to specify a different axes object besides gca to use with the syntax

xline (hax, ...)

I checked and the current patch doesn't support this behavior.

As I mentioned in comment #9, the xline object needs to be dynamic.  Right now the code is static.  Try

clf
xline (3)
ylim ([-1, 3])

The attached file shows that the line was not re-sized to the new axis limits.

file://xline.png


Rik <rik5>
Project Administrator
Thu 07 Apr 2022 06:27:32 PM UTC, comment #11: 

Yes, exactly Matlab is not creating a static line graphics object.
I have tried to mimic tis behaviour.

What I did is that I created dynamically changing vertical line. The vertical line length change according to the user needs. I have shown this in the images in the GNU discourse group. The discussion is going on there.

Tamandeep Singh <tamandeep>
Thu 07 Apr 2022 03:40:24 PM UTC, comment #10: 

I guess we will eventually want to create this "constantline" graphics object?

And maybe also migrate to a graphics system built with classdef objects?

Someday...

John W. Eaton <jwe>
Project Administrator
Thu 07 Apr 2022 03:15:59 PM UTC, comment #9: 

An initial implementation would be great, and then we can improve things from there.  This is not a difficult Octave project, but neither is it a trivial one.

The issue is that Matlab is not creating a static "line" graphics object.  Instead, they have created a new fundamental graphics type called "constantline".  In Octave, we can mimic that behavior by creating an hggroup object and then using addproperties() to create the properties that are missing from an ordinary line object.  A good example to build from is area.m in scripts/plot/draw directory.

The other tricky thing is that "constantline" is a dynamic object.  If the axis is resized then the underlying line object needs to have the data points changed so it again occupies the entire plot.  This is entirely feasible, but a little tricky.  When the hggroup is being built you will also need to use the addlistener() function to watch the current axes' "xlim" property (for a yline object).  The listener function will be a callback that adjusts the data in the line object to match the new xlimits.

Sample code for testing

yl = yline (2);  # Create yline at y==2, default xlimits of [0, 1]
xlim ([-5, 5]);

The above code should display a line that is now 10 data units long.

But, if you just want to get started and provide an initial implementation we can refine it from there.

Rik <rik5>
Project Administrator
Thu 07 Apr 2022 02:35:48 PM UTC, comment #8: 

you're welcome to go ahead and upload your working m-file or patch if you want comments. 

as @hardy said, you should do your best to ensure compatibilty with the matlab implementation.  Note, however, that there are a number of things there that Octave can't currently support.  E.g., only numeric inputs are likely necessary, as octave doesn't have implementations of duration, datetime, or categorical objects.  And it may describe line property parameters that Octave doesn't support, so hopefully just passing parameters directly to the underlying line functions would suffice and not take too much effort.

Nicholas Jankowski <nrjank>
Project Member
Thu 07 Apr 2022 01:27:42 PM UTC, comment #7: 

@Tamandeep: You could check with the Matlab help page, if your code does (mostly) the same thing as Matlab does ( https://de.mathworks.com/help/matlab/ref/xline.html ) Ideally it would also generate (and return) the same type of graphics objects as Matlab does.

Hartmut <hardy>
Thu 07 Apr 2022 12:15:50 PM UTC, comment #6: 

comment #5:

> Hello everyone.
> I have implemented xline and yline functions which are not in Octave,
> The implemented function does the following
> it takes a value input and creates a constant vertical line at that x coordinate for xline
> similarly it goes for y line
> I have also added linespec feature in this also for the specified line style, marker, and color.
> I have also added a feature in which we can give x coordinates as a vector so that we can draw multiple vertical lines in xline

Is there any other feature should I also add before submitting the patch?

Tamandeep Singh <tamandeep>
Thu 07 Apr 2022 12:13:24 PM UTC, comment #5: 

Hello everyone.
I have implemented xline and yline functions which are not in Octave,
The implemented function does the following
it takes a value input and creates a constant vertical line at that x coordinate for xline
similarly it goes for y line
I have also added linespec feature in this also for the specified line style, marker, and color.
I have also added a feature in which we can give x coordinates as a vector so that we can draw multiple vertical lines in xline

Tamandeep Singh <tamandeep>
Sun 21 Nov 2021 09:40:41 PM UTC, comment #4: 

Not enough time to add these properly to Octave version 7.1.  I added the two names to the list of unimplemented functions here: http://hg.savannah.gnu.org/hgweb/octave/rev/90ca4cd8e7e5.

Rik <rik5>
Project Administrator
Thu 11 Nov 2021 11:18:41 PM UTC, comment #3: 

ping @rik to see if he has these lying around that someone could turn into at least partial compatibility hacks. if not we could at least make a quick missing_functions add.

Nicholas Jankowski <nrjank>
Project Member
Fri 30 Apr 2021 10:53:11 PM UTC, comment #2: 

Using version 6.1.0

>> plot(1:10)
>> yline(5.7);
error: 'yline' undefined near line 1, column 1

Anonymous
Mon 08 Jun 2020 09:12:49 PM UTC, comment #1: 

Interesting, I wrote m-files to do this when I first started using Octave more than 10 years ago, but I called my files hline.m (horizontal line) and vline.m (vertical line).  I can dust them off and add them to Octave.

Rik <rik5>
Project Administrator
Mon 08 Jun 2020 05:56:40 PM UTC, original submission:  

There are two new functions in Matlab: xline and yline.
Mathworks introduced them in R2018b.
These functions just draw one straight line into a plot, like this:

plot(1:10)
yline(5.7);

Currently (Octave 5.2.0) does not throw an "unknown function" comment, when using those commands.

I would suggest to

  • at least include those functions into the "missing functions" list of Octave
  • maybe generate two new Octave functions, that mimic this simple behavior
  • Perfect compatibility won't be reachable too soon, because those two command seem to return some kind of (classdef) object in Matlab.
Hartmut <hardy>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53054:  xline.png added by rik5 (8KiB - image/png)
file #53053:  bug58530.patch added by tamandeep (3KiB - application/octet-stream - New Function implemented xline)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by tamandeep (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (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 project members can vote.

     

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-07 rik5 StatusConfirmed In Progress
    2022-04-07 rik5 Attached File- Added xline.png, #53054
    2022-04-07 tamandeep Attached File- Added bug58530.patch, #53053
    2020-06-08 rik5 StatusNone Confirmed
        Release5.2.0 dev

    Back to the top


    Powered by Savane 3.9