From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Fleischer Newsgroups: gmane.emacs.help Subject: Re: Plotting in Emacs? Date: Sat, 20 May 2023 11:26:32 +0300 Message-ID: References: <87a5z56d0j.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22378"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:lQqIbuZh9qejxldzcXyzFCcnjOk= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 20 10:27:07 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q0Hvf-0005hH-DZ for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 20 May 2023 10:27:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0HvI-0004ya-MK; Sat, 20 May 2023 04:26:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0HvF-0004y0-IO for help-gnu-emacs@gnu.org; Sat, 20 May 2023 04:26:42 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0HvE-0002a5-70 for help-gnu-emacs@gnu.org; Sat, 20 May 2023 04:26:41 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1q0HvB-00057Y-Bu for help-gnu-emacs@gnu.org; Sat, 20 May 2023 10:26:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DIET_1=0.001, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143661 Archived-At: Marcin Borkowski [2023-04-18 Tue 06:16] wrote: > The reason I want this is that I weigh myself every day, I put the > datapoints in an Org mode table (and use Org spreadsheet to compute > moving averages), and now I'd like to see a nice chart telling me > whether my diet works and I'm losing weight. So, calculating linear > regression (pretty easy with Org mode) and plotting a regression line > would also be cool. Plotting == gnuplot. You got to have a library that creates plots out of data. Here is a snippet I use for the same purpose: #+begin_src gnuplot :var data=body-data :file a.png reset set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5 set style line 2 lc rgb '#269C52' lt 1 lw 2 pt 5 pi -1 ps 1.5 set pointintervalbox 3 set title "Body Metrics" set xdata time set timefmt "%Y-%m-%d" set format x "%d/%m/%y" set key spacing 1.5 set ytics 1 set y2tics 1 set ytics nomirror set xtics nomirror set xlabel "Date" set ylabel "Kg" set y2label "Fat \%" set xrange ["2020-08-01":] set yrange [80:90] set y2range [10:25] plot data using 1:2 axis x1y1 with lp ls 1 title 'Weight',\ '' using 1:3 axis x1y2 with lp ls 2 title 'Fat' #+end_src #+RESULTS: [[file:a.png]] #+NAME: body-data | Date | Weight | Fat | |------------------+--------+------| | [2020-08-04 Tue] | 85.5 | | | [2020-08-05 Wed] | 85.1 | 18.2 | | [2020-08-06 Thu] | 86.5 | 18.9 | | [2020-08-07 Fri] | 85.7 | 18.7 | | [2020-08-08 Sat] | 85.3 | 18.3 | | [2020-08-09 Sun] | 85.9 | 18.6 | Feel free to change the gnuplot parameters for taste and the weight/fat numbers as well. -- Daniel Fleischer