Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizontal bar plot docs #3964

Merged
merged 4 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tibor-mach something funny is happening here 🤔 Did you run the pre-commit hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't because the .pre-commit-config.yaml seems to be missing in the repo. There is a .pre-commit-hooks.yaml file but it is not a valid config...so I am bit confused about how I can run it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in this case it's installed if you run yarn.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are a bit more details - https://dvc.org/doc/contributing/docs#development-environment, but you don't need to run everything. And we are figuring out how to simplify the workflow for the external contributors. We had an external tool (Restyled) that was taking care of running linters and creating a fixed PR on top of a contribution.

Copy link
Contributor Author

@tibor-mach tibor-mach Sep 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did run yarn though. I set up a locally hosted version of the website with yarn develop and had it opened as I was editing the code.

I now also ran all the liters etc. manually. Everything seems to be fine. Building it also works fine...

I do get the following warning and error when I run yarn develop though. Not sure if this might have something to do with the problem here (I am not exactly sure what the problem is as it works on my machine :-) ... Perhaps a devcontainer would help here ... )

(process:22910): GModule-CRITICAL **: 21:18:59.521: g_module_make_resident: assertion 'module != NULL' failed

(process:22910): VIPS-WARNING **: 21:18:59.521: unable to load "/usr/lib/vips-modules-8.13/vips-jxl.so" -- libjxl_threads.so.0.6: cannot open shared object file: No such file or directory

## 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
Comment on lines +282 to +284
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I think "bar chart" is much more widely used. But surprisingly (for me) term "bar plot" is not insignificant out there 🤷🏼


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