From: Charles Sebold <csebold@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org-plot and timestamps
Date: Mon, 27 Oct 2008 15:51:48 -0500 [thread overview]
Message-ID: <uy709vk0r.fsf@gmail.com> (raw)
In-Reply-To: <ubpx5x0g0.fsf@gmail.com> (Charles Sebold's message of "Mon\, 27 Oct 2008 15\:11\:43 -0500")
On 27 Oct 2008, Charles Sebold wrote:
> How's this for a first pass? Not a git user before I started with
> org-mode so any pointers on how to generate these would be
> appreciated.
How embarrassing. This is the patch I meant to send:
Changes in origin/HEAD
Modified lisp/org-plot.el
diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index db67257..d0d62f6 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -101,10 +101,16 @@ will be added. Returns the resulting property list."
(org-plot/add-options-to-plist params (match-string 1 line))
params)))
+(defun org-plot-quote-timestamp-field (s)
+ "Convert field S from timestamp to Unix time and export to gnuplot."
+ (format-time-string "%Y-%m-%d-%H:%M:%S" (org-time-string-to-time s)))
+
(defun org-plot-quote-tsv-field (s)
"Quote field S for export to gnuplot."
(if (string-match org-table-number-regexp s) s
- (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")))
+ (if (string-match org-ts-regexp3 s)
+ (org-plot-quote-timestamp-field s)
+ (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\""))))
(defun org-plot/gnuplot-to-data (table data-file params)
"Export TABLE to DATA-FILE in a format readable by gnuplot.
@@ -180,6 +186,7 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
(title (plist-get params :title))
(file (plist-get params :file))
(ind (plist-get params :ind))
+ (time-ind (plist-get params :timeind))
(text-ind (plist-get params :textind))
(deps (if (plist-member params :deps) (plist-get params :deps)))
(col-labels (plist-get params :labels))
@@ -217,6 +224,9 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
(mapconcat (lambda (pair)
(format "\"%s\" %d" (cdr pair) (car pair)))
y-labels ", "))))
+ (when time-ind ;; timestamp index
+ (add-to-script "set xdata time")
+ (add-to-script "set timefmt \"%Y-%m-%d-%H:%M:%S\""))
(case type ;; plot command
('2d (dotimes (col num-cols)
(unless (and (equal type '2d)
@@ -284,16 +294,24 @@ line directly before or after the table."
('grid (let ((y-labels (org-plot/gnuplot-to-grid-data
table data-file params)))
(when y-labels (plist-put params :ylabels y-labels)))))
- ;; check for text ind column
+ ;; check for timestamp ind column
(let ((ind (- (plist-get params :ind) 1)))
- (when (and (>= ind 0) (equal '2d (plist-get params :plot-type)))
- (if (> (length
- (delq 0 (mapcar
+ (when (and (>= ind 0) (equal '2d (plist-get params :plot-type)))
+ (if (= (length
+ (delq 0 (mapcar
(lambda (el)
- (if (string-match org-table-number-regexp el)
+ (if (string-match org-ts-regexp3 el)
0 1))
(mapcar (lambda (row) (nth ind row)) table)))) 0)
- (plist-put params :textind t))))
+ (plist-put params :timeind t)
+ ;; check for text ind column
+ (if (> (length
+ (delq 0 (mapcar
+ (lambda (el)
+ (if (string-match org-table-number-regexp el)
+ 0 1))
+ (mapcar (lambda (row) (nth ind row)) table)))) 0)
+ (plist-put params :textind t)))))
;; write script
(with-temp-buffer
(if (plist-get params :script) ;; user script
@@ -307,7 +325,8 @@ line directly before or after the table."
(gnuplot-mode)
(gnuplot-send-buffer-to-gnuplot))
;; cleanup
- (bury-buffer (get-buffer "*gnuplot*"))(delete-file data-file))))
+ (bury-buffer (get-buffer "*gnuplot*"))
+ (delete-file data-file))))
(provide 'org-plot)
--
Charles Sebold
http://merbc.invigorated.org/
http://triablogue.blogspot.com/
next prev parent reply other threads:[~2008-10-27 20:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-27 13:53 org-plot and timestamps Charles Sebold
2008-10-27 15:20 ` Eric Schulte
2008-10-27 20:11 ` Charles Sebold
2008-10-27 20:51 ` Charles Sebold [this message]
2008-10-28 16:23 ` Eric Schulte
2008-10-29 20:36 ` [PATCH] org-plot: Add support for plotting timestamps Bernt Hansen
2008-10-30 12:43 ` org-plot and timestamps Charles Sebold
2008-10-30 15:35 ` Charles Sebold
2008-11-02 7:04 ` Carsten Dominik
2008-11-02 13:04 ` Charles Sebold
2008-11-02 14:25 ` Carsten Dominik
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=uy709vk0r.fsf@gmail.com \
--to=csebold@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).