From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: org plot scripts Date: Sun, 28 Jun 2009 20:32:50 -0700 Message-ID: References: <87hbyedmw7.wl%josephzxu@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ML7c9-00009h-5F for emacs-orgmode@gnu.org; Sun, 28 Jun 2009 23:33:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ML7c4-0008Ow-Gc for emacs-orgmode@gnu.org; Sun, 28 Jun 2009 23:33:04 -0400 Received: from [199.232.76.173] (port=55396 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ML7c4-0008OE-AY for emacs-orgmode@gnu.org; Sun, 28 Jun 2009 23:33:00 -0400 Received: from mail-px0-f192.google.com ([209.85.216.192]:34120) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ML7c3-0007ny-Ok for emacs-orgmode@gnu.org; Sun, 28 Jun 2009 23:33:00 -0400 Received: by pxi30 with SMTP id 30so59339pxi.14 for ; Sun, 28 Jun 2009 20:32:58 -0700 (PDT) In-Reply-To: <87hbyedmw7.wl%josephzxu@gmail.com> (josephzxu@gmail.com's message of "Thu, 18 Jun 2009 03:25:12 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: josephzxu@gmail.com Cc: emacs-orgmode@gnu.org --=-=-= josephzxu@gmail.com writes: > Hi: > > I've been trying to make candlestick plots with org-plot, and the only > way I've found that I can do this is by specifying a custom script in > the +PLOT options. However, I noticed that when I specify a script, > all other +PLOT options I specify, such as with set: or line:, are > completely ignored. I think it would be nice to allow the user to > specify plot options in the latter manner along with custom scripts > and just prepend the options to the script. This way, the user can use > a single custom script to plot multiple data tables, while being able > to set things like the title or range of the plot on a per-table > basis. That sounds like a great idea, the attached patch[1] *should* implement the prepending of options to a script as you described above. It works for me on one simple test. Please let me know if it works for you. > Alternatively, I can also imagine giving the user the ability > to hard code the exact plot commands right in the org file. > This second approach could work with "org-babel" --a library for org-mode on which I am currently working--. I hope to add gnuplot as a supported language to org-babel. Once this is done it will be possible to write gnuplot source-code blocks which can then be fed table data returning graphs for display or inclusion in org-mode files. Through the "library of babel" functionality, these gnuplot code blocks could be named, saved, and called from other org-mode files. Cheers -- Eric > > Thanks for your time. > > Joseph > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode Footnotes: [1] --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=prepend-options-to-script.patch diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 78775a0..ae01aa2 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -181,9 +181,11 @@ and dependant variables." (setf back-edge "") (setf front-edge ""))))) row-vals)) -(defun org-plot/gnuplot-script (data-file num-cols params) +(defun org-plot/gnuplot-script (data-file num-cols params &optional preface) "Write a gnuplot script to DATA-FILE respecting the options set in PARAMS. -NUM-COLS controls the number of columns plotted in a 2-d plot." +NUM-COLS controls the number of columns plotted in a 2-d plot. +Optional argument PREFACE returns only option parameters in a +manner suitable for prepending to a user-specified script." (let* ((type (plist-get params :plot-type)) (with (if (equal type 'grid) 'pm3d @@ -238,7 +240,8 @@ NUM-COLS controls the number of columns plotted in a 2-d plot." (add-to-script (concat "set timefmt \"" (or timefmt ;; timefmt passed to gnuplot "%Y-%m-%d-%H:%M:%S") "\""))) - (case type ;; plot command + (unless preface + (case type ;; plot command ('2d (dotimes (col num-cols) (unless (and (equal type '2d) (or (and ind (equal (+ 1 col) ind)) @@ -259,8 +262,8 @@ NUM-COLS controls the number of columns plotted in a 2-d plot." ('grid (setq plot-lines (list (format "'%s' with %s title ''" data-file with))))) - (add-to-script - (concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) ",\\\n "))) + (add-to-script + (concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) ",\\\n ")))) script))) ;;----------------------------------------------------------------------------- @@ -328,10 +331,13 @@ line directly before or after the table." ;; write script (with-temp-buffer (if (plist-get params :script) ;; user script - (progn (insert-file-contents (plist-get params :script)) - (goto-char (point-min)) - (while (re-search-forward "$datafile" nil t) - (replace-match data-file nil nil))) + (progn (insert + (org-plot/gnuplot-script data-file num-cols params t)) + (insert "\n") + (insert-file-contents (plist-get params :script)) + (goto-char (point-min)) + (while (re-search-forward "$datafile" nil t) + (replace-match data-file nil nil))) (insert (org-plot/gnuplot-script data-file num-cols params))) ;; graph table --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--