Re: [PATCH] updating org-plot.org on worg, was Re: Can we add PLOT to org-element-multiple-keywords?

2024-04-29 Thread Ihor Radchenko
Leo Butler  writes:

> From 4e262898feb349dad2f5b5afe8960c8e09723862 Mon Sep 17 00:00:00 2001
> From: Leo Butler 
> Date: Wed, 24 Apr 2024 12:57:58 -0500
> Subject: [PATCH] org-tutorials/org-plot.org: update documentation and examples

Thanks!
Applied, with minor amendments (I fixed Org repository link to point to
gnu website).
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=36a9f6f18

> Advice sought: The section, 3d grid plots, is tricky:
> example-{4,5,6}.png are not reprocible using the code in the file. I am
> not sure they can even be produced using org-plot and gnuplot as each
> exists now, without some drastic surgery. For example, to produce a
> facsimile of example-5.png, I need something like
>
> #+name: org-mode-figure.gnuplot
> #+header: :var table=org-plot-org-mode-table
> #+begin_src gnuplot :exports none :results none
> unset key
> set xrange [0:16]
> set yrange [0:13]
> plot table matrix with image title 'org mode'
> #+end_src
>
> where `org-plot-org-mode-table' is the un-named table that occurs after
> these figures. Of course, that does not exercise the features of
> org-plot that are intended.
>
> To produce something like example-{4,5}.png, I can do the following (set
> view 15,30 for example-4). But, this example seems like an excursion
> into gnuplot coding. And, again, I am not using "type:grid", despite the
> name of the section.

It indeed looks like we need to use "matrix" in the underlying scripts
and generally fix type:grid option.
CCing Timothy.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Can we add PLOT to org-element-multiple-keywords?

2024-04-26 Thread Jeff Trull
Hi all,

I notice that multiple #+PLOT lines before a table will be coalesced and
handled as one. However, this is
accomplished through specific code in org-plot.el that does a reverse
search through the buffer for
additional lines. org-element has a built-in mechanism for this,
org-element-multiple-keywords. It seems
like it would be useful to add PLOT to it. Can that be done? If not, is
there a way to temporarily add it for
an exporter?

Thanks,
Jeff


[PATCH] updating org-plot.org on worg, was Re: Can we add PLOT to org-element-multiple-keywords?

2024-04-24 Thread Leo Butler
I looked at the documentation on worg for org-plot and much of it is
out-of-date and/or no longer works (e.g. dead links, non-working
examples). Attached is a patch for the first half of the documentation.
The patch ends at the end of the section on 2d graphs.

Comments are appreciated. I also ask for advice on later sections, below.

From 4e262898feb349dad2f5b5afe8960c8e09723862 Mon Sep 17 00:00:00 2001
From: Leo Butler 
Date: Wed, 24 Apr 2024 12:57:58 -0500
Subject: [PATCH] org-tutorials/org-plot.org: update documentation and examples

- Replace dead link to org-plot.el with link to it on the Org
repository.
- Put discussion of keybinding into a subsection distinct from
installation.  Replace instructions about an idiosyncratic keybinding
with mention of the established keybinding for org-plot/gnuplot.
- Restructure ``2d plots'' section.
   - Put lines example in one subsection, histogram example in a
   second.
   - Show the #+PLOT options that are used to create each example.
   - Fix internal link.
   - Add names/captions to tables.
   - Remove the second histogram example, because the instructions are
 incorrect and it does not work.
---
 org-tutorials/org-plot.org | 70 +-
 1 file changed, 39 insertions(+), 31 deletions(-)

diff --git a/org-tutorials/org-plot.org b/org-tutorials/org-plot.org
index a0f3564b..98401fd3 100644
--- a/org-tutorials/org-plot.org
+++ b/org-tutorials/org-plot.org
@@ -43,38 +43,46 @@ following
 First we need to make sure that org-plot is on your system and
 available to emacs.  If you have a recent version of org-mode (version
 6.07 or later) then org-plot is already included.  Otherwise you can
-grab the latest org-plot.el from [[http://github.com/eschulte/org-plot/tree/master][github/eschulte/org-plot]].  Once you
-have org-plot loaded it may be useful to bind the main plotting
-command =org-plot/gnuplot= to a key chord, I use =C-M-g= for the
-mnemonic "graph" which can be done by executing the following elisp
-snippet.  This command will be the only org-plot command needed for
-the remainder of this tutorial.
+grab the latest ~org-plot.el~ from the [[https://git.sr.ht/~bzg/org-mode/tree/main/item/lisp/org-plot.el][Org repository]].
 
-[[elisp:(local-set-key "\M-\C-g" 'org-plot/gnuplot)]]
-
-Alright, we're now ready to start generating some graphs.
+** Keybinding
+The main plotting command, =org-plot/gnuplot=, is bound to the
+key-chord =C-c " g=.  This is the only org-plot command used in this
+tutorial.
 
 * Examples
 ** 2d plots (lines and histograms)
+*** Lines
 
-First, to plot the following table use the key sequence defined above
-=C-M-g=.  This will call =org-plot/gnuplot= which finds and plots the
-nearest table.  The options specified in any =#+PLOT= lines above the
-table are read and applied to the plot.  Notice that the second
-=#+PLOT:= line specifies labels for each column, if this line is
-removed the labels will default to the column headers in the table,
-try removing this line and re-plotting.
+To plot [[org-plot-example-1][Table 1]], execute the =org-plot/gnuplot= command.  This command
+finds and plots the nearest table.  The result, saved as a =png= file,
+is displayed in [[org-plot-example-1-plot][Figure 1]].
 
+#+NAME: org-plot-example-1-plot
+#+CAPTION: Plot of Table 1.
 [[file:../images/org-plot/example-1.png]]
 
+The options specified in any =#+PLOT= lines above the table are read
+and applied to the plot.  Notice that the second =#+PLOT= line
+specifies labels for each column; if this line is removed the labels
+will default to the column headers in the table. Here are the =#+PLOT=
+lines used to create Figure 1.
+
+#+NAME: org-plot-example-1-plot-options
+#+BEGIN_EXAMPLE
+#+PLOT: title:"example table" ind:1 type:2d with:lines
+#+PLOT: labels:("first new label" "second column" "last column")
+#+END_EXAMPLE
+
 For a complete list of all of the options and their meanings see the
-[[options]] section at the end of this file.  For more information on
+[[options][options]] section at the end of this file.  For more information on
 gnuplot options see [[http://gnuplot.sourceforge.net/documentation.html][the gnuplot documentation]], nearly all gnuplot
 options should be accessible through org-plot.
 
+#+NAME: org-plot-example-1
+#+CAPTION: Data used to plot Figure 1.
 #+PLOT: title:"example table" ind:1 type:2d with:lines
 #+PLOT: labels:("first new label" "second column" "last column")
-#+TBLNAME:org-plot-example-1
 | independent var | first dependent var | second dependent var |
 |-+-+--|
 | 0.1 |   0.425 |0.375 |
@@ -107,14 +115,22 @@ options should be accessible through org-plot.
 | 2.8 |   0.1598214 |   0.18928565 |
 | 2.9 |  0.15603453 |0.1844828 |
 
+*** Historgrams
+Org-plot can also produce histograms from 2d data.  [[org-plot-example-2-plot][Figure 

Re: Can we add PLOT to org-element-multiple-keywords?

2024-04-23 Thread Ihor Radchenko
Jeff Trull  writes:

> I notice that multiple #+PLOT lines before a table will be coalesced and
> handled as one. However, this is
> accomplished through specific code in org-plot.el that does a reverse
> search through the buffer for
> additional lines. org-element has a built-in mechanism for this,
> org-element-multiple-keywords. It seems
> like it would be useful to add PLOT to it. Can that be done? If not, is
> there a way to temporarily add it for
> an exporter (i.e. after the export is launched but before the buffer is
> parsed)?

Yes, it can be done.

However, in addition to changing the parser, we should also make use of
the change in org-plot itself.

I tried to do this, and noticed that `org-plot/gnuplot' promises to
parse #+TABLE options _after_ the table as well. Affiliated keywords are
of no help then.

Further, I reviewed the two calls to `org-plot/collect-options' in
org-table.el and noticed that the second call is no longer doing the
right thing of scanning #+PLOT lines after the table - since commit
ac3148ef8 (by Timothy):

org-plot: Don't move point when plotting

* lisp/org-plot.el (org-plot/gnuplot): Expanding the `save-excursion'
block to include `org-plot/goto-nearest-table` prevents the current
point from being moved, and doesn't affect the rest of the function.

Timothy, may you please take a look?

We may drop support for the #+PLOT lines after the table - they are not
really documented in our manual. Though it will technically be a
breaking change, so I am not 100% sure.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Can we add PLOT to org-element-multiple-keywords?

2024-04-20 Thread Jeff Trull
Hi all,

I notice that multiple #+PLOT lines before a table will be coalesced and
handled as one. However, this is
accomplished through specific code in org-plot.el that does a reverse
search through the buffer for
additional lines. org-element has a built-in mechanism for this,
org-element-multiple-keywords. It seems
like it would be useful to add PLOT to it. Can that be done? If not, is
there a way to temporarily add it for
an exporter (i.e. after the export is launched but before the buffer is
parsed)?

Thanks,
Jeff