[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] How to plot time series over weekly / monthly data



In my completely unbiased opinion, you should use my tools!

feedgnuplot (http://github.com/dkogan/feedgnuplot) to plot stdin in
various flexible ways

vnlog (http://github.com/dkogan/vnlog) to manipulate textual tables in
various flexible ways

Starting with Carsten's modified example to add a header and to just
take one year for simplicity:

  $ ( echo '# date value'; for m in {01..12}; do echo "2020-$m $RANDOM"; done) | tee /tmp/data.vnl

  # date value
  2020-01 16404
  2020-02 13997
  2020-03 30219
  2020-04 32555
  2020-05 1214
  2020-06 24831
  2020-07 4371
  2020-08 17144
  2020-09 10803
  2020-10 18450
  2020-11 2738
  2020-12 6945

And I can plot:

  $ < /tmp/data.vnl feedgnuplot --domain --timefmt '%Y-%m' \
     --unset grid --lines --points \
     --terminal 'dumb 80,40'

  35000 +-------------------------------------------------------------------+   
        |     +     +    +     +    +     +     +    +     +     +     +    |   
        |                                                                   |   
        |                     *A                                            |   
        |                  *** *                                            |   
  30000 |-+              A*    *                                          +-|   
        |                *     *                                            |   
        |               *       *                                           |   
        |               *       *                                           |   
        |               *       *                                           |   
  25000 |-+             *       *         A                               +-|   
        |              *        *         *                                 |   
        |              *        *         **                                |   
        |              *         *       * *                                |   
        |             *          *       * *                                |   
  20000 |-+           *          *       * *                              +-|   
        |             *          *       *  *                               |   
        |            *           *      *   *                    A          |   
        |            *           *      *   *        A          **          |   
        |     A**    *            *     *   *        **         * *         |   
        |        **  *            *     *    *      *  *       *  *         |   
  15000 |-+        **             *    *     *      *   *     *   *       +-|   
        |           A             *    *     *      *   *    *     *        |   
        |                         *    *      *    *     *   *     *        |   
        |                         *    *      *    *      * *      *        |   
        |                         *   *       *    *       A        *       |   
  10000 |-+                        *  *       *   *                 *     +-|   
        |                          *  *        *  *                 *       |   
        |                          *  *        * *                  *       |   
        |                          * *         * *                   *      |   
        |                          * *         * *                   *    **|   
   5000 |-+                        * *          *                    *   *+-|   
        |                           **          A                     ***   |   
        |                           *                                 A     |   
        |                           *                                       |   
        |     +     +    +     +    A     +     +    +     +     +     +    |   
      0 +-------------------------------------------------------------------+   
    01/12/01/01/01/0201/03/01/0401/05/01/06/01/0701/08/01/09/01/10/01/1101/12/20


For the purposes of this email I'm using the dumb terminal, but most of
the time you'd omit that, and get a graphical, interactive plot. And
it's very, very flexible. Let's take only the data above 10000, plot
that AND that squared on the right-hand y axis, let's add a legend, and
let's put different text on the x axis for good measure

  $ < /tmp/data.vnl vnl-filter 'value > 10000' -p date,value,square='value*value' |
      feedgnuplot --domain --timefmt '%Y-%m' \
                  --vnl --autolegend --y2 square \
                  --set 'key bottom left' \
                  --set 'format x "%b"' \
                  --unset grid --points \
                  --terminal 'dumb 80,40'

  35000 +---------------------------------------------------------+ 1.1e+09     
        |     +     +    +     A     +     +    +     +     +     |             
        |                                                         |             
        |                                                         |             
        |                      B                                +-| 1e+09       
        |                                                         |             
        |                                                         |             
  30000 |-+              B                                      +-| 9e+08       
        |                                                         |             
        |                                                         |             
        |                                                         |             
        |                                                       +-| 8e+08       
        |                                                         |             
        |                                                         |             
  25000 |-+                                                     +-| 7e+08       
        |                                  B                      |             
        |                                                         |             
        |                                  A                      |             
        |                                                       +-| 6e+08       
        |                                                         |             
        |                                                         |             
        |                                                         |             
  20000 |-+                                                     +-| 5e+08       
        |                                                         |             
        |                                                         |             
        |                                                       +-| 4e+08       
        |                                             B           |             
        |     B                                                   |             
        |                                                         |             
  15000 |-+                                           A         +-| 3e+08       
        |     A     B                                             |             
        |                                                         |             
        |                                                       +-| 2e+08       
        |           A                                             |             
        |square    A                                              |             
        | value    B+    +     +     +     +    +     +     B     |             
  10000 +---------------------------------------------------------+ 1e+08       
       Dec   Jan   Feb  Mar   Apr   May   Jun  Jul   Aug   Sep   Oct            

And so on. Plenty of documentation and samples online. And both are in
Debian. AND if you want to do python, there's gnuplotlib (also mine, and
also in Debian)


Reply to: