title: how to layer multiple regression lines without repeating code?
body: <p>I'm using Vega Lite to chart the times at which I eat my meals, and want a regression (loess) line showing the general time for each. By default, a regression uses the entire dataset and only shows one line; I want three lines, one for each meal (stored in the field <code>extra_data.content</code>).</p>
  <p>I've achieved what I want to do my repeating the loess layer three times (<a href="https://i.stack.imgur.com/HrH7e.png" rel="nofollow noreferrer">screenshot</a>) but am trying to find a solution in which the same layer is written once and repeats itself three times.</p>
  <p><strong>Edit after solving!</strong> Thanks very much to @jakevdp for the answer! Here is my working code; note that there is both a <code>groupby</code> on the loess and a <code>color</code> channel.</p>
  <pre class="lang-json prettyprint-override"><code>        {
              &quot;mark&quot;: &quot;line&quot;,
              &quot;transform&quot;: [
                  {
                      &quot;loess&quot;: &quot;hm&quot;,
                      &quot;on&quot;: &quot;ymd&quot;,
                      &quot;groupby&quot;: [&quot;extra_data.content&quot;]
                  }
              ],
              &quot;encoding&quot;: {
                  &quot;x&quot;: {
                      &quot;field&quot;: &quot;ymd&quot;,
                      &quot;type&quot;: &quot;temporal&quot;
                  },
                  &quot;y&quot;: {
                      &quot;field&quot;: &quot;hm&quot;,
                      &quot;type&quot;: &quot;temporal&quot;
                  },
                  &quot;color&quot;: {
                      &quot;field&quot;: &quot;extra_data.content&quot;,
                      &quot;type&quot;: &quot;nominal&quot;
                  }
              }
          }
  </code></pre>