Print plots and metrics directly in the terminal

Wasn’t sure where to best share this. Let me know if there are more appropriate channels.

If you use the fish shell and the kitty terminal (not sure if other terminals can print images) you can print DVC plots directly in the terminal without opening an external program/browser. The function also prints the metrics diff below the plot, but I didn’t have any changes to show now :sweat_smile:

Save this code as ~/.config/fish/functions/plotit.fish
(follow the link for the latest version)

You also need jq and vega-cli installed.

Example usage:

  • plotit pr_curve.csv -> prints diff plot with width x height of 500px x 500px and x set to row-index and y to the second column of the csv
  • plotit pr_curve.csv recall precision -> same as above but selects the columns for x and y
  • plotit pr_curve.csv recall precision 800 800 -> with custom width and height in pixels

@dmitry are there plans to add something like this to the dvc plots command? e.g. dvc plots --print-to-term

3 Likes

@jcpsantiago that looks magnificent in the command line :smiling_face_with_three_hearts:

The biggest question - how to integrate this to DVC core without dependencies on these kitty specific scripts. The issue tracker might be a better place to start this discussion. I’d appreciate it if you can create an issue.

Not related topic - The current approach and your code might be a great fit for a small blog post in resources like http://dev.to/ (we publish small posts there from time to time). Some people might use it until we integrated CLI plots in DVC.If you decide to republish it here - we’d be happy to support it.

@dmitry published here https://dev.to/jcpsantiago/print-dvc-plots-and-metrics-directly-in-the-terminal-1c6g

Reg the feature development I’ll open an issue then.