bugGNU Octave - Bugs: bug #55859, [octave forge] (signal) zplane.m...

 
 

bug #55859: [octave forge] (signal) zplane.m multiplicity annotations should not use superscript

Submitter:  Robert Jenssen <morgawr>
Submitted:  Fri 08 Mar 2019 12:42:36 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 25 Apr 2019 03:47:53 AM UTC, comment #14: 

The gnuplot toolkit does not allow me to work out text spacing (bug #56174) so here is a simple patch:


--- signal-1.4.1/inst/zplane.m        2019-02-09 09:00:37.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-04-25 13:28:30.542608642 +1000
@@ -115,8 +115,9 @@
       for i = 1:length (x_u)
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
-          label = sprintf (" ^%d", n);
-          text (real (x_u(i)), imag (x_u(i)), label, "color", color);
+          label = sprintf ("%d", n);
+          text (real (x_u(i)), imag (x_u(i)), label, "color", color, ...
+                "verticalalignment", "bottom", "horizontalalignment", "left");
         endif
       endfor
     endfor


Robert Jenssen <morgawr>
Mon 11 Mar 2019 11:24:31 AM UTC, comment #13: 

The new attached patch is better but still not quite right. Perhaps  plotboxaspectratio includes the axis labels? Compare
zplane([-1;-1;j;-j],[1;1;1]) and zplane([-2+j;-2+j],[2;2;2])

(file #46493)

Robert Jenssen <morgawr>
Sun 10 Mar 2019 12:49:31 PM UTC, comment #12: 

FYI I tried this patch:

--- octave-signal-f050d888e7efe5327e5ed702aed77a8d24448616/inst/zplane.m        2019-03-07 15:02:59.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-03-10 23:40:01.103212038 +1100
@@ -108,15 +108,30 @@
     colors = get (gca (), "colororder");
     for c = 1:columns (x)
       color = colors(mod (c, rows (colors)), :);
-      plot (real (x(:,c)), imag (x(:,c)), "color", color, ...
+      h=plot (real (x(:,c)), imag (x(:,c)), "color", color, ...
             "linestyle", "none", "marker", symbol);

+      % The marker is centred at x. The "markersize" property of the
+      % plot is in points. Scale markersize/2 to the range of the x-axis.
+      marker_size_points = get(h,"markersize");
+      x_range = diff(get(gca(),"xlim"));
+      current_units = get(gca(),"units");
+      current_activepositionproperty=get(gca(),"activepositionproperty");
+      set(gca(),"activepositionproperty","position");
+      set(gca(),"units","points");
+      current_position = get(gca(),"position");
+      set(gca(),"units",current_units);
+      set(gca(),"activepositionproperty",current_activepositionproperty);
+      x_range_points = current_position(3);
+      xshift = 1.5 * (marker_size_points/2) * (x_range/x_range_points);
+
       x_u = unique (x(:,c));
       for i = 1:length (x_u)
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
-          label = sprintf (" ^%d", n);
-          text (real (x_u(i)), imag (x_u(i)), label, "color", color);
+          label = sprintf ("%d", n);
+          text (real (x_u(i)) + xshift, imag (x_u(i)), label, ...
+                "color", color, "verticalalignment", "bottom");
         endif
       endfor
     endfor


My guess is that, regardless of the value of "activepositionproperty", get(gca(),"position") returns the size of the window rather than the plot. I suspect that this is a bug.

Robert Jenssen <morgawr>
Sun 10 Mar 2019 08:14:00 AM UTC, comment #11: 

Here is a patch that combines text shift in x and verticalalignment:

--- octave-signal-f050d888e7efe5327e5ed702aed77a8d24448616/inst/zplane.m        2019-03-07 15:02:59.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-03-10 18:40:55.529778490 +1100
@@ -115,8 +115,10 @@
       for i = 1:length (x_u)
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
-          label = sprintf (" ^%d", n);
-          text (real (x_u(i)), imag (x_u(i)), label, "color", color);
+          label = sprintf ("%d", n);
+          xshift = 0.015 * diff (get (gca, "xlim"));
+          text (real (x_u(i)) + xshift, imag (x_u(i)), label, ...
+                "color", color, "verticalalignment", "bottom");
         endif
       endfor
     endfor


Unfortunately, with this change the multiplicity annotation is not placed consistently for different sized axes. For example, if two zeros are at -2. The markersize property is 6 points. When I resize a figure window I see that the screen size of the marker remains constant (as expected if there is no callback that changes the markersize to match the new window size). To correctly space the multiplicity annotation I'd have to be able to find the difference between the axis x limits in points. I don't know how to do this in the current Octave. For example:

octave:1> h=plot (1/2, 1/2, "linestyle", "none", "marker", "x");
octave:2> cu=get(gca(),"units")
cu = normalized
octave:3> get(gca(),"xlim")
ans =

   0.44000   0.58000

octave:4> get(gca(),"position")
ans =

   0.13000   0.11000   0.77500   0.81500

octave:5> set(gca(),"units","points")
octave:6> get(gca(),"xlim")
ans =

   0.44000   0.58000

octave:7> get(gca(),"position")
ans =

    54.576    34.635   325.358   256.613


When I change the units the "xlim" doesn't change. When I resize the figure window, the "position" doesn't change. This seems to me to be a bug.

Robert Jenssen <morgawr>
Sat 09 Mar 2019 05:46:36 PM UTC, comment #10: 

I do want to be somewhat Matlab compatible in how the labels are attached to the figure. I know that Matlab sets VerticalAlignment to 'bottom', and adds an offset to the X coordinate of the position. It should be a combination of comment #9 and your patch in file #46473. It would be better if you didn't have to pass an extra parameter into the plot_with_labels function. Inside the function you can 'get (gca, "xlim")', for example, 'diff (get (gca, "xlim"))' is an easy way to get the X range.

Mike Miller <mtmiller>
Group Member
Sat 09 Mar 2019 02:44:46 AM UTC, comment #9: 

Sorry, of course that should have been:

--- octave-signal-f050d888e7efe5327e5ed702aed77a8d24448616/inst/zplane.m        2019-03-07 15:02:59.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-03-09 13:08:41.000000000 +1100
@@ -115,8 +115,9 @@
       for i = 1:length (x_u)
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
-          label = sprintf (" ^%d", n);
-          text (real (x_u(i)), imag (x_u(i)), label, "color", color);
+          label = sprintf ("%d", n);
+          text (real (x_u(i)), imag (x_u(i)), label, "color", color, ...
+                "horizontalalignment", "left", "verticalalignment", "bottom");
         endif
       endfor
     endfor


Robert Jenssen <morgawr>
Sat 09 Mar 2019 02:33:48 AM UTC, comment #8: 

I forgot to mention that I prefer the patch in the last comment to:

--- octave-signal-f050d888e7efe5327e5ed702aed77a8d24448616/inst/zplane.m        2019-03-07 15:02:59.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-03-09 13:04:49.999031619 +1100
@@ -116,7 +116,8 @@
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
           label = sprintf (" ^%d", n);
-          text (real (x_u(i)), imag (x_u(i)), label, "color", color);
+          text (real (x_u(i)), imag (x_u(i)), label, "color", color, ...
+                "horizontalalignment", "right", "verticalalignment", "top");
         endif
       endfor
     endfor


I don't have access to Matlab so I don't know what that looks like.

Robert Jenssen <morgawr>
Sat 09 Mar 2019 01:53:49 AM UTC, comment #7: 

I don't have access to Matlab. The attached patch of inst/zplane.m works for me on my local octave-5.1.0(gnuplot), Fedora octave.x86_64 (6:4.2.2-6.fc29.1) and Win10 octave-5.1.0-w64-installer.exe.

(file #46473)

Robert Jenssen <morgawr>
Fri 08 Mar 2019 11:33:24 PM UTC, comment #6: 

The multiplicity number should be above and to the right of the pole or zero marker. That was the point of using the superscript operator.

But I've since learned that Matlab adds the marker as a plain number, and uses the position and verticalalignment properties to make it appear above and to the right of the marker.

Mike Miller <mtmiller>
Group Member
Fri 08 Mar 2019 11:00:27 PM UTC, comment #5: 

Sure. What is the purpose of the vertical spacing?

Robert Jenssen <morgawr>
Fri 08 Mar 2019 06:56:23 PM UTC, comment #4: 

This should be fixed to use the 'verticalalignment' property, and add a little spacing to the x coordinate of each text label. The label should be only the digit, no extra space. Would you like to look at working up a patch like that?

Mike Miller <mtmiller>
Group Member
Fri 08 Mar 2019 06:46:30 PM UTC, comment #3: 

Yeah, I think the annotation should be fixed to not use a superscript. That and the extra space were quick hacks that should be done better.

Mike Miller <mtmiller>
Group Member
Fri 08 Mar 2019 04:51:23 AM UTC, comment #2: 

There seem to be inconsistencies in the way latex math strings are treated
in the pdflatex and svg printer devices. Perhaps a simple way to avoid my
problem would be to not use the latex '^' math operator in zplane.m?

With the inst/zplane.m from
octave-signal-f050d888e7efe5327e5ed702aed77a8d24448616.zip
I get:

$ octave-cli
GNU Octave, version 5.1.0
Copyright (C) 2019 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> clear all
octave:2> pkg load signal
octave:3> graphics_toolkit("gnuplot")
octave:4> zplane([-1;-1;j;-j],[1;1;1])
octave:5> print("t","-dsvg")
octave:6> print("t","-dpdflatex")
warning: latex markup not supported for tick marks
warning: called from
    __gnuplot_draw_axes__>do_tics_1 at line 2257 column 7
    __gnuplot_draw_axes__>do_tics at line 2191 column 5
    __gnuplot_draw_axes__ at line 391 column 3
    __gnuplot_draw_figure__ at line 164 column 17
    __gnuplot_drawnow__ at line 43 column 9
    __gnuplot_print__>local_drawnow at line 232 column 5
    __gnuplot_print__ at line 144 column 9
    print at line 692 column 14
octave:7>


With the following tt.tex:

\documentclass[10pt]{report}
\usepackage{color}
\usepackage{graphics}
\begin{document}
\begin{figure}
\input{t}
\end{figure}
\end{document}


I get:

$ pdflatex tt
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./tt.tex
LaTeX2e <2018-04-01> patch level 5
(/usr/share/texlive/texmf-dist/tex/latex/base/report.cls
Document Class: report 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)) (./tt.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./t.tex
! Missing $ inserted.
<inserted text>
                $
l.115     \gplfronttext

?


Using the following doesn't keep the spaces in t.tex but tt.tex does compile:

diff -U 3 signal-tip.orig/inst/zplane.m signal-tip/inst/zplane.m
--- signal-tip.orig/inst/zplane.m        2019-03-07 15:02:59.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-03-08 15:26:25.857936802 +1100
@@ -115,7 +115,7 @@
       for i = 1:length (x_u)
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
-          label = sprintf (" ^%d", n);
+          label = sprintf (" %d", n);
           text (real (x_u(i)), imag (x_u(i)), label, "color", color);
         endif
       endfor


BTW, this patch lets me suppress the latex warnings about tick marks on axes:

--- octave-5.1.0/scripts/plot/util/private/__gnuplot_draw_axes__.m        2019-02-24 04:33:37.000000000 +1100
+++ octave-5.1.0.new/scripts/plot/util/private/__gnuplot_draw_axes__.m        2019-03-06 20:44:33.580217435 +1100
@@ -2254,7 +2254,8 @@
     endfor
   elseif (strcmp (interpreter, "latex"))
     if (! warned_latex)
-      warning ("latex markup not supported for tick marks");
+      warning ("Octave:latex-markup-not-supported-for-tick-marks",
+               "latex markup not supported for tick marks");
       warned_latex = true;
     endif
   endif


Robert Jenssen <morgawr>
Fri 08 Mar 2019 01:48:38 AM UTC, comment #1: 

Thanks for the bug report and the patch, but this patch doesn't work for me at all.

Can you show exactly what you're running in Octave with gnuplot to demonstrate the bug in the first place, and that shows it being fixed?

The only thing I see in my testing is additional "$" characters showing up in the on-screen display as well as in all the output formats I've tried.

Mike Miller <mtmiller>
Group Member
Fri 08 Mar 2019 12:42:36 AM UTC, original submission:  

See https://savannah.gnu.org/bugs/index.php?50130#comment2

For inst/zplane.m in the repository version of the signal package
octave-signal-f050d888e7efe5327e5ed702aed77a8d24448616.zip
with the pdflatex device in gnuplot, I need the following patch
to get my LaTeX document to compile:


--- signal-tip.orig/inst/zplane.m        2019-03-07 15:02:59.000000000 +1100
+++ signal-tip/inst/zplane.m        2019-03-08 11:25:06.302971935 +1100
@@ -115,7 +115,7 @@
       for i = 1:length (x_u)
         n = sum (x_u(i) == x(:,c));
         if (n > 1)
-          label = sprintf (" ^%d", n);
+          label = sprintf (" $^%d$", n);
           text (real (x_u(i)), imag (x_u(i)), label, "color", color);
         endif
       endfor


Robert Jenssen <morgawr>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46493:  zplane.m.patch added by morgawr (2KiB - text/x-patch)
file #46473:  zplane.m.patch added by morgawr (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by morgawr (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-11 morgawr Attached File- Added zplane.m.patch, #46493
    2019-03-09 morgawr Attached File- Added zplane.m.patch, #46473
    2019-03-08 mtmiller StatusNeed Info Confirmed
        Summary[octave forge] (signal) zplane.m latex markup needs $ delimiters [octave forge] (signal) zplane.m multiplicity annotations should not use superscript
    2019-03-08 mtmiller StatusNone Need Info
        Releaseother dev
        Summarysignal zplane.m latex markup needs $ delimiters [octave forge] (signal) zplane.m latex markup needs $ delimiters

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code