g = sb.boxplot(
x="Tranche",
y="Value",
dodge=True,
cut=0,
data=tranche_results.xs(
("Delta Overall Efficiency", "Technology A"),
level=["Index", "Technology"]
).reset_index(
)[["Tranche", "Value"]],
order=[
'Component B0 Low Funding',
'Component B0 Medium Funding',
'Component B0 High Funding',
'Component B1 Low Funding',
'Component B1 Medium Funding',
'Component B1 High Funding',
'Component B2 Low Funding',
'Component B2 Medium Funding',
'Component B2 High Funding',
]
)
g.set(ylabel="Change in Overall Efficiency\nRelative to Current State",
title="Overall Efficiency Progress (Technology A Only)\n with Component B0, B1, B2 R&D")
g.set_xticklabels(g.get_xticklabels(), rotation=30, ha='right', rotation_mode='anchor')
g.axhline(y=0, linestyle=":", label='Current State')
g.legend()
Box, Boxen, Violin, Swarm all throw an error, but not the same one, see below
I can't remember if this plot was working correctly at one time (originally it was boxen) and perhaps a package update broke it, or if the plot was never working - although since it's in the middle of the notebook, the former is more likely.
Plan of attack:
[ ] Line by line comparison of this plot code with the other plots, which are working
[ ] Manual inspection of the data being passed in
[ ] See if code is working if another data set is passed in (pull from another plot)
[ ] Reduce this code to a minimal working state and test additions one at a time
Boxen:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[21], line 1
----> 1 g = sb.boxenplot(
2 x="Tranche",
3 y="Value",
4 dodge=True,
5 cut=0,
6 data=tranche_results.xs(
7 ("Delta Overall Efficiency", "Technology A"),
8 level=["Index", "Technology"]
9 ).reset_index(
10 )[["Tranche", "Value"]],
11 order=[
12 'Component B0 Low Funding',
13 'Component B0 Medium Funding',
14 'Component B0 High Funding',
15 'Component B1 Low Funding',
16 'Component B1 Medium Funding',
17 'Component B1 High Funding',
18 'Component B2 Low Funding',
19 'Component B2 Medium Funding',
20 'Component B2 High Funding',
21 ]
22 )
23 g.set(ylabel="Change in Overall Efficiency\nRelative to Current State",
24 title="Overall Efficiency Progress (Technology A Only)\n with Component B0, B1, B2 R&D")
25 g.set_xticklabels(g.get_xticklabels(), rotation=30, ha='right', rotation_mode='anchor')
File ~\AppData\Local\anaconda3\envs\tyche2\lib\site-packages\seaborn\categorical.py:1940, in boxenplot(data, x, y, hue, order, hue_order, orient, color, palette, saturation, fill, dodge, width, gap, linewidth, linecolor, width_method, k_depth, outlier_prop, trust_alpha, showfliers, hue_norm, log_scale, native_scale, formatter, legend, scale, box_kws, flier_kws, line_kws, ax, **kwargs)
1932 color = _default_color(
1933 ax.fill_between, hue, color,
1934 {}, # TODO how to get default color?
1935 # {k: v for k, v in kwargs.items() if k in ["c", "color", "fc", "facecolor"]},
1936 saturation=saturation,
1937 )
1938 linecolor = p._complement_color(linecolor, color, p._hue_map)
-> 1940 p.plot_boxens(
1941 width=width,
1942 dodge=dodge,
1943 gap=gap,
1944 fill=fill,
1945 color=color,
1946 linecolor=linecolor,
1947 linewidth=linewidth,
1948 width_method=width_method,
1949 k_depth=k_depth,
1950 outlier_prop=outlier_prop,
1951 trust_alpha=trust_alpha,
1952 showfliers=showfliers,
1953 box_kws=box_kws,
1954 flier_kws=flier_kws,
1955 line_kws=line_kws,
1956 plot_kws=kwargs,
1957 )
1959 p._add_axis_labels(ax)
1960 p._adjust_cat_axis(ax, axis=p.orient)
File ~\AppData\Local\anaconda3\envs\tyche2\lib\site-packages\seaborn\categorical.py:796, in _CategoricalPlotter.plot_boxens(self, width, dodge, gap, fill, color, linecolor, linewidth, width_method, k_depth, outlier_prop, trust_alpha, showfliers, box_kws, flier_kws, line_kws, plot_kws)
791 pos_data = pd.DataFrame({
792 self.orient: [sub_vars[self.orient]],
793 "width": [width * self._native_width],
794 })
795 if dodge:
--> 796 self._dodge(sub_vars, pos_data)
797 if gap:
798 pos_data["width"] *= 1 - gap
File ~\AppData\Local\anaconda3\envs\tyche2\lib\site-packages\seaborn\categorical.py:391, in _CategoricalPlotter._dodge(self, keys, data)
389 def _dodge(self, keys, data):
390 """Apply a dodge transform to coordinates in place."""
--> 391 hue_idx = self._hue_map.levels.index(keys["hue"])
392 n = len(self._hue_map.levels)
393 data["width"] /= n
AttributeError: 'NoneType' object has no attribute 'index'
Box:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[22], line 1
----> 1 g = sb.boxplot(
2 x="Tranche",
3 y="Value",
4 dodge=True,
5 cut=0,
6 data=tranche_results.xs(
7 ("Delta Overall Efficiency", "Technology A"),
8 level=["Index", "Technology"]
9 ).reset_index(
10 )[["Tranche", "Value"]],
11 order=[
12 'Component B0 Low Funding',
13 'Component B0 Medium Funding',
14 'Component B0 High Funding',
15 'Component B1 Low Funding',
16 'Component B1 Medium Funding',
17 'Component B1 High Funding',
18 'Component B2 Low Funding',
19 'Component B2 Medium Funding',
20 'Component B2 High Funding',
21 ]
22 )
23 g.set(ylabel="Change in Overall Efficiency\nRelative to Current State",
24 title="Overall Efficiency Progress (Technology A Only)\n with Component B0, B1, B2 R&D")
25 g.set_xticklabels(g.get_xticklabels(), rotation=30, ha='right', rotation_mode='anchor')
File ~\AppData\Local\anaconda3\envs\tyche2\lib\site-packages\seaborn\categorical.py:1619, in boxplot(data, x, y, hue, order, hue_order, orient, color, palette, saturation, fill, dodge, width, gap, whis, linecolor, linewidth, fliersize, hue_norm, native_scale, log_scale, formatter, legend, ax, **kwargs)
1612 color = _default_color(
1613 ax.fill_between, hue, color,
1614 {k: v for k, v in kwargs.items() if k in ["c", "color", "fc", "facecolor"]},
1615 saturation=saturation,
1616 )
1617 linecolor = p._complement_color(linecolor, color, p._hue_map)
-> 1619 p.plot_boxes(
1620 width=width,
1621 dodge=dodge,
1622 gap=gap,
1623 fill=fill,
1624 whis=whis,
1625 color=color,
1626 linecolor=linecolor,
1627 linewidth=linewidth,
1628 fliersize=fliersize,
1629 plot_kws=kwargs,
1630 )
1632 p._add_axis_labels(ax)
1633 p._adjust_cat_axis(ax, axis=p.orient)
File ~\AppData\Local\anaconda3\envs\tyche2\lib\site-packages\seaborn\categorical.py:637, in _CategoricalPlotter.plot_boxes(self, width, dodge, gap, fill, whis, color, linecolor, linewidth, fliersize, plot_kws)
635 data = pd.DataFrame({self.orient: positions, "width": orig_width})
636 if dodge:
--> 637 self._dodge(sub_vars, data)
638 if gap:
639 data["width"] *= 1 - gap
File ~\AppData\Local\anaconda3\envs\tyche2\lib\site-packages\seaborn\categorical.py:391, in _CategoricalPlotter._dodge(self, keys, data)
389 def _dodge(self, keys, data):
390 """Apply a dodge transform to coordinates in place."""
--> 391 hue_idx = self._hue_map.levels.index(keys["hue"])
392 n = len(self._hue_map.levels)
393 data["width"] /= n
AttributeError: 'NoneType' object has no attribute 'index'
This graph doesn't seem to want to generate:
Box, Boxen, Violin, Swarm all throw an error, but not the same one, see below
I can't remember if this plot was working correctly at one time (originally it was boxen) and perhaps a package update broke it, or if the plot was never working - although since it's in the middle of the notebook, the former is more likely.
Plan of attack:
Boxen:
Box:
Violin:
Swarm: