From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YFlJJY/5x17xYQAA0tVLHw (envelope-from ) for ; Fri, 22 May 2020 16:10:55 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id QHDoII/5x16nPgAAB5/wlQ (envelope-from ) for ; Fri, 22 May 2020 16:10:55 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CBE39940308 for ; Fri, 22 May 2020 16:10:54 +0000 (UTC) Received: from localhost ([::1]:40166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcAG4-0006co-44 for larch@yhetil.org; Fri, 22 May 2020 12:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcADi-0003UR-Ej for emacs-orgmode@gnu.org; Fri, 22 May 2020 12:08:26 -0400 Received: from latitanza.investici.org ([2001:888:2000:56::19]:21453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcADf-0004y7-Db for emacs-orgmode@gnu.org; Fri, 22 May 2020 12:08:26 -0400 Received: from mx3.investici.org (unknown [127.0.0.1]) by latitanza.investici.org (Postfix) with ESMTP id B330712096E; Fri, 22 May 2020 16:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anche.no; s=stigmate; t=1590163691; bh=Nu+iUzPk0yqLqsEY60CNcb1glc8dZ1zAXCVBfuC0jvk=; h=To:From:Subject:Date:From; b=g4B8SVyWM71SnZJ7cB90Rd59ZNwepdEZrAwEE8g8WG6KHvd+9WbnIMQKBDXuSkUb2 3Q5YRpfC5fQejs0oGBJWQt8H44Z4x4ty9niH/zWZVGvts1yRWBKxxMOWqoDoHklNZk nbUB9wkgd7zQfhp6ep7k6Uks3p6Oy4pmrcYzBQBA= Received: from [82.94.249.234] (mx3.investici.org [82.94.249.234]) (Authenticated sender: mariotomo@inventati.org) by localhost (Postfix) with ESMTPSA id C13AE12096B; Fri, 22 May 2020 16:08:10 +0000 (UTC) To: emacs-orgmode@gnu.org From: Mario Frasca Subject: `with` as a list. Message-ID: <656b815f-9e38-e68c-b7a3-091f6f3d36bf@anche.no> Date: Fri, 22 May 2020 11:07:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------19030B3CB9FD0DF69A03A770" Content-Language: en-US Received-SPF: pass client-ip=2001:888:2000:56::19; envelope-from=mario@anche.no; helo=latitanza.investici.org X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=anche.no header.s=stigmate header.b=g4B8SVyW; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.21 X-TUID: 4qmqm7LarkLH This is a multi-part message in MIME format. --------------19030B3CB9FD0DF69A03A770 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit good day to you all now and then I use emacs to make graphs.  now recently I was plotting point data, and a running average "fit", so I wanted to have points, and lines, which I know it's possible in `gnuplot` but now how do I do that from org-plot … I wrote a small patch for org-plot.el, I'm not a Lisp programmer so I'm sure the patch looks terrible, but it does allow me to do this: #+PLOT: ind:1 deps:(3 6 4 7) with:(points lines points lines) it's two additions: 1. it lets me specify the order in which the dependent columns should be considered. 2. it lets me specify a different `with` for each column, in the same order. if you leave the `with` away, you get "lines" for all columns. if you specify only one `with` value, that value is used for all columns. if you specify more `deps` than `with`, the ones not specified will get "lines". if you specify more `with` than `deps`, they are ignored. I ran the tests, and I get two failing ones, quite unrelated according to me: 2 unexpected results:    FAILED  ob-exp/evaluate-all-executables-in-order    FAILED  ob-exp/export-call-line-information I have not defined test cases for the new behaviour, I'm willing to do that (learning the way this test environment works), but I don't find the location of the other tests related to the area of the program, which I'm tweaking. best regards all, Mario Frasca --------------19030B3CB9FD0DF69A03A770 Content-Type: text/x-patch; charset=UTF-8; name="with-as-a-list.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="with-as-a-list.patch" diff --git a/lisp/org-plot.el b/lisp/org-plot.el index a23195d2a..87a415137 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -179,6 +179,28 @@ and dependent variables." (setf back-edge "") (setf front-edge "")))) row-vals)) +(defun org-plot/zip-deps-with (num-cols ind deps with) + "describe each column to be plotted as (col . with)" + ;; make 'deps explicit + (unless deps + (setf deps (let (r) + (dotimes (i num-cols r) + (unless (eq num-cols (+ ind i)) + (setq r (cons (- num-cols i) r))))))) + ;; make sure 'with matches 'deps + (unless with + (setf with "lines")) + (unless (listp with) + (setf with (mapcar (lambda (x) with) deps))) + ;; invoke zipping function on converted data + (org-plot/zip deps with)) + +(defun org-plot/zip (xs ys) + (unless + (null xs) + (cons (cons (car xs) (or (car ys) "lines")) + (org-plot/zip (cdr xs) (cdr ys))))) + (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. @@ -240,22 +262,22 @@ manner suitable for prepending to a user-specified script." "%Y-%m-%d-%H:%M:%S") "\""))) (unless preface (pcase type ; plot command - (`2d (dotimes (col num-cols) - (unless (and (eq type '2d) - (or (and ind (equal (1+ col) ind)) - (and deps (not (member (1+ col) deps))))) - (setf plot-lines - (cons - (format plot-str data-file - (or (and ind (> ind 0) - (not text-ind) - (format "%d:" ind)) "") - (1+ col) - (if text-ind (format ":xticlabel(%d)" ind) "") - with - (or (nth col col-labels) - (format "%d" (1+ col)))) - plot-lines))))) + (`2d (dolist + (col-with + (org-plot/zip-deps-with num-cols ind deps with)) + (setf plot-lines + (cons + (format plot-str data-file + (or (and ind (> ind 0) + (not text-ind) + (format "%d:" ind)) "") + (car col-with) + (if text-ind (format ":xticlabel(%d)" ind) "") + (cdr col-with) + (or (nth (1- (car col-with)) + col-labels) + (format "%d" (car col-with)))) + plot-lines)))) (`3d (setq plot-lines (list (format "'%s' matrix with %s title ''" data-file with)))) @@ -310,7 +332,8 @@ line directly before or after the table." table data-file params))) (when y-labels (plist-put params :ylabels y-labels))))) ;; Check for timestamp ind column. - (let ((ind (1- (plist-get params :ind)))) + (let ((ind (1- (plist-get params :ind))) + (with (plist-get params :with))) (when (and (>= ind 0) (eq '2d (plist-get params :plot-type))) (if (= (length (delq 0 (mapcar @@ -320,7 +343,7 @@ line directly before or after the table." 0) (plist-put params :timeind t) ;; Check for text ind column. - (if (or (string= (plist-get params :with) "hist") + (if (or (and (stringp with) (string= with "hist")) (> (length (delq 0 (mapcar (lambda (el) --------------19030B3CB9FD0DF69A03A770--