Skip to content

Commit

Permalink
horizontal bar plot docs (#3964)
Browse files Browse the repository at this point in the history
* horizontal bar plot docs

* removed commented out confusion matrix quote

* missing \

* another missing backslash
  • Loading branch information
tibor-mach authored Sep 19, 2022
1 parent 98fe9aa commit c099bba
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
41 changes: 40 additions & 1 deletion content/docs/command-reference/plots/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions content/docs/user-guide/visualizing-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions static/img/plots_show_bar_horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c099bba

Please sign in to comment.