bugGNU Octave - Bugs: bug #51759, demo ("axis", 3) fails...

 
 

bug #51759: demo ("axis", 3) fails with gnuplot

Submitter:  Avinoam Kalma <avinoam>
Submitted:  Tue 15 Aug 2017 06:11:28 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 23 Aug 2017 10:22:57 PM UTC, comment #10: 

I pushed your cset here (http://hg.savannah.gnu.org/hgweb/octave/rev/fe780a4b89c1).  It's true, I prefer to avoid for loops so I used the version with repmat.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Wed 23 Aug 2017 05:39:06 AM UTC, comment #9: 

The construct I wrote is intended.  That's the "if labels is empty" part.  Bit of a trick I suppose since it incorporates the conditional in the syntax.


labels(end+1:1) = {""};


is the same as


if (isempty(labels))
  labels = {""};


or


if (length (labels) == 0)
  labels = {""};


The bug is that labels can't be empty or the loop will fail.

The preference for patch 41540 or 41542 is up to you.  I know you like to get rid of loops whenever possible, so I thought you might like 41542.

Dan Sebald <sebald>
Wed 23 Aug 2017 05:12:32 AM UTC, comment #8: 

For Matlab compatibility, axis labels should repeat.  The motivating example in comment #5 works for me already.  Ticklabels are correctly repeated even without this patch.  I don't know why that is, but I'm happy to commit the patch if it fixes problems for others.

Could you take a look at this line


+    labels(end+1:1) = {""};


Why use a range here?  Why not


+    labels(end+1) = {""};




Rik <rik5>
Group administrator
Sat 19 Aug 2017 06:25:44 PM UTC, comment #7: 

Changing status to to "Patch Reviewed".

@Maintainers: Please push the patch

Avinoam Kalma <avinoam>
Group Member
Fri 18 Aug 2017 05:03:33 AM UTC, comment #6: 

Last patch also fixes this problem. Thanks!

Avinoam Kalma <avinoam>
Group Member
Wed 16 Aug 2017 04:22:24 PM UTC, comment #5: 

Oh, an example for comparison in the most general case:


graphics_toolkit gnuplot;
figure;
plot(1:50);
set(gca,'xticklabel', {'a','b';'c','d'});

graphics_toolkit fltk;
figure;
plot(1:50);
set(gca,'xticklabel', {'a','b';'c','d'});


Dan Sebald <sebald>
Wed 16 Aug 2017 04:20:14 PM UTC, comment #4: 

If one prefers compactness of code and removing the conditional test on k, here's another patch that uses repmat() to repeat labels.

(file #41542)

Dan Sebald <sebald>
Wed 16 Aug 2017 04:08:59 PM UTC, comment #3: 

Regarding the repetition of labels, i.e., resetting k.  I was thinking about this a bit.  Perhaps the wrap is intended; say, something like:


graphics_toolkit gnuplot;
figure;
plot(1:50);
set(gca,'xticklabel', {'|'});

graphics_toolkit fltk;
figure;
plot(1:50);
set(gca,'xticklabel', {'|'});


So, just to make the wrap behavior consistent with FLTK/Qt toolkits, I'm attaching a new patch that simple adds one blank label if there are no labels.

(file #41540)

Dan Sebald <sebald>
Wed 16 Aug 2017 10:48:24 AM UTC, comment #2: 

Thank you very much for the fix. This patch solves the problem.
I checked it with "compare_plot_demos" and I did not see new
problems.

@maintainers: Please push this patch

Avinoam Kalma <avinoam>
Group Member
Wed 16 Aug 2017 06:35:35 AM UTC, comment #1: 

I see the error, but Octave isn't freezing on my linux machine.  (I don't quite have the latest code because compiling is failing here at the moment.)  Typically the gnuplot toolkit pipe gets out of synch with this type of error.

Try the attached patch.  It supplies missing labels as empty strings.  This seems to the most code efficient way of doing things.

Rik, can you think of any reason that the index k (in the patch) should wrap around to the front and start repeating labels?  I would think that simply leaving the last ones blank is the better result.

Also, the error message gives array notation

labels(1): out of bound 0

when labels was indexed as a cell, i.e., labels{k++}.  My first instinct was to grep for "labels(" or "labels (".  It didn't take long to figure out "labels{" was the syntax to search for.  It might be convenient for the user to see round or curly bracket depending on the use that caused the error.

(file #41539)

Dan Sebald <sebald>
Tue 15 Aug 2017 06:11:28 PM UTC, original submission:  



>> graphics_toolkit gnuplot
>> demo ("axis", 3)
axis example 3:
clf;
t = 0:0.01:2*pi;
x = sin (t);

subplot (331);
  plot (t, x);
  title ("x ticks and labels");
  axis ("ticx");

......

subplot (338);
  plot (t, x);
  title ("y ticks, no labels");
  axis ("nolabel","ticy");

subplot (339);
  plot (t, x);
  title ("all ticks and labels");
  axis ("on");

axis example 3: failed
labels(1): out of bound 0

>>  demo ("axis", 3)
           line 12: undefined variable: set

OCTAVE:  cairolatex canvas cgm context corel domterm dumb dxf eepic emf emtex epscairo epslatex fig hpgl latex mf mp
pcl5 pdfcairo pngcairo postscript pslatex pstex pstricks qms svg texdraw tgif tkcanvas tpic unknown windows wxt


After the second command, Octave hangs.

Avinoam Kalma <avinoam>
Group Member

 

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

Attach Files:
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sebald (Updated the item)
  • -email is unavailable- added by avinoam (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-23 rik5 StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2017-08-19 avinoam StatusPatch Submitted Patch Reviewed
    2017-08-16 sebald Attached File- Added octave-missing_gnuplot_axis_labels_remove_k_loop-djs2017aug16.patch, #41542
    2017-08-16 sebald Attached File- Added octave-missing_gnuplot_axis_labels_smallest_code_change-djs2017aug16.patch, #41540
    2017-08-16 avinoam StatusNone Patch Submitted
        Operating SystemAny Microsoft Windows
    2017-08-16 sebald Attached File- Added octave-missing_gnuplot_axis_labels-djs2017aug16.patch, #41539

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code