Search code examples
vega-lite

Line thickness in VegaLite for mark: rule


I have this plot and I am trying to make the dashed line really thin compared to the others, but can't quite figure it out. I've tried size on the actual mark-rule encoding part, as well as strokeWidth in the config (which at least the vega example here suggests is what i want) but no joy. What am I missing?


Solution

  • It appears that non-integer stroke widths are rounded up in rule marks; however this is not the case for line marks. If you replace your rule layer with this, it seems to do what you wish:

    
        {
          "data": {
            "values": [
              {"date": "2019-12-10", "metric": 100},
              {"date": "2019-12-16", "metric": 100}
            ]
          },
          "mark": {"type": "line", "strokeWidth": 0.5, "color": "black"},
          "encoding": {
            "x": {"field": "date", "type": "temporal", "timeUnit": "monthdate"},
            "y": {"field": "metric", "type": "quantitative"}
          }
        }
    

    Here is the result (vega editor): enter image description here