arviz-devs / arviz-devs/arviz

`plot_compare` incorrectly places `min_ic` line and `ic_diff` triangles when `order_by_rank=False`

Open
#2,115 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TeX
Stars
1.9k
Forks
507
Avg merge
2d 20h
Merged PRs (30d)
3

Description

**Describe the bug**
If `order_by_rank=False` when calling `plot_compare`, the models are arranged in the same order as in the `comp_df` argument. However, the `min_ic` line always ends up at the x-location of the top model (not the best model) and the `ic_diff` triangles always end up plotted for all models except the top one (instead of all models except the best one).

**To Reproduce**

Here's the correct behavior when `order_by_rank=True`
```python
model_compare = az.compare({'Centered 8 schools': az.load_arviz_data('centered_eight'),
'Non-centered 8 schools': az.load_arviz_data('non_centered_eight')})
az.plot_compare(model_compare)
```

![Selection_042](https://user-images.githubusercontent.com/6338509/190268268-105ba42e-e5eb-4b29-862d-b895df1e8bd9.png)

And then here's the incorrect behavior when the ordering changes:
```python
az.plot_compare(model_compare.sort_values('rank', ascending=False), order_by_rank=False)
```
![Selection_043](https://user-images.githubusercontent.com/6338509/190268391-3d0ffc86-e5f2-482e-93b7-dfaf4aab5bba.png)

**Expected behavior**
I expect the `min_ic` line to be drawn at the x-location of the best model and the `ic_diff` triangles to be plotted for all models except the best one.

**Additional context**
arviz version `0.11.2`.

Contributor guide

Open the contributing guide

Research direction

Start at the plot_compare entry point and reproduce the two calls shown in the issue, comparing order_by_rank=True with the reordered comp_df and order_by_rank=False. Done means min_ic is positioned at the best model and ic_diff triangles appear for every model except the best one in the reordered plot.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.