diff --git a/content/docs/command-reference/plots/show.md b/content/docs/command-reference/plots/show.md index b843106dfb..33d54867fb 100644 --- a/content/docs/command-reference/plots/show.md +++ b/content/docs/command-reference/plots/show.md @@ -486,9 +486,48 @@ file:///Users/usr/src/dvc_plots/index.html We can use `confusion_normalized` template to normalize the results: ```dvc -$ dvc plots show classes.csv -t confusion_normalized +$ dvc plots show classes.csv -t confusion_normalized \ -x actual -y predicted file:///Users/usr/src/dvc_plots/index.html ``` ![](/img/plots_show_confusion_normalized.svg) + +## Example: Horizontal bar plot + +This is a simple bar plot useful for example in visualizing model feature +importances. + +We'll use `importances.csv` for this example: + +``` +feature_name,feature_importance +petal_width,0.4 +petal_length,0.33 +sepal_width,0.24 +sepal_length,0.03 +``` + +Let's visualize it: + +```dvc +$ dvc plots show importances.csv --template bar_horizontal \ + -x feature_importance -y feature_name +file:///Users/usr/src/dvc_plots/index.html +``` + +![](/img/plots_show_bar_horizontal.svg) + +When using the `bar_horizontal` template the plot is sorted by the vertical axis +(in our example this means alphabetically, by feature name). + +If you want it to be sorted by the horizontal axis (by feature importance in the +example) you can use the `bar_horizontal_sorted` template instead: + +```dvc +$ dvc plots show importances.csv -t bar_horizontal_sorted \ + -x feature_importance -y feature_name +file:///Users/usr/src/dvc_plots/index.html +``` + +![](/img/plots_show_bar_horizontal_sorted.svg) diff --git a/content/docs/user-guide/visualizing-plots.md b/content/docs/user-guide/visualizing-plots.md index 3de50e11fb..dc2cb7a6b3 100644 --- a/content/docs/user-guide/visualizing-plots.md +++ b/content/docs/user-guide/visualizing-plots.md @@ -279,6 +279,9 @@ DVC has the following built-in plot templates: [example](/doc/command-reference/plots/show#example-confusion-matrix) - `confusion_normalized` - confusion matrix with values normalized to <0, 1> range +- `bar_horizontal` - horizontal bar plot, see + [example](/doc/command-reference/plots/show#example-horizontal-bar-plot) +- `bar_horizontal_sorted` - horizontal bar plot sorted by bar size Note that in the case of CSV/TSV metrics files, column names from the table header (first row) are equivalent to field names. diff --git a/static/img/plots_show_bar_horizontal.svg b/static/img/plots_show_bar_horizontal.svg new file mode 100644 index 0000000000..feb444746c --- /dev/null +++ b/static/img/plots_show_bar_horizontal.svg @@ -0,0 +1 @@ +0.000.050.100.150.200.250.300.350.40feature_importancepetal_lengthpetal_widthsepal_lengthsepal_widthfeature_nameworkspacerevimportances.csv \ No newline at end of file diff --git a/static/img/plots_show_bar_horizontal_sorted.svg b/static/img/plots_show_bar_horizontal_sorted.svg new file mode 100644 index 0000000000..6351b2fcbf --- /dev/null +++ b/static/img/plots_show_bar_horizontal_sorted.svg @@ -0,0 +1 @@ +0.000.050.100.150.200.250.300.350.40feature_importancepetal_widthpetal_lengthsepal_widthsepal_lengthfeature_nameworkspacerevimportances.csv \ No newline at end of file