Grouped Bars with flattened data

DataGraph Forums Technical Support Support Desk Grouped Bars with flattened data

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6556
    kourosh kalayeh
    Participant

      Hi,

      I am struggling to make a plot with grouped bars using flattened data. I want to generate a figure like the one below using the bars commands and flattened data.

      Screen Shot 2021-06-14 at 1.01.39 PM

      I made this figure with Bar command and “Use as mask option”. The problem is that depending on the number of categories, I have to change so many things manually; width of each bar, bar offset, mask, etc.

      Screen Shot 2021-06-14 at 1.02.38 PM

      The Pivot command does an amazing job in achieving the above automatically while processing the data. But my data is already processed, I just want to show it using bars.
      Using the processed data the pivot command can even show the values, the problem is that it cannot show the std since it does not calculate it.

      Is there anyway that I can achieve this?

      Thanks,
      Kourosh

      #6559
      dgteam
      Moderator

        We made up some data to test out an approach where you would use the Pivot to draw the bars.  Then calculate the x location and draw the error bars using a Points command.

        The key to making this work is to have the Label and Type as text columns that are mapped to numerical values, using the “Sorted #” option.

        Then the x = LABEL + width*(LABEL.count-(n/2+0.5))/n

        where

        n =  number of unique entries in the TYPE column

        width = the width fraction of the bars

        BarWidthHere are the drawing commands. Note how the fraction of the bar width is set to a variable ( called width) so it can be easily modified.

        BarWidth2

        #6601
        kourosh kalayeh
        Participant

          Thanks, did you enter “n” manually?

          Also, it would have been much nicer if you can implement a more straight forward way to achieve this (of course, depending on feasibility).

          Thanks as always,
          Kourosh

        Viewing 3 posts - 1 through 3 (of 3 total)
        • You must be logged in to reply to this topic.

        DataGraph Forums Technical Support Support Desk Grouped Bars with flattened data