* Plotting a table of date+time pairs
@ 2024-11-28 1:21 Michael Heerdegen
2024-11-28 9:27 ` Fraga, Eric
0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2024-11-28 1:21 UTC (permalink / raw)
To: emacs-orgmode
Hi,
I want to plot two columns of an org table: the first column (the "x"
coordinate) consists of dates, the second column contains a time value
associated with each date.
It seems this is not as easy to do as I had hoped: AFAIU, for making
gnuplot interpret the "y"-value (!) as a time value I need to add
something like
using "1:(timecolumn(2,\"%H:%M\"))"
to the gnuplot command line (it took me quite a while to find out how to
do it at all...)
And AFAIK this is only possible by tweaking
`org-plot/preset-plot-types'. I need to add a complete new type of
plot!
Is there maybe a simpler way (I know I could add redundant columns to
the table to help org - that's not really what I want, though)?
TIA,
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-28 1:21 Plotting a table of date+time pairs Michael Heerdegen
@ 2024-11-28 9:27 ` Fraga, Eric
2024-11-28 23:17 ` Michael Heerdegen
0 siblings, 1 reply; 12+ messages in thread
From: Fraga, Eric @ 2024-11-28 9:27 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: emacs-orgmode@gnu.org
Response below/inline for email Michael Heerdegen wrote:
> (original email sent 28 Nov 2024 at 02:21)
>
> [...]
> And AFAIK this is only possible by tweaking
> `org-plot/preset-plot-types'. I need to add a complete new type of
> plot!
You could use a gnuplot src block instead of org-plot? It's what I do
usually as org-plot is not powerful enough for most of my plots
(although very nice for simple x-y graphs etc.).
--
: Eric S Fraga, with org 9.7.15-a1df10 in Emacs 31.0.50
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-28 9:27 ` Fraga, Eric
@ 2024-11-28 23:17 ` Michael Heerdegen
2024-11-29 9:30 ` Fraga, Eric
2024-11-29 15:21 ` Max Nikulin
0 siblings, 2 replies; 12+ messages in thread
From: Michael Heerdegen @ 2024-11-28 23:17 UTC (permalink / raw)
To: emacs-orgmode
"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
> You could use a gnuplot src block instead of org-plot? It's what I do
> usually as org-plot is not powerful enough for most of my plots
> (although very nice for simple x-y graphs etc.).
Ah ok, thank you. Sounds reasonable.
I'm not a sophisticated org user. May I ask for a simple example,
and how I would have to invoke gnuplot instead?
Thank you very much,
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-28 23:17 ` Michael Heerdegen
@ 2024-11-29 9:30 ` Fraga, Eric
2024-11-30 6:17 ` Michael Heerdegen
2024-11-29 15:21 ` Max Nikulin
1 sibling, 1 reply; 12+ messages in thread
From: Fraga, Eric @ 2024-11-29 9:30 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
Response below/inline for email Michael Heerdegen wrote:
> (original email sent 29 Nov 2024 at 00:17)
>
> I'm not a sophisticated org user. May I ask for a simple example,
> and how I would have to invoke gnuplot instead?
Sure, see attached. This example has a table of data to plot (simple
example with two columns) and the gnuplot src block to create a PDF
plot. You invoke gnuplot by typing C-c C-c in the src block. You can
then view the result with C-c C-o.
Check the info manual for org, specifically
(org) Working with Source Code
HTH,
eric
--
: Eric S Fraga, with org 9.7.15-a1df10 in Emacs 31.0.50
[-- Attachment #2: test.org --]
[-- Type: application/vnd.lotus-organizer, Size: 550 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-28 23:17 ` Michael Heerdegen
2024-11-29 9:30 ` Fraga, Eric
@ 2024-11-29 15:21 ` Max Nikulin
1 sibling, 0 replies; 12+ messages in thread
From: Max Nikulin @ 2024-11-29 15:21 UTC (permalink / raw)
To: emacs-orgmode
On 29/11/2024 06:17, Michael Heerdegen wrote:
> I'm not a sophisticated org user. May I ask for a simple example,
> and how I would have to invoke gnuplot instead?
<https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.html>
Link to its source is incorrect, it should be
<https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-29 9:30 ` Fraga, Eric
@ 2024-11-30 6:17 ` Michael Heerdegen
2024-11-30 6:48 ` Michael Heerdegen
2024-12-02 12:21 ` Fraga, Eric
0 siblings, 2 replies; 12+ messages in thread
From: Michael Heerdegen @ 2024-11-30 6:17 UTC (permalink / raw)
To: emacs-orgmode
"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
> Sure, see attached. This example has a table of data to plot (simple
> example with two columns) and the gnuplot src block to create a PDF
> plot. You invoke gnuplot by typing C-c C-c in the src block. You can
> then view the result with C-c C-o.
> [...]
Ok... I had to (require 'ob-gnuplot), but then the example worked fine.
It took a while but I got my own table work as well, more or less (see
below).
Thank you very much!
"Max Nikulin" <manikulin@gmail.com> writes:
> <https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-gnuplot.html>
Very nice overview and reference, thank you very much as well.
I now have one remaining problem: my time values in the second column
contain the name of the time zone - the purpose is to flag the time as
summer or winter time. Currently I need to remove these indicators from
the table, else plotting fail, gnuplot doesn't understand the data.
Can I tell "ob-gnuplot" to export the table in a different way - how?
The time zone makes a difference when exporting since the generated
data file has a different format: the time fields including the timezone
get wrapped in quotation marks, without time zone they are exported
literally.
Thanks again,
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-30 6:17 ` Michael Heerdegen
@ 2024-11-30 6:48 ` Michael Heerdegen
2024-12-02 12:21 ` Fraga, Eric
1 sibling, 0 replies; 12+ messages in thread
From: Michael Heerdegen @ 2024-11-30 6:48 UTC (permalink / raw)
To: emacs-orgmode
Michael Heerdegen <michael_heerdegen@web.de> writes:
> I now have one remaining problem: my time values in the second column
> contain the name of the time zone - the purpose is to flag the time as
> summer or winter time. Currently I need to remove these indicators from
> the table, else plotting fail, gnuplot doesn't understand the data.
I could adjust `org-table-number-regexp' - this makes plotting succeed.
Unfortunately does "ob-gnuplot" not respect a buffer local binding of
that variable (in the org buffer containing the table). I need to
change the global binding of that variable.
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-11-30 6:17 ` Michael Heerdegen
2024-11-30 6:48 ` Michael Heerdegen
@ 2024-12-02 12:21 ` Fraga, Eric
2024-12-04 10:50 ` Michael Heerdegen
1 sibling, 1 reply; 12+ messages in thread
From: Fraga, Eric @ 2024-12-02 12:21 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: emacs-orgmode@gnu.org
Response below/inline for email Michael Heerdegen wrote:
> (original email sent 30 Nov 2024 at 07:17)
>
> I now have one remaining problem: my time values in the second column
> contain the name of the time zone - the purpose is to flag the time as
> summer or winter time. Currently I need to remove these indicators from
> the table, else plotting fail, gnuplot doesn't understand the data.
You can specify the format of dates/times in gnuplot and then manipulate
them. See "time/date specifiers" in the gnuplot info manual and also
read about the strptime() function. I don't have any examples of these
at hand unfortunately.
--
: Eric S Fraga, with org 9.7.15-a1df10 in Emacs 31.0.50
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-12-02 12:21 ` Fraga, Eric
@ 2024-12-04 10:50 ` Michael Heerdegen
2024-12-04 11:51 ` Fraga, Eric
0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2024-12-04 10:50 UTC (permalink / raw)
To: Org Mode List
"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
> > I now have one remaining problem: my time values in the second column
> > contain the name of the time zone - the purpose is to flag the time as
> > summer or winter time. Currently I need to remove these indicators from
> > the table, else plotting fail, gnuplot doesn't understand the data.
>
> You can specify the format of dates/times in gnuplot and then manipulate
> them. See "time/date specifiers" in the gnuplot info manual and also
> read about the strptime() function. I don't have any examples of these
> at hand unfortunately.
Yes thanks - but I really think Org gets it wrong. Look:
With
| plot data using 1:(timecolumn(2,"%H:%M") ...
gnuplot happily accepts a data file looking like
| 2024-09-18 11:40 CEST
| 2024-09-19 11:27 CEST
| ... ...
It just discards the timezone which is good enough. No problem with the
kind of data for gnuplot (AFAIR I read in the gnuplot manual that time
zones are not supported ad-hoc - anyway, I don't need this for
plotting.)
But the real problem is that the org table export mechanism thinks that
the time field doesn't look like a numerical field, so it wraps every
such field in quotes, and the exported data file will look like
| 2024-09-18 "11:40 CEST"
| 2024-09-19 "11:27 CEST"
| ... ...
instead. Then gnuplot doesn't find data matching "%H:%M in the second
column of the data file and interprets it as zero or 00:00am or
whatever.
Can I make gnuplot disregard the quotation marks? Else I must tell org
that these fields should not be quoted. But ironically the only way I
know to do this is again a hack: I must adjust
`org-table-number-regexp' which... sounds like a good solution but since
org disregards a file local binding I must change the global binding of
the variable! Ugh. Better solutions welcome.
Thanks,
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-12-04 10:50 ` Michael Heerdegen
@ 2024-12-04 11:51 ` Fraga, Eric
2024-12-04 13:47 ` Michael Heerdegen
0 siblings, 1 reply; 12+ messages in thread
From: Fraga, Eric @ 2024-12-04 11:51 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: Org Mode List
Response below/inline for email Michael Heerdegen wrote:
> (original email sent 4 Dec 2024 at 11:50)
>
> But the real problem is that the org table export mechanism thinks that
> the time field doesn't look like a numerical field, so it wraps every
> such field in quotes, and the exported data file will look like
>
> | 2024-09-18 "11:40 CEST"
> | 2024-09-19 "11:27 CEST"
Is it possible to specify a format to timecolumn that includes both the
quotes and the time zone? I'm thinking something along the lines of
... timecolumn(2, "\"%H:%M %Z\"")
(untested)
--
: Eric S Fraga, with org 9.7.15-a1df10 in Emacs 31.0.50
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-12-04 11:51 ` Fraga, Eric
@ 2024-12-04 13:47 ` Michael Heerdegen
2024-12-04 14:02 ` Fraga, Eric
0 siblings, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2024-12-04 13:47 UTC (permalink / raw)
To: emacs-orgmode
"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
> > But the real problem is that the org table export mechanism thinks that
> > the time field doesn't look like a numerical field, so it wraps every
> > such field in quotes, and the exported data file will look like
> >
> > | 2024-09-18 "11:40 CEST"
> > | 2024-09-19 "11:27 CEST"
>
> Is it possible to specify a format to timecolumn that includes both the
> quotes and the time zone? I'm thinking something along the lines of
>
> ... timecolumn(2, "\"%H:%M %Z\"")
>
> (untested)
Tested!
The escaped quotes seem to be recognized literally as expected. This
saves me from my org hack!
Unfortunately %Z is ignored - I think it's only significant for output:
| [...] However this default can be replaced when reading any
| particular file or column of input using the timecolumn function in
| the corresponding using specifier.
|
| The conversion to and from seconds assumes Universal Time (which is
| the same as Greenwich Standard Time). There is no provision for
| changing the time zone or for daylight savings. If all your data
| refer to the same time zone (and are all either daylight or standard)
| you don’t need to worry about these things. But if the absolute time
| is crucial for your application, you’ll need to convert to UT
| yourself.
I thought maybe %z, which is meant to support a time zone in [+/-]mm:hh
format, could work, but parsing completely fails when using it. Maybe
it's not implemented for input, not even as "ignore that part".
But that's not a big deal, I'm happy with the version that works. You
were a great help, Eric.
Thanks again,
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Plotting a table of date+time pairs
2024-12-04 13:47 ` Michael Heerdegen
@ 2024-12-04 14:02 ` Fraga, Eric
0 siblings, 0 replies; 12+ messages in thread
From: Fraga, Eric @ 2024-12-04 14:02 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: emacs-orgmode@gnu.org
Response below/inline for email Michael Heerdegen wrote:
> (original email sent 4 Dec 2024 at 14:47)
>
> Tested!
>
> The escaped quotes seem to be recognized literally as expected. This
> saves me from my org hack!
Excellent!
> Unfortunately %Z is ignored - I think it's only significant for output:
Yeah, I had a feeling that would be the case. The documentation implied
this by omission.
> But that's not a big deal, I'm happy with the version that works. You
> were a great help, Eric.
Happy to have been able to help. gnuplot is a brilliant tool but
sometimes difficult to get exactly what you want due to its rather
idiosyncratic syntax (that comes from the organic growth of features).
But ever so powerful (like org) once you get comfortable with the
various features.
--
: Eric S Fraga, with org 9.7.15-a1df10 in Emacs 31.0.50
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-12-04 14:03 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 1:21 Plotting a table of date+time pairs Michael Heerdegen
2024-11-28 9:27 ` Fraga, Eric
2024-11-28 23:17 ` Michael Heerdegen
2024-11-29 9:30 ` Fraga, Eric
2024-11-30 6:17 ` Michael Heerdegen
2024-11-30 6:48 ` Michael Heerdegen
2024-12-02 12:21 ` Fraga, Eric
2024-12-04 10:50 ` Michael Heerdegen
2024-12-04 11:51 ` Fraga, Eric
2024-12-04 13:47 ` Michael Heerdegen
2024-12-04 14:02 ` Fraga, Eric
2024-11-29 15:21 ` Max Nikulin
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).