bugGNU Octave - Bugs: bug #29057, __errplot__.m plots legends...

 
 

bug #29057: __errplot__.m plots legends without markers

Submitter:  None
Submitted:  Wed 03 Mar 2010 08:32:51 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Jarno Rajahalme Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Mac OS Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 28 Apr 2010 07:06:50 PM UTC, comment #33: 

I'm not sure that the backend can't handle the ldata, udata of the line objects and if they aare non empty assume that an errorbar is requested.. This might be easier than modifying the frontend. In any case the issue with the marker updates is just another bug in my past patch and the attached should fix it

D.


(file #20360)

David Bateman <dbateman>
Group Member
Wed 28 Apr 2010 02:37:42 PM UTC, comment #32: 

I agree. Eventually the error bars will need to be drawn in a manner that doesn't rely upon the special features of particular backend (same needs to be done for the legend).

Ben Abbott <bpabbott>
Group Member
Wed 28 Apr 2010 02:05:41 PM UTC, comment #31: 

If I understand the problem correctly, I think the solution is to not rely on gnuplot to draw the errorbars, but to have Octave generate the line commands to draw them.  That's what other backends will have probably have to do.

Or, I guess you could try to get a change in gnuplot so that the markers only appear on the main line and not on the error bars.

John W. Eaton <jwe>
Group administrator
Wed 28 Apr 2010 01:38:45 PM UTC, comment #30: 

Opps ... my last comment may have inspired the wrong approach.

With the latest changeset

    http://hg.savannah.gnu.org/hgweb/octave/rev/6a81e809a392

The markers do not survive an update.

x = 0:0.5:2*pi;
err = x/100;
y1 = sin (x);
y2 = cos (x);
h = errorbar (x, y1, err, "-s", x, y2, err, "--o");

At this point the markers are as they should be.

set (h, "markersize", 3)

After an update, the markers are now all set to "none".

I assume this latest change to _errorplt_ needs to reverted. I don't see how to ask gnuplot to draw the error bars with no markers but keep the markers for the usual line object.

Perhaps it is best to add the markers to both the error bars and the normal line object ... which I think means reverting the changeset above.

Additionally, I noticed that the following throws an error.

    h = errorbar (x, y1, err, x, y2, err);



Ben Abbott <bpabbott>
Group Member
Wed 28 Apr 2010 01:06:29 AM UTC, comment #29: 

No reason, the marker used to be "none" and the attached changset changes it back. As Rik has committed his patch, I'm closing this bug report

D.


(file #20353)

David Bateman <dbateman>
Group Member
Wed 28 Apr 2010 12:48:23 AM UTC, comment #28: 

David/Rik,

Any reason why the marker type for the error bars can't be set to "none" as it the case with Matlab?

Ben Abbott <bpabbott>
Group Member
Tue 27 Apr 2010 10:44:21 PM UTC, comment #27: 

@David

Well, this bug report contains several examples, so I don't really know which to pick (btw. none of the examples actually run in Matlab as they all use Octave-specific syntax). So, I just did this

>> x = 0:0.5:2*pi;
>> y1 = sin (x);
>> y2 = cos (x);
>> err = x/100;  
>> errorbar (x, y1, err, '-*');
>> legend sin
>> get (get (gca(), 'children'), 'marker')


ans =

*

>> get (get (get (gca(), 'children'), 'children'), 'marker')


ans =

    '*'
    'none'

Søren Hauberg <hauberg>
Tue 27 Apr 2010 10:19:32 PM UTC, comment #26: 

@Soren
Run one of the errorbar examples before looking at the markers.

@Jarno and Ben
The markers can already be cycled through by setting the colororder property to a 1 by 3 vector for the color and then setting the linestyleorder to something like "+o*" for example

For example

x = [0:0.5:2*pi]';
err = x/50;
y1 = sin (x);
y2 = cos (x);
set(gca(), "colororder", [1, 0, 0], "linestyleorder", "-+|-o|-*");
h1 = errorbar ([x, x], [y1, y2], [err, err]);
legend ('left')
legend ('sin', 'cos', 'location', 'southwest')

though this currently fails as errorbar doesn't respect the linestyleorder property. The attached patch that I committed adds this and also allows the linestyle to be set with the errorbar style (for example ("~-o" is a valid style).

@Rik
I thought we could get gnuplot not to print a marker at all rather than using the ".". It seems what you propose is the right thing to do. Can you commit your patch? I believe and my changeset will close this bug (or rather feature request given the details that this has involved).


(file #20352)

David Bateman <dbateman>
Group Member
Tue 27 Apr 2010 07:48:06 PM UTC, comment #25: 

The line colors are cycled through in the order defined by the order defined by the parent axes "colororder" property.

If we'd like to have the ability to cycle through markers, I recommend a "markerorder" property be defined for the axes objects.

However, this is a different topic and should be discussed on the maintainers email list.

Ben Abbott <bpabbott>
Group Member
Tue 27 Apr 2010 06:45:37 PM UTC, comment #24: 

Rik's patch posted in the attachments section removes the markers added by gnuplot from the errorbars. Now it is possible to separately set markers, and they also appear in the legend.

However, I miss the functionality thus removed: the possibility to have the markers be automatically cycled for different lines (even though it was done by gnuplot, not Octave). Any chance to get that into Octave?

Thanks,

  Jarno

Anonymous
Tue 27 Apr 2010 04:17:02 PM UTC, comment #23: 

David,

I don't quite follow. What code should I run before

  get (get (gca(), "children"), "marker")
  get (get (get (gca(), "children"), "children"), "marker")

?

Søren Hauberg <hauberg>
Tue 27 Apr 2010 01:57:48 PM UTC, comment #22: 

Soren,

Try something like

get (get (gca(), "children"), "marker")

for the markers of the hggroups and then

get (get (get (gca(), "children"), "children"), "marker")

for the markers of the sub objects of the hggroups.. They are all the same. I think Rik is right and its gnuplot adding them to the errorbars and probably something like Rik's fix is the right thing to do.. I don't have time to check at the moment though..

Cheers
David

David Bateman <dbateman>
Group Member
Tue 27 Apr 2010 12:21:34 PM UTC, comment #21: 

I read Rik's email (which I dont' see on the tracker), and took a quick look at Matlab.

The Matlab solution sets the marker size for the line object, and the marker size is the default for a line object, and Matlab sets the "markertype" for the error bars to "none".

I think Octave is doing this part correctly. However, it is also adding markers to the error bars ... which Matlab does not have.


Ben Abbott <bpabbott>
Group Member
Tue 27 Apr 2010 01:24:49 AM UTC, comment #20: 

Ben,

Yes, I am using Aquaterm. Is there a way to set the default size differently in Aquaterm?

What is funny is that when doing

h = errorbar (x, y1, err, "~", x, y2, err, "~");
legend("sin", "cos", "location", "southwest");

I get (by default) markers that are of the correct size. If I do:

set(h, "marker", "o");

I get big markers suporimposed on top of the old markers, and the markers are of different style than the "default" ones. (see attachment "markertest.pdf")

It appears to me that the original markers (that were of the correct size) are NOT in Octave's control, as setting the "marker" or "markersize" has no effect on them. You might see the same thing, if you set the "markersize" bigger, so the "new" markers are not drawn directly on top of the "old" ones.

Is it possible that gnuplot is adding some markers by default, underneath Octave?

Experimenting with this by commenting out the last _line_ call in _errplot_.m, causing only the errorbars be plotted, and no "visible line", I see that the errorbars are drawn with some default markers, and that setting the "marker" or "markersize" have no effect, even though I can verify that the corresponding children of the hggroup is of type "line" and has "marker" of "o" (which is not what I see).

Finally, it appears that the order of the children in the hggroup is significant, when it comes to the legend. Adding this line after the last _line_ call in _errplot_.m changes this order:

   set(hl, "parent", hg);

Now the 'hl' (the line with the errorbars, not the visible line just added above) is the 1st children, and when creating the legend, the markers visible on the errorbars are shown in the legend. (see attachment "markertest2.pdf")

The children order seems to be significant to the update_data () function further down in the file; there the error data is updated on the 2nd children only, so if the order of children is changed, you need to swap 1 and 2 in update_data ().

The downside now it that setting the "marker" property adds another set of markers, as I described above, but now only to the main figure, not the legend. (see attachment "markertest3.pdf")

  Jarno


(file #20345, file #20346, file #20347)

Anonymous
Tue 27 Apr 2010 12:26:43 AM UTC, comment #19: 

Jarno,

Are you using Aquaterm on OSX?

If so, its markers are larger than those of gnuplot's other terminals.

I'm not sure we want to fix that problem here in Octave.

Ben Abbott <bpabbott>
Group Member
Mon 26 Apr 2010 11:51:03 PM UTC, comment #18: 


> set (h1, "markersize", 6)


In my system I need to us markersize 3 instead of 6 to get the "normal" size. I.e. 6 is way too big. The markers I get automatically seem to be of the size 3.

  Jarno

Anonymous
Mon 26 Apr 2010 10:04:41 PM UTC, comment #17: 

David,

I added support for matlab's markers.

Ben

(file #20344)

Ben Abbott <bpabbott>
Group Member
Mon 26 Apr 2010 09:36:49 PM UTC, comment #16: 

anonymous wrote:

> Follow-up Comment #14, bug #29057 (project octave):
>
> David,
>
> In your code below, I needed to do h(1) = errorbar... and h(2) = errorbar..
> to get it to work.
>
> Also, if you look carefully at your posted figure, you'll notice that the "o"
> marks in the main lines have a "x" mark superimposed. The fact is that without
> any given format the errorbar currently automatically cycles through some
> default set of markers. It appears to me that setting the marker as you
> proposed will set the marker for the line, that then gets copied on to the
> legend (as it should). However, now the points and the line both have markers,
> and in the case of the other line, they do not agree. Do you know how to get
> rid of these double markers?
>


Now that is wierd.. Still haven't figured it out

> Also, on my system the markers added via the set() show up as way too large.
> I guess there is something from with the marker size setting?


set (h1, "markersize", 6)

D.

David Bateman <dbateman>
Group Member
Mon 26 Apr 2010 09:16:30 PM UTC, comment #15: 

David,

I haven't tried it yet, but the changeset you attached looks good to me.

Perhaps a few more demos should be added?

Ben

Ben Abbott <bpabbott>
Group Member
Mon 26 Apr 2010 09:09:14 PM UTC, comment #14: 

David,

In your code below, I needed to do h(1) = errorbar... and h(2) = errorbar.. to get it to work.

Also, if you look carefully at your posted figure, you'll notice that the "o" marks in the main lines have a "x" mark superimposed. The fact is that without any given format the errorbar currently automatically cycles through some default set of markers. It appears to me that setting the marker as you proposed will set the marker for the line, that then gets copied on to the legend (as it should). However, now the points and the line both have markers, and in the case of the other line, they do not agree. Do you know how to get rid of these double markers?

Also, on my system the markers added via the set() show up as way too large. I guess there is something from with the marker size setting?

Anonymous
Mon 26 Apr 2010 09:08:05 PM UTC, comment #13: 

Ok, yes the matlab linestyles "-+" and "-*" should set the marker as well. See the attached changeset. This also means a linestyle line "~+" or even ">+" should give you what you want

D.


(file #20341)

David Bateman <dbateman>
Group Member
Mon 26 Apr 2010 08:47:38 PM UTC, comment #12: 

The "~" marker in octave just means use yerr bars, it was the "@" marker that was an octave feature that cycled through the markers. This was removed I think in 3.1.x series sometime when the graphic properties were worked on and temporarily readded a few months ago till it became obvious that using a 1x3 value in colororder and a linestyleorder property is the matlab compatible way of implementing this. There is no octave feature that cycles through the markers in the development version of Octave.

The errorbar series hggroup has a marker property and it can be set. For an examplem try

x = 0:0.5:2*pi;
err = x/100;
y1 = sin (x);
y2 = cos (x);
errorbar (x, y1, err)
hold on;
h = errorbar (x, y2, err);
set (h(1), "marker", "+")
set (h(2), "marker", "o")
hold off;
legend ('left')
legend ('sin', 'cos', 'location', 'southwest')
print -dpng errorbars2.png

and hey look, the legend has the markers..

D.



David Bateman <dbateman>
Group Member
Mon 26 Apr 2010 08:44:30 PM UTC, comment #11: 

While the proposed patches allow explicit setting of color for error plots, the fact still remains that I can't get the legend to show the markers for errorbar. Please note that for a corresponding "plot" (leaving out the error arguments), the legend does show the markers as expected.

For example (assuming the definitions from my example in the original bug report):

plot (x, y1, "-*", x, y2, "-+");
legend("left");
legend("sin", "cos", "location", "southwest");

This produces markers in the legend as well as in the main figure.

However,

errorbar (x, y1, err, "-*", x, y2, err, "-+");
legend("left");
legend("sin", "cos", "location", "southwest");

Produces a legend without the markers. The patch you gave below allows the markers to show in the main figure without using the Octave-specific "~".

Anonymous
Mon 26 Apr 2010 08:20:10 PM UTC, comment #10: 

Ben,

I suppose we could do something like the attached of the error you're seeing, and it would ensure compatibility with the matlab way of doing things, so why not

D.


(file #20339)

David Bateman <dbateman>
Group Member
Mon 26 Apr 2010 08:11:25 PM UTC, comment #9: 

Soren sees no markers in the figure neither, so the fact that "the markers" are "missing" from the legend is a moot point. He should run code that produces markers in the figure, then see if they ALSO show in the legend.

Also, as my example uses "~", which is an Octave feature, that automatically cycles through different markers, maybe the Matlab behavior is less significant?

Also, as my originally included modified _errplot_.m demonstrates, gnuplot is perfectly capable to reproduce markers both in the lines and the legend.

So, no, in my opinion the bug is not closed. I'd propose you close this bug as soon as you give a counter-example that has different markers on each errorbar line, and also reproduces those markers on the legend. I'd be happy to change my code instead of changing Octave.

With regards,

  Jarno Rajahalme

Anonymous
Mon 26 Apr 2010 08:00:41 PM UTC, comment #8: 

Ben,

The code in _pltopt_ for the errorbar plots is

  if (strcmp (caller,"__errplot__"))
    if (strncmp (opt, "#~>", 3))
      n = 3;
    elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2))
      n = 2;
    elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1)
            || strncmp (opt, "#", 1))
      n = 1;
    endif
    options.linestyle = opt(1:n);
    opt(1:n) = [];
    have_linestyle = true;
  endif

Where "options.linestyle = opt(1:n);" is line 158... Only the linestyles above are valid in Octave's errorbar function, as these are used to define if yerr,xerr,xyerr or box plots are used. We shouldn't fail in such a horrid way, but should we accept other linestyles than the above and if so do we assume yerr style for the errorbars?

D.

David Bateman <dbateman>
Group Member
Mon 26 Apr 2010 07:54:22 PM UTC, comment #7: 

So Soren sees no markers in the legend with matlab.... Do this close this bug?

D.


David Bateman <dbateman>
Group Member
Mon 26 Apr 2010 07:37:24 PM UTC, comment #6: 

The following does work for Matlab, but not for Octave.

octave:7> errorbar (x, y1, err, '-r')
error: `n' undefined near line 158 column 31
error: invalid limit value in colon expression
error: evaluating argument list element number 1
error: called from:
error:   /Users/bpabbott/Development/mercurial/local_clone/scripts/plot/private/__pltopt__.m at line 158, column 23
error:   /Users/bpabbott/Development/mercurial/local_clone/scripts/plot/private/__pltopt__.m at line 113, column 28
error:   /Users/bpabbott/Development/mercurial/local_clone/scripts/plot/private/__errplot__.m at line 35, column 15
error:   /Users/bpabbott/Development/mercurial/local_clone/scripts/plot/private/__errcomm__.m at line 54, column 23
error:   /Users/bpabbott/Development/mercurial/local_clone/scripts/plot/errorbar.m at line 125, column 9

Ben Abbott <bpabbott>
Group Member
Mon 26 Apr 2010 07:02:21 PM UTC, comment #5: 

Okay, I did

  x = 0:0.5:2*pi;
  err = x/100;
  y1 = sin (x);
  y2 = cos (x);
  errorbar (x, y1, err)  
  hold on, errorbar (x, y2, err), hold off
  legend ('left')
  legend ('sin', 'cos', 'location', 'southwest')
  print -dpng errorbars.png

and I got the attached result.


Søren Hauberg <hauberg>
Mon 26 Apr 2010 06:34:48 PM UTC, comment #4: 

If I do

  errorbar (x, y1, err, '~', x, y2, err, '~')

in Matlab 2010a, I get the following error

  ??? Error using ==> errorbar at 47
  Incorrect number of inputs for property-value pairs.

My guess is that Matlab doesn't allow several plots to be given in one line, so I tried

  errorbar (x, y1, err, '~')

which gives me this error

  ??? Error using ==> errorbar at 47
  Error in color/linetype argument.
 
So, somebody needs to change the example if I should run it in Matlab.

Søren Hauberg <hauberg>
Mon 26 Apr 2010 11:59:47 AM UTC, comment #3: 

Look at the page

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/errorbarseriesproperties.html

describing an errorbar series.. As you'll see an errorbar plot is an hggroup object with several opaque grahics objects wrapped in it. In matlab these are all line objects, but octave uses the gnuplots errorbar functionality hidden opaquely in the hggroup so the child objects of the hggroup are not the same between Octave and Matlab.

When I implemented errorbar series 2 years ago, I hesitated to have a single octave _line_ object as the child of the hggroup. However, if I remember correctly, matlab doesn't plot the markers of the error bar plot in the legend, and so I deliberately added a second line object that just plotted the line essentially for use in the legend for compatibility with matlab.

So the question is not that Octave doesn't plots a marker in the legend, but rather whether this is the correct behavior.. I believe if you try the same in matlab you'll get the same behavior as Octave currently has. So I don't see this as a bug, but rather the expected behavior.

As I don't have access to matlab to test I can't however close this bug as I can't confirm the above. Does someone want to run the command in the first comment to this bug report and see whether matlab plots the markers in the legend or not?

D.

David Bateman <dbateman>
Group Member
Sun 25 Apr 2010 09:54:55 PM UTC, comment #2: 

I can confirm this bug.  Unfortunately the problem is a bit more involved than I first thought.  The yerrorbar lines are being assigned their own own marker style instead of using "none".

The points, such as squares or asterisks, are not associated with the _line_ object at line 150 of the m-file.

The legend command is correctly picking the style from the _line_ object.  This can be verified by setting the marker to some shape and the legend will update to reflect the new shape.

Unfortunately, there will now be two shapes for every data point.  One from the _line_ drawn through the points and one at each point created by the yerrorbars.  The two shapes need not be the same which leads to chaos on the plot.

Rik <rik5>
Group administrator
Sun 25 Apr 2010 09:49:48 PM UTC, comment #1: 

The existing behavior seems to be consist with matlab. At least as far as I can see from surfing mathcentral, etc (I no longer have access to matlab), though I'd be happy if some else can confirm this with Jarno's example.

Should we change Octave's behavior? I suggest that we don't fix this.

D.


David Bateman <dbateman>
Group Member
Wed 03 Mar 2010 08:32:51 PM UTC, original submission:  

(NOTE: The "Release" selection for the bug tracker is obsolete, as it stops at 3.1.55)

I found a bug in the plotting of errorbars in Octave (3.2.3) (with GNUplot 4.2 patchlevel 5).

The problem is that the legend lines are printed without the markers used in the plot itself. Here is the test code I used:

x = 0:0.5:2*pi;
err = x/100;
y1 = sin (x);
y2 = cos (x);
errorbar (x, y1, err, "~", x, y2, err, "~");
legend("left");
legend("sin", "cos", "location", "southwest");


With my Octave (without modifications) the legend lines have no markers.

I found a problem in _errplot_.m, where for each plotline, two separate lines are created. The problem has something to do with which line is created first, as the legend commands seem to refer to the last one. I first tried adding markers also for that line, but that did not work. Then I moved the creation of the solid line before the errorbar-line, and changed the _line_ call at the end to a set of set() commands. However, if I set the "parent" property, the old behavior is back. So now the set("parent") is commented out.

I have to submit a camera-ready paper this week, so I had to figure out what to do. I have no idea if my modifications have unforeseen consequences, but for now it seems to work.

See the attached _errplot_.m. Changes commented with %% HACK FIX
I hope you could fix the Octave code, so that I would not need to maintain this change for myself.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #20360:  changeset.errorbar_listener added by dbateman (4KiB - application/octet-stream)
file #20353:  changeset.errorbar_markers added by dbateman (2KiB - application/octet-stream)
file #20352:  changeset.errorstyle added by dbateman (5KiB - application/octet-stream)
file #20348:  patch.bug_29057 added by rik5 (1KiB - application/octet-stream)
file #20345:  markertest.pdf added by None (6KiB - application/pdf)
file #20346:  markertest2.pdf added by None (4KiB - application/pdf)
file #20347:  markertest3.pdf added by None (6KiB - application/pdf)
file #20344:  changeset.patch added by bpabbott (3KiB - application/octet-stream - changeset supporting matlab style makers)
file #20341:  changeset.errorbar_linestyle2 added by dbateman (2KiB - application/octet-stream)
file #20340:  errorbars2.png added by dbateman (13KiB - image/png)
file #20339:  changeset.errorbar_linestyle added by dbateman (2KiB - application/octet-stream)
file #20338:  errorbars.png added by hauberg (11KiB - image/png)
file #19844:  __errplot__.m added by None (7KiB - application/octet-stream - Changes commented with %% HACK FIX )

 

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 bpabbott (Posted a comment)
  • -email is unavailable- added by hauberg (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dbateman (Posted a comment)
  • -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 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-04-28 dbateman Attached File- Added changeset.errorbar_listener, #20360
    2010-04-28 dbateman Attached File- Added changeset.errorbar_markers, #20353
        StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2010-04-27 dbateman Attached File- Added changeset.errorstyle, #20352
    2010-04-27 rik5 Attached File- Added patch.bug_29057, #20348
    2010-04-27 None Attached File- Added markertest.pdf, #20345
        Attached File- Added markertest2.pdf, #20346
        Attached File- Added markertest3.pdf, #20347
    2010-04-26 bpabbott Attached File- Added changeset.patch, #20344
    2010-04-26 dbateman Attached File- Added changeset.errorbar_linestyle2, #20341
    2010-04-26 dbateman Attached File- Added errorbars2.png, #20340
    2010-04-26 dbateman Attached File- Added changeset.errorbar_linestyle, #20339
    2010-04-26 hauberg Attached File- Added errorbars.png, #20338
    2010-04-25 rik5 StatusNone Confirmed
    2010-03-03 None Attached File- Added _errplot_.m, #19844

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code