Repository: mwaskom/seaborn

Issue:
categorical sizes plot now has order reversed
From the relational tutorial, on 0.11.0.dev0:

```python
sns.relplot(x="time", y="firing_rate",
           hue="coherence", size="choice",
           palette=palette,
           kind="line", data=dots);
```

![image](https://user-images.githubusercontent.com/315810/83755000-e2b44380-a63a-11ea-9632-3fcedfaba8d0.png)


Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=h1) Report
> Merging [#2221](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=desc) into [master](https://codecov.io/gh/mwaskom/seaborn/commit/ccd56351ce244b3a0268df8cb8090eb30f033e41?el=desc) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/mwaskom/seaborn/pull/2221/graphs/tree.svg?width=650&height=150&src=pr&token=SLuzHnA9Bl)](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #2221   +/-   ##
=======================================
  Coverage   96.92%   96.92%           
=======================================
  Files          17       17           
  Lines        5861     5861           
=======================================
  Hits         5681     5681           
  Misses        180      180           
```


| [Impacted Files](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [seaborn/\_core.py](https://codecov.io/gh/mwaskom/seaborn/pull/2221/diff?src=pr&el=tree#diff-c2VhYm9ybi9fY29yZS5weQ==) | `98.43% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=footer). Last update [ccd5635...98aa173](https://codecov.io/gh/mwaskom/seaborn/pull/2221?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/seaborn/_core.py b/seaborn/_core.py
index 9c2c90ae..cd4728e0 100644
--- a/seaborn/_core.py
+++ b/seaborn/_core.py
@@ -398,8 +398,11 @@ class SizeMapping(SemanticMapping):
                 sizes = self.plotter._default_size_range
 
             # For categorical sizes, use regularly-spaced linear steps
-            # between the minimum and maximum sizes
-            sizes = np.linspace(*sizes, len(levels))
+            # between the minimum and maximum sizes. Then reverse the
+            # ramp so that the largest value is used for the first entry
+            # in size_order, etc. This is because "ordered" categoricals
+            # are often though to go in decreasing priority.
+            sizes = np.linspace(*sizes, len(levels))[::-1]
             lookup_table = dict(zip(levels, sizes))
 
         return levels, lookup_table


Test patch:
diff --git a/seaborn/tests/test_core.py b/seaborn/tests/test_core.py
index f04da623..c9ac48fe 100644
--- a/seaborn/tests/test_core.py
+++ b/seaborn/tests/test_core.py
@@ -420,7 +420,13 @@ class TestSizeMapping:
         m = SizeMapping(p, sizes=sizes)
         assert m.lookup_table == sizes
 
-        # Test excplicit categories
+        # Test specified size range
+        sizes = (2, 5)
+        m = SizeMapping(p, sizes=sizes)
+        values = np.linspace(*sizes, len(m.levels))[::-1]
+        assert m.lookup_table == dict(zip(m.levels, values))
+
+        # Test explicit categories
         p = VectorPlotter(data=long_df, variables=dict(x="x", size="a_cat"))
         m = SizeMapping(p)
         assert m.levels == long_df["a_cat"].cat.categories.tolist()