emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: josephzxu@gmail.com
Cc: emacs-orgmode@gnu.org
Subject: Re: org plot scripts [PATCH]
Date: Tue, 07 Jul 2009 12:27:06 -0700	[thread overview]
Message-ID: <m2ocrwcn05.fsf_-_@gmail.com> (raw)
In-Reply-To: <m2vdmf67fh.fsf@gmail.com> (Eric Schulte's message of "Sun, 28 Jun 2009 20:32:50 -0700")

[-- Attachment #1: Type: text/plain, Size: 174 bytes --]

Hi Carsten,

Having played with this patch some more, I am confident that it is
working and won't break org-plot.

Please do apply it when you get a chance.

Thanks -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: prepend-options-to-script.patch --]
[-- Type: text/x-patch, Size: 2525 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 4540 bytes --]



"Eric Schulte" <schulte.eric@gmail.com> writes:

> 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]  
> 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

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

      reply	other threads:[~2009-07-07 19:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-18  7:25 org plot scripts josephzxu
2009-06-29  3:32 ` Eric Schulte
2009-07-07 19:27   ` Eric Schulte [this message]

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=m2ocrwcn05.fsf_-_@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=josephzxu@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).