[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] org plot scripts [PATCH]
From: |
Eric Schulte |
Subject: |
Re: [Orgmode] org plot scripts [PATCH] |
Date: |
Tue, 07 Jul 2009 12:27:06 -0700 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.92 (darwin) |
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
prepend-options-to-script.patch
Description: Text Data
"Eric Schulte" <address@hidden> writes:
> address@hidden 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.
>> address@hidden
>> 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Orgmode] org plot scripts [PATCH],
Eric Schulte <=