emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Visuwesh <visuweshm@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] org-plot: Unable to use text xtics with type:2d (+ more) [9.7-pre (N/A @ /home/viz/lib/emacs/straight/build/org/)]
Date: Fri, 24 May 2024 12:21:57 +0000	[thread overview]
Message-ID: <871q5rv1qy.fsf@localhost> (raw)
In-Reply-To: <87cypbjw50.fsf@gmail.com>

Visuwesh <visuweshm@gmail.com> writes:

> Unless I misunderstood the code, the line
>
>       ;; Check type of ind column (timestamp? text?)
>       (when (plist-get params :check-ind-type)
>
> should be
>
>       ;; Check type of ind column (timestamp? text?)
>       (when (plist-get (cdr type) :check-ind-type)
>
> because (1) org-plot/collect-options only adds a select number of
> keywords to the plist and :check-ind-type is not a part of the select
> members, and (2) org-plot/gnuplot is never called with a non-nil value
> for the optional argument PARAMS in tree.

I do not think that it is right.
AFAIU, the idea is that `org-plot/preset-plot-types' provides some
default options, but the user can overwrite these defaults in the #+PLOT
line. What you propose will disregard the values of

 :set :line :map :title :file :ind :timeind :timefmt :textind
 :deps :labels :xlabels :ylabels :xmin :xmax :ymin :ymax :ticks

if they are customized by user in `org-plot/preset-plot-types'.

I believe that the right way to address the problem will be
`org-combine-plists' on the (1) org-plot/preset-plot-types; (2)
org-plot/gnuplot-default-options; (3) #+PLOT lines in the buffer.

> BTW, the earlier check in the function for :data-dump should also fail
> because
>
>     (plist-get (assoc 'grid org-plot/preset-plot-types) :data-dump) ;; => nil
>
> but
>
>     (plist-get (cdr (assoc 'grid org-plot/preset-plot-types)) :data-dump) ;; => non-nil
>
> where type ≡ (assoc 'grid org-plot/preset-plot-types) in
> org-plot/gnuplot.
>
> [ I cannot reproduce the grid example in worg's org-plot.org file, but
>   even with the fix, I cannot reproduce it; more below.  ]

Your concern is valid here. The code is indeed not right.

> The other code smell I see is that the function checks for the PLOT line
> twice.  Once near the beginning of the function, and once just after the
> cleaning up of hline.  Is this simply an oversight?

It is kinda intentional, but broken.

Historically, users can put #+PLOT lines _after_ the table.
However, after refactoring org-table.el, this is no longer working.
See https://list.orgmode.org/orgmode/87o7a0p9ba.fsf@localhost/

> Coming to the grid example, the doc-string of org-plot/preset-plot-types
> options says:
>
>     - :data-dump - Function to dump the table to a datafile for ease of
>       use.
>
>       Accepts lambda function.  Default lambda body:
>       (org-plot/gnuplot-to-data table data-file params)
>
> but in fact, org-plot/gnuplot passes one more argument to the :data-dump
> function:
>
>       ;; Dump table to datafile
>       (let ((dump-func (plist-get type :data-dump)))
>         (if dump-func
> 	    (funcall dump-func table data-file num-cols params)
> 	  (org-plot/gnuplot-to-data table data-file params)))
>
> but here's the catch: the :data-dump function in the grid option expects
> the order
>
>     (lambda (table data-file params _num-cols)
>
> which breaks things down the line.  What should be the actual order
> here?  I looked at the history of those lines briefly using C-x v h but
> I don't have the time to look into it properly to decide on the actual
> argument order.

The best order is de-facto calling convention in the code:

(funcall dump-func table data-file num-cols params)

The docstring and the default value should be fixed accordingly.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2024-05-24 12:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24 11:18 [BUG] org-plot: Unable to use text xtics with type:2d (+ more) [9.7-pre (N/A @ /home/viz/lib/emacs/straight/build/org/)] Visuwesh
2024-05-24 12:21 ` Ihor Radchenko [this message]
2024-05-24 17:19   ` Visuwesh
2024-06-11  5:41     ` Visuwesh
2024-06-12 12:41     ` Ihor Radchenko
2024-06-13  7:04       ` Visuwesh
2024-06-13  7:18         ` Visuwesh
2024-06-15  9:51           ` Ihor Radchenko
2024-06-17  5:06             ` Visuwesh
2024-06-17 17:13               ` Ihor Radchenko
2024-06-18  5:10                 ` Visuwesh
2024-06-18 14:29                   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871q5rv1qy.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=visuweshm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).