Menu ▾ ▴

#4424 draw2d doesnt accept fill_density in order to create opaque shapes

None
closed
nobody
5
2025-02-18
2024-11-27
No

The following code:

(%i1)draw2d
(
    title = "fill\\_density does not work",
    proportional_axes = 'xy,
    grid   = true,
    xrange = [-4, 0],
    yrange = [-3, 3],
    xlabel = "Re(h λ)",
    ylabel = "Im(h λ)",
    key = "stability region",
    transparent = false,
    color       = blue,
    line_width  = 1,
    fill_color  = light_pink,
    fill_density = 0.1,
    nticks = 80,
    ellipse(-1, 0, 1, 1, 0, 360)
);

doesn't produce the right appearance using the alpha-channel on GNUplot. Error is the following:

gnuplot> plot '/var/folders/5w/f2d_lxbd6ljfpccm36g61sb0qjr9n_/T/data18376.gnuplot' index 0 t 'stability region' w filledcurves fillstyle solid 0.1 xy=-1.0,0.0 lc rgb '#FFB6C1' axis x1y1,'/var/folders/5w/f2d_lxbd6ljfpccm36g61sb0qjr9n_/T/data18376.gnuplot' index 1 t '' w l lw 1.0 lt 1 lc rgb '#0000FF' axis x1y1
                                                                                                                                                   ^
         "/var/folders/5w/f2d_lxbd6ljfpccm36g61sb0qjr9n_/T/maxout18376.gnuplot" line 41: unexpected or unrecognized token: xy

Build-info:

(%i2) build_info();
(%o2)
Maxima-version: "5.47.0"
Maxima build date: "2024-04-01 17:37:51"
Host type: "x86_64-apple-darwin21.6.0"
Lisp implementation type: "SBCL"
Lisp implementation version: "2.4.3"
User dir: "/Users/mlomonaco/.maxima"
Temp dir: "/var/folders/5w/f2d_lxbd6ljfpccm36g61sb0qjr9n_/T"
Object dir: "/Users/mlomonaco/.maxima/binary/5_47_0/sbcl/2_4_3"
Frontend: false

Image produced attached.

1 Attachments

Discussion

  • Marco Lo Monaco

    Marco Lo Monaco - 2024-11-27

    Tried to run manually within gnuplot its compiled line above and omitted the xy=-1.0,0.0 and it seems to work. So it's not a Gnuplot issue, rather some leftover xy tag in the lisp code.

     
  • Leo Butler

    Leo Butler - 2024-11-28

    I have attached the gnuplot file that a pared-down MNWE creates.

    Before ripping out the offending code, I have asked the gnuplot developers for clarification on the history and possible meaning of xy=. According to our git repository, the offending code has been in the draw package from its original commit, 18 years ago.

     
  • Tomio Arisaka

    Tomio Arisaka - 2024-11-29
    (%i2) ? fill_density
    
    
     -- Graphic option: fill_density
         Default value: 0
    
         ‘fill_density’ is a number between 0 and 1 that specifies the
         intensity of the ‘fill_color’ in ‘bars’ objects.
    
         See ‘bars’ for examples.
    
    (%o2)                                true
    

    So, I guess fill_density in ellipse objects has not been checked.

    About filledcurves xy=, see:
    https://gnuplot.sourceforge.net/docs_5.4/Gnuplot_5_4.pdf#section*.110

    Therefore, next command works:

    plot '/tmp/data2675.gnuplot' index 0 notitle w filledcurves xy=-1.0,0.0 fillstyle solid 0.1 lc rgb '#FFB6C1' axis x1y1,'/tmp/data2675.gnuplot' index 1 t '' w l lw 1 lt 1 lc rgb '#0000FF' axis x1y1
    
     
  • Tomio Arisaka

    Tomio Arisaka - 2024-11-30

    Thanks, Leo.

    I saw your patch, then I noticed that your modified strings are different :)
    " ~a w filledcurves xy=~a,~a ~alc ~a axis ~a"
    " ~a w filledcurves xy=~a,~a ~a lc ~a axis ~a"

    By the way, a potential problem is here:

    @@ -1359,7 +1359,7 @@
                  (setf result-array (make-array (length result)
                                                 :element-type 'flonum 
                                                 :initial-contents result))
    
    -             (setf pltcmd (format nil " ~a w filledcurves~a x1 lc ~a axis ~a"
    +             (setf pltcmd (format nil " ~a w filledcurves x1 ~a lc ~a axis ~a"
                                           (make-obj-title (get-option '$key))
                                           (format nil "~@[ fillstyle solid ~a~]" (get-option '$fill_density))
                                           (hex-to-rgb (get-option '$fill_color))
    

    (This patch fixes the following issue. So, were you able to append this to your patch?)

    The next example reproduces the error:

    (%i1) draw2d(fill_color  = red,
                 filled_func = true,
                 fill_density = 0.5,
                 explicit(-sin(x),x,0,%pi));
    (%o1)                          [gr2d(explicit)]
    (%i2) 
    gnuplot> plot '/var/folders/58/sd7gn5sn04dc1gg55cmx6vg40000gn/T/data1823.gnuplot' index 0 notitle w filledcurves fillstyle solid 0.5 x1 lc rgb '#FF0000' axis x1y1
                                                                                                                                         ^
             "/var/folders/58/sd7gn5sn04dc1gg55cmx6vg40000gn/T/maxout1823.gnuplot" line 39: unexpected or unrecognized token: x1
    
     
  • Robert Dodier

    Robert Dodier - 2024-12-01
    • labels: --> draw, draw2d, fill_density, gnuplot
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2024-12-01

    I've applied the patches posted by Leo and Tomio, thanks a lot. I also added the examples shown in this bug report to share/draw/rtest_draw.mac. I pushed those changes as commit 1a034e4. Closing this ticket as fixed.

     
  • Marco Lo Monaco

    Marco Lo Monaco - 2025-02-18

    Sorry to check back on this: I brewed maxima on MacOS Sequoia and I dont see the fix being kicked in.

    Maxima-version: "5.47.0"
    Maxima build date: "2025-01-31 22:49:26"
    Host type: "x86_64-apple-darwin23.6.0"
    Lisp implementation type: "SBCL"
    Lisp implementation version: "2.5.1"
    User dir: "/Users/mlomonaco/.maxima"
    Temp dir: "/var/folders/5w/f2d_lxbd6ljfpccm36g61sb0qjr9n_/T"
    Object dir: "/Users/mlomonaco/.maxima/binary/5_47_0/sbcl/2_5_1"
    Frontend: false
    

    Brew says:

    ==> maxima: stable 5.47.0 (bottled)
    Computer algebra system
    https://maxima.sourceforge.io/
    Installed
    /usr/local/Cellar/maxima/5.47.0_18 (2,922 files, 116MB) *
      Poured from bottle using the formulae.brew.sh API on 2025-02-17 at 17:09:12
    From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/m/maxima.rb
    License: GPL-2.0-only
    ==> Dependencies
    Build: gawk ✔, gnu-sed ✘, perl ✔, texinfo ✔
    Required: gettext ✔, gnuplot ✔, rlwrap ✔, sbcl ✔
    ==> Caveats
    Emacs Lisp files have been installed to:
      /usr/local/share/emacs/site-lisp/maxima
    ==> Analytics
    install: 823 (30 days), 2,451 (90 days), 9,840 (365 days)
    install-on-request: 744 (30 days), 2,246 (90 days), 8,780 (365 days)
    build-error: 0 (30 days)
    
     
  • Leo Butler

    Leo Butler - 2025-02-18

    The fix will be in a post 5.47.0 release. That has not been made yet.

     

Log in to post a comment.