xia2 / screen19

Screening program for small-molecule single-crystal X-ray diffraction data
https://pypi.org/project/screen19/
BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

Gnuplot dumb terminal swallows its own ylabel #18

Closed benjaminhwilliams closed 4 years ago

benjaminhwilliams commented 4 years ago

In recent versions of Gnuplot, the dumb terminal refuses to print the y-axis label, despite apparently making enough room for it.

Example:

gnuplot> set terminal dumb 80 35
Terminal type is now 'dumb'
Options are 'feed  size 80, 35 aspect 2, 1 mono'
gnuplot> set title 'Test title'
gnuplot> set xlabel 'Test xlabel'
gnuplot> set ylabel 'test ylabel'
gnuplot> plot '-' using 1:2 title '' with lines
input data ('e' ends) > 1 200
input data ('e' ends) > 2 400 
input data ('e' ends) > 3 300
input data ('e' ends) > 4 600
input data ('e' ends) > e

                                        Test title                             

             600 +----------------------------------------------------------+   
                 |         +         +         +        +         +        *|   
                 |                                                        * |   
             550 |-+                                                     *+-|   
                 |                                                      *   |   
                 |                                                     *    |   
                 |                                                    *     |   
             500 |-+                                                 *    +-|   
                 |                                                  *       |   
                 |                                                 *        |   
             450 |-+                                              *       +-|   
                 |                                                *         |   
                 |                                               *          |   
                 |                                              *           |   
             400 |-+                 *****                     *          +-|   
                 |                 **     **                  *             |   
                 |                *         ***              *              |   
             350 |-+            **             ***          *             +-|   
                 |             *                  **       *                |   
                 |            *                     ***   *                 |   
                 |          **                         * *                  |   
             300 |-+       *                            *                 +-|   
                 |       **                                                 |   
                 |      *                                                   |   
             250 |-+  **                                                  +-|   
                 |   *                                                      |   
                 |  *                                                       |   
                 |**       +         +         +        +         +         |   
             200 +----------------------------------------------------------+   
                 1        1.5        2        2.5       3        3.5        4   
                                         Test xlabel                            

No y-axis label, and yet

gnuplot> show ylabel
    ylabel is "test ylabel", offset at (character 0, 0, 0), rotated by -270 degrees in 2D plots textcolor lt -1

Interestingly, it seems that the space to the left of the y-axis is made to measure to the length of the y-axis label, it's just that the label itself never gets printed:

gnuplot> set ylabel "" 
gnuplot> refresh

                                    Test title                                  

  600 +---------------------------------------------------------------------+   
      |           +          +           +           +          +          *|   
      |                                                                   * |   
  550 |-+                                                                *+-|   
      |                                                                 *   |   
      |                                                               **    |   
      |                                                              *      |   
  500 |-+                                                           *     +-|   
      |                                                            *        |   
      |                                                           *         |   
  450 |-+                                                        *        +-|   
      |                                                         *           |   
      |                                                        *            |   
      |                                                       *             |   
  400 |-+                    ******                          *            +-|   
      |                    **      ***                      *               |   
      |                  **           ***                 **                |   
  350 |-+               *                ****            *                +-|   
      |               **                     ***        *                   |   
      |             **                          ****   *                    |   
      |            *                                * *                     |   
  300 |-+        **                                  *                    +-|   
      |         *                                                           |   
      |       **                                                            |   
  250 |-+   **                                                            +-|   
      |    *                                                                |   
      |  **                                                                 |   
      |**         +          +           +           +          +           |   
  200 +---------------------------------------------------------------------+   
      1          1.5         2          2.5          3         3.5          4   
                                    Test xlabel                                 

gnuplot> set ylabel "Antidisestablishmentarianism"
gnuplot> refresh

                                                  Test title                    

                              600 +-----------------------------------------+   
                                  |      +      +      +      +      +     *|   
                                  |                                        *|   
                              550 |-+                                     *-|   
                                  |                                      *  |   
                                  |                                      *  |   
                                  |                                     *   |   
                              500 |-+                                  *  +-|   
                                  |                                    *    |   
                                  |                                   *     |   
                              450 |-+                                *    +-|   
                                  |                                  *      |   
                                  |                                 *       |   
                                  |                                *        |   
                              400 |-+           ***                *      +-|   
                                  |            *   **             *         |   
                                  |           *      **          *          |   
                              350 |-+        *         **        *        +-|   
                                  |         *            **     *           |   
                                  |        *               **  *            |   
                                  |       *                  * *            |   
                              300 |-+    *                    *           +-|   
                                  |     *                                   |   
                                  |    *                                    |   
                              250 |-+ *                                   +-|   
                                  |  *                                      |   
                                  | *                                       |   
                                  |*     +      +      +      +      +      |   
                              200 +-----------------------------------------+   
                                  1     1.5     2     2.5     3     3.5     4   
                                                  Test xlabel                   

Let's break it down, what happens with one character?

gnuplot> set ylabel "y"
gnuplot> refresh

                                    Test title                                  

   600 +--------------------------------------------------------------------+   
       |           +          +           +          +           +         *|   
       |                                                                  * |   
   550 |-+                                                               *+-|   
       |                                                                *   |   
       |                                                              **    |   
       |                                                             *      |   
   500 |-+                                                          *     +-|   
       |                                                           *        |   
       |                                                          *         |   
   450 |-+                                                       *        +-|   
       |                                                        *           |   
       |                                                       *            |   
       |                                                      *             |   
  y400 |-+                    *****                          *            +-|   
       |                    **     ****                     *               |   
       |                  **           ***                **                |   
   350 |-+               *                ***            *                +-|   
       |               **                    ****       *                   |   
       |             **                          ***   *                    |   
       |            *                               * *                     |   
   300 |-+        **                                 *                    +-|   
       |         *                                                          |   
       |       **                                                           |   
   250 |-+   **                                                           +-|   
       |    *                                                               |   
       |  **                                                                |   
       |**         +          +           +          +           +          |   
   200 +--------------------------------------------------------------------+   
       1          1.5         2          2.5         3          3.5         4   
                                    Test xlabel                                 

Aha, we have a label but it looks as though the spacing is dodgy. Let's try setting an offset.

gnuplot> set ylabel "y" offset character 0,0
gnuplot> refresh

                                    Test title                                  

   600 +--------------------------------------------------------------------+   
       |           +          +           +          +           +         *|   
       |                                                                  * |   
   550 |-+                                                               *+-|   
       |                                                                *   |   
       |                                                              **    |   
       |                                                             *      |   
   500 |-+                                                          *     +-|   
       |                                                           *        |   
       |                                                          *         |   
   450 |-+                                                       *        +-|   
       |                                                        *           |   
       |                                                       *            |   
       |                                                      *             |   
 y 400 |-+                    *****                          *            +-|   
       |                    **     ****                     *               |   
       |                  **           ***                **                |   
   350 |-+               *                ***            *                +-|   
       |               **                    ****       *                   |   
       |             **                          ***   *                    |   
       |            *                               * *                     |   
   300 |-+        **                                 *                    +-|   
       |         *                                                          |   
       |       **                                                           |   
   250 |-+   **                                                           +-|   
       |    *                                                               |   
       |  **                                                                |   
       |**         +          +           +          +           +          |   
   200 +--------------------------------------------------------------------+   
       1          1.5         2          2.5         3          3.5         4   
                                    Test xlabel                                 

Much better. Does this always work?

gnuplot> set ylabel "yl" offset character 0,0
gnuplot> refresh

                                     Test title                                 

    600 +-------------------------------------------------------------------+   
        |          +           +          +          +           +         *|   
        |                                                                 * |   
    550 |-+                                                              *+-|   
        |                                                               *   |   
        |                                                             **    |   
        |                                                            *      |   
    500 |-+                                                         *     +-|   
        |                                                          *        |   
        |                                                         *         |   
    450 |-+                                                      *        +-|   
        |                                                       *           |   
        |                                                      *            |   
        |                                                     *             |   
    400 |-+                    *****                         *            +-|   
        |                    **     ***                     *               |   
        |                  **          ***                **                |   
    350 |-+               *               ****           *                +-|   
        |               **                    ***       *                   |   
        |             **                         ***   *                    |   
        |            *                              * *                     |   
    300 |-+        **                                *                    +-|   
        |         *                                                         |   
        |       **                                                          |   
    250 |-+   **                                                          +-|   
        |    *                                                              |   
        |  **                                                               |   
        |**        +           +          +          +           +          |   
    200 +-------------------------------------------------------------------+   
        1         1.5          2         2.5         3          3.5         4   
                                     Test xlabel                             

Clearly not. Let's try a bigger offset.

gnuplot> set ylabel "yl" offset character 1,0
gnuplot> refresh

                                     Test title                                 

    600 +-------------------------------------------------------------------+   
        |          +           +          +          +           +         *|   
        |                                                                 * |   
    550 |-+                                                              *+-|   
        |                                                               *   |   
        |                                                             **    |   
        |                                                            *      |   
    500 |-+                                                         *     +-|   
        |                                                          *        |   
        |                                                         *         |   
    450 |-+                                                      *        +-|   
        |                                                       *           |   
        |                                                      *            |   
        |                                                     *             |   
 yl 400 |-+                    *****                         *            +-|   
        |                    **     ***                     *               |   
        |                  **          ***                **                |   
    350 |-+               *               ****           *                +-|   
        |               **                    ***       *                   |   
        |             **                         ***   *                    |   
        |            *                              * *                     |   
    300 |-+        **                                *                    +-|   
        |         *                                                         |   
        |       **                                                          |   
    250 |-+   **                                                          +-|   
        |    *                                                              |   
        |  **                                                               |   
        |**        +           +          +          +           +          |   
    200 +-------------------------------------------------------------------+   
        1         1.5          2         2.5         3          3.5         4   
                                     Test xlabel                                

gnuplot> set ylabel "yla" offset character 1,0
gnuplot> refresh

                                     Test title                                 

     600 +------------------------------------------------------------------+   
         |          +          +           +          +          +         *|   
         |                                                                * |   
     550 |-+                                                             *+-|   
         |                                                              *   |   
         |                                                             *    |   
         |                                                            *     |   
     500 |-+                                                         *    +-|   
         |                                                          *       |   
         |                                                         *        |   
     450 |-+                                                     **       +-|   
         |                                                      *           |   
         |                                                     *            |   
         |                                                    *             |   
 yla 400 |-+                   *****                         *            +-|   
         |                   **     ****                    *               |   
         |                  *           ***                *                |   
     350 |-+              **               ***            *               +-|   
         |              **                    ****       *                  |   
         |             *                          ***   *                   |   
         |           **                              * *                    |   
     300 |-+        *                                 *                   +-|   
         |        **                                                        |   
         |       *                                                          |   
     250 |-+   **                                                         +-|   
         |   **                                                             |   
         |  *                                                               |   
         |**        +          +           +          +          +          |   
     200 +------------------------------------------------------------------+   
         1         1.5         2          2.5         3         3.5         4   
                                     Test xlabel                                

gnuplot> set ylabel "ylab" offset character 1,0
gnuplot> refresh

                                      Test title                                

      600 +-----------------------------------------------------------------+   
          |          +          +          +          +          +         *|   
          |                                                               * |   
      550 |-+                                                            *+-|   
          |                                                             *   |   
          |                                                            *    |   
          |                                                           *     |   
      500 |-+                                                        *    +-|   
          |                                                         *       |   
          |                                                        *        |   
      450 |-+                                                    **       +-|   
          |                                                     *           |   
          |                                                    *            |   
          |                                                   *             |   
      400 |-+                   *****                        *            +-|   
          |                   **     ***                    *               |   
          |                  *          ***                *                |   
      350 |-+              **              ****           *               +-|   
          |              **                    ***       *                  |   
          |             *                         ***   *                   |   
          |           **                             * *                    |   
      300 |-+        *                                *                   +-|   
          |        **                                                       |   
          |       *                                                         |   
      250 |-+   **                                                        +-|   
          |   **                                                            |   
          |  *                                                              |   
          |**        +          +          +          +          +          |   
      200 +-----------------------------------------------------------------+   
          1         1.5         2         2.5         3         3.5         4   
                                      Test xlabel                               

gnuplot> set ylabel "ylab" offset character 2,0
gnuplot> refresh

                                      Test title                                

      600 +-----------------------------------------------------------------+   
          |          +          +          +          +          +         *|   
          |                                                               * |   
      550 |-+                                                            *+-|   
          |                                                             *   |   
          |                                                            *    |   
          |                                                           *     |   
      500 |-+                                                        *    +-|   
          |                                                         *       |   
          |                                                        *        |   
      450 |-+                                                    **       +-|   
          |                                                     *           |   
          |                                                    *            |   
          |                                                   *             |   
 ylab 400 |-+                   *****                        *            +-|   
          |                   **     ***                    *               |   
          |                  *          ***                *                |   
      350 |-+              **              ****           *               +-|   
          |              **                    ***       *                  |   
          |             *                         ***   *                   |   
          |           **                             * *                    |   
      300 |-+        *                                *                   +-|   
          |        **                                                       |   
          |       *                                                         |   
      250 |-+   **                                                        +-|   
          |   **                                                            |   
          |  *                                                              |   
          |**        +          +          +          +          +          |   
      200 +-----------------------------------------------------------------+   
          1         1.5         2         2.5         3         3.5         4   
                                      Test xlabel                               

OK, so it's clear that we need a horizontal offset equal to len(xlabel) // 2.