Menu

#2743 Missing xticlabels in boxplot

None
closed
nobody
2025-01-04
2024-10-30
theozh
No

It's maybe not a bug, more a missing feature, but I don't understand why I don't easily get xticlabels on a boxplot. Maybe it's just a lack of understanding how it is intended to work. I know, you could workaround with an extra dummy plot command to get the xticlabels right.

Why do I get xticlabels using with boxes, but not when using with boxplot?

Example:

reset session

$Data <<EOD
 One   Two  Three
 3     6    2
 4     1    3
 6     9    1
 1     7    4
 2     8    5
 5     4    4
EOD

set boxwidth 0.8 absolute
set key noautotitle

set multiplot layout 1,2
    plot for [col=1:3]$Data u (col):col:xtic(columnheader(col)) w boxes

    plot for [col=1:3]$Data u (col):col:xtic(columnheader(col)) w boxplot
unset multiplot
1 Attachments

Discussion

  • theozh

    theozh - 2024-10-30
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,6 @@
    -It&#39;s maybe not a bug, more a missing feature, but I don&#39;t understand why I don&#39;t easily get xtic labels on a boxplot. Maybe it&#39;s just a lack of understanding how it is intended to work. I know, you could workaround with an extra dummy plot command to get the xtics right. 
    +It&#39;s maybe not a bug, more a missing feature, but I don&#39;t understand why I don&#39;t easily get xticlabels on a boxplot. Maybe it&#39;s just a lack of understanding how it is intended to work. I know, you could workaround with an extra dummy plot command to get the xticlabels right. 
    
    -Why do I get xtics using `with boxes`, but not when using `with boxplot`?
    +Why do I get xticlabels using `with boxes`, but not when using `with boxplot`?
    
     **Example:**
     ```
    
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2024-10-30

    The documentation section for with boxplot is definitely lacking in essential detail. It is already on the list of things that need attention. The short answer is that it wants the label, if any, for the boxplot to be provided in the fourth column.

    In general the primary feature of a boxplot is to show the distribution of values along y. The numerical value of the x coordinate is not usually relevant, so you don't normally want xtics at all. Instead you normally want some label underneath that acts like the key title would.

    $Data <<EOD
     One   Two  Three
     3     6    2
     4     1    3
     6     9    1
     1     7    4
     2     8    5
     5     4    4
    EOD
    
    set boxwidth 0.8 absolute
    set yrange [0:10]
    unset key
    
    set multiplot layout 1,2
       plot for [col=1:3] $Data u (col):col:xtic(columnheader(col)) w boxes
       set border 2
       set tics scale 0
       plot for [col=1:3] $Data u (col):col:(0.8):(columnheader(col)) w boxplot
    unset multiplot
    
     
  • theozh

    theozh - 2024-10-31

    Thanks, this clarifies it. Apparently, this was my lack of understanding how it works. So, the idea for boxplot is not necessarily to have data in different columns, but in one and another one for indicating the respective box. Data can even be in random order, sorted by first occurrence. I was also positively surprised that lc var works as well.

    reset session
    
    $Data <<EOD
    3    One
    1    Two
    1    Three
    6    One
    2    One
    6    Two
    4    One
    5    Three
    9    Two
    1    One
    3    Three
    7    Two
    8    Two
    4    Two
    2    Three
    5    One
    4    Three
    4    Three
    EOD
    
    set key noautotitle
    plot $Data u (1):1:(0.8):2 w boxplot lc var
    
     
  • Ethan Merritt

    Ethan Merritt - 2024-12-21
    • status: open --> pending
     
  • Ethan Merritt

    Ethan Merritt - 2025-01-04
    • status: pending --> closed
     

Log in to post a comment.