How set a RuleX and RuleY at mean/median of the data? #2324
              
                Unanswered
              
          
                  
                    
                      nimitnshah
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment 2 replies
-
| 
         Not sure what you tried (posting code is helpful for clarity!), but here’s a fresh example for you: Plot.plot({
  marginTop: 18,
  marks: [
    Plot.tickX(penguins, {
      x: "culmen_length_mm"
    }),
    Plot.tickX(
      penguins,
      Plot.groupZ(
        { x: "median" },
        {
          x: "culmen_length_mm",
          stroke: "red",
          strokeWidth: 2,
          inset: -8
        }
      )
    ),
    Plot.text(
      penguins,
      Plot.groupZ(
        { x: "median", text: "median" },
        {
          x: "culmen_length_mm",
          text: "culmen_length_mm",
          frameAnchor: "top",
          dy: -18,
          fill: "red"
        }
      )
    )
  ]
}) | 
  
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    

Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I've been trying to get a RuleX position on the axis at the median value of the dataset. If we take the penguins dataset for example, and I put culmen_length_mm on the x axis, ideally I'd want a single RuleX line denoting the mean of all culmen_length data values. I tried using the Group transform but it outputs multiple lines across the axis, maybe because Group was meant to be for ordinal data? If it's easier, a RuleX on midpoint of the axis would also do. I feel like this should be easy to do but I'm missing something.
Beta Was this translation helpful? Give feedback.
All reactions