vscode-dvc: `smooth` plots template broken

The smooth plots template is broken and doesn’t seem to account for the groupby, instead collapsing everything into one line.

To reproduce, you can use https://github.com/iterative/example-get-started and change the template in dvc.yaml for one of the linear plots to smooth:

$ git diff
diff --git a/dvc.yaml b/dvc.yaml
index 684eb69..9b34875 100644
--- a/dvc.yaml
+++ b/dvc.yaml
@@ -52,6 +52,7 @@ plots:
       y:
         eval/prc/train.json: precision
         eval/prc/test.json: precision
+      template: smooth
   - ROC:
       x: fpr
       y:

The smooth template is on the left below, and it should have two lines (the right plot also doesn’t look great, but that should be fixable on the DVC side):

Screenshot 2023-01-20 at 3 31 23 PM

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

For now, they have to be concatenated, I’m looking into options to keep them apart. That’s how the Vega template looks like in VS Code (anyone can copy paste and play with it here):

A pretty large JSON
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {
        "step": "0",
        "train/acc": "0.2707333333333333",
        "dvc_inferred_y_value": "0.2707333333333333",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "1",
        "train/acc": "0.40696666666666664",
        "dvc_inferred_y_value": "0.40696666666666664",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "2",
        "train/acc": "0.4991833333333333",
        "dvc_inferred_y_value": "0.4991833333333333",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "3",
        "train/acc": "0.6582666666666667",
        "dvc_inferred_y_value": "0.6582666666666667",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "4",
        "train/acc": "0.5437333333333333",
        "dvc_inferred_y_value": "0.5437333333333333",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "5",
        "train/acc": "0.6674",
        "dvc_inferred_y_value": "0.6674",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "6",
        "train/acc": "0.6644",
        "dvc_inferred_y_value": "0.6644",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "7",
        "train/acc": "0.6833166666666667",
        "dvc_inferred_y_value": "0.6833166666666667",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "8",
        "train/acc": "0.7272",
        "dvc_inferred_y_value": "0.7272",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "9",
        "train/acc": "0.68985",
        "dvc_inferred_y_value": "0.68985",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "10",
        "train/acc": "0.7435333333333334",
        "dvc_inferred_y_value": "0.7435333333333334",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "11",
        "train/acc": "0.6868166666666666",
        "dvc_inferred_y_value": "0.6868166666666666",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "12",
        "train/acc": "0.76165",
        "dvc_inferred_y_value": "0.76165",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "13",
        "train/acc": "0.7097833333333333",
        "dvc_inferred_y_value": "0.7097833333333333",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "14",
        "train/acc": "0.7694",
        "dvc_inferred_y_value": "0.7694",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "15",
        "train/acc": "0.7323666666666667",
        "dvc_inferred_y_value": "0.7323666666666667",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "16",
        "train/acc": "0.7824166666666666",
        "dvc_inferred_y_value": "0.7824166666666666",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "17",
        "train/acc": "0.7494666666666666",
        "dvc_inferred_y_value": "0.7494666666666666",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "18",
        "train/acc": "0.7894",
        "dvc_inferred_y_value": "0.7894",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "19",
        "train/acc": "0.7608166666666667",
        "dvc_inferred_y_value": "0.7608166666666667",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/train/acc.tsv",
          "field": "train/acc"
        },
        "filename": "training/plots/metrics/train/acc.tsv",
        "field": "train/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/train/acc.tsv::train/acc"
      },
      {
        "step": "0",
        "test/acc": "0.3712",
        "dvc_inferred_y_value": "0.3712",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "1",
        "test/acc": "0.4104",
        "dvc_inferred_y_value": "0.4104",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "2",
        "test/acc": "0.6052",
        "dvc_inferred_y_value": "0.6052",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "3",
        "test/acc": "0.7678",
        "dvc_inferred_y_value": "0.7678",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "4",
        "test/acc": "0.6457",
        "dvc_inferred_y_value": "0.6457",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "5",
        "test/acc": "0.7654",
        "dvc_inferred_y_value": "0.7654",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "6",
        "test/acc": "0.7689",
        "dvc_inferred_y_value": "0.7689",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "7",
        "test/acc": "0.7841",
        "dvc_inferred_y_value": "0.7841",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "8",
        "test/acc": "0.8325",
        "dvc_inferred_y_value": "0.8325",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "9",
        "test/acc": "0.7935",
        "dvc_inferred_y_value": "0.7935",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "10",
        "test/acc": "0.8514",
        "dvc_inferred_y_value": "0.8514",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "11",
        "test/acc": "0.791",
        "dvc_inferred_y_value": "0.791",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "12",
        "test/acc": "0.8712",
        "dvc_inferred_y_value": "0.8712",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "13",
        "test/acc": "0.8105",
        "dvc_inferred_y_value": "0.8105",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "14",
        "test/acc": "0.8735",
        "dvc_inferred_y_value": "0.8735",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "15",
        "test/acc": "0.8332",
        "dvc_inferred_y_value": "0.8332",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "16",
        "test/acc": "0.8862",
        "dvc_inferred_y_value": "0.8862",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "17",
        "test/acc": "0.8529",
        "dvc_inferred_y_value": "0.8529",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "18",
        "test/acc": "0.8929",
        "dvc_inferred_y_value": "0.8929",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      },
      {
        "step": "19",
        "test/acc": "0.8662",
        "dvc_inferred_y_value": "0.8662",
        "dvc_data_version_info": {
          "filename": "training/plots/metrics/test/acc.tsv",
          "field": "test/acc"
        },
        "filename": "training/plots/metrics/test/acc.tsv",
        "field": "test/acc",
        "rev": "workspace",
        "filename::field": "training/plots/metrics/test/acc.tsv::test/acc"
      }
    ]
  },
  "title": "dvc.yaml::Accuracy",
  "width": 300,
  "height": 300,
  "params": [
    {
      "name": "smooth",
      "value": 0.2,
      "bind": {
        "input": "range",
        "min": 0.001,
        "max": 1,
        "step": 0.01
      }
    }
  ],
  "transform": [
    {
      "loess": "dvc_inferred_y_value",
      "on": "step",
      "groupby": [
        "rev",
        "filename",
        "field",
        "filename::field"
      ],
      "bandwidth": {
        "signal": "smooth"
      }
    }
  ],
  "layer": [
    {
      "encoding": {
        "x": {
          "field": "step",
          "type": "quantitative",
          "title": "step"
        },
        "y": {
          "field": "dvc_inferred_y_value",
          "type": "quantitative",
          "title": "accuracy",
          "scale": {
            "zero": false
          }
        },
        "color": {
          "field": "rev",
          "type": "nominal"
        }
      },
      "layer": [
        {
          "mark": {
            "type": "line",
            "point": true,
            "tooltip": {
              "content": "data"
            }
          }
        }
      ]
    }
  ],
  
  "encoding": {
    "color": {
      "legend": {
        "disable": true
      },
      "field": "rev",
      "scale": {
        "domain": [
          "workspace"
        ],
        "range": [
          "#13adc7"
        ]
      }
    },
    "strokeDash": {
      
      "field": "filename::field",
      "scale": {
        "domain": [
          "training/plots/metrics/test/acc.tsv::test/acc",
          "training/plots/metrics/train/acc.tsv::train/acc"
        ],
        "range": [
          [
            1,
            0
          ],
          [
            8,
            8
          ]
        ]
      },
      "legend": {
        "disable": true
      }
    }
  }
}

(I modified and put filename::field into groupby to make it work).

VS Code adds this section (besides modifying the data points a bit with an additional field filename::field):

"encoding": {
    "color": {
      "legend": {
        "disable": true
      },
      "field": "rev",
      "scale": {
        "domain": [
          "workspace"
        ],
        "range": [
          "#13adc7"
        ]
      }
    },
    "strokeDash": {
      
      "field": "filename::field",
      "scale": {
        "domain": [
          "training/plots/metrics/test/acc.tsv::test/acc",
          "training/plots/metrics/train/acc.tsv::train/acc"
        ],
        "range": [
          [
            1,
            0
          ],
          [
            8,
            8
          ]
        ]
      },
      "legend": {
        "disable": true
      }
    }
  }

This section is needed to:

  • disable the legend (it’a available only if you zoom in) + side panel and the ribbon serve as a basic legend
  • enforce a specific color per revision
  • enforce a specific type of “dash” per filename + field

I can’t easily at the moment come up with an alternative, but I’m pretty sure we can do something here. I don’t like that we have to grow the list of things that go through group by. And unfortunately, it seems we can’t group by by the whole dvc_data_version_info object 😦