Last active
December 3, 2015 17:16
-
-
Save mlgill/4d1987d650b32329e4ee to your computer and use it in GitHub Desktop.
IPython notebook illustrating issue with Matplotlib's errorbar and Seaborn's FacetGrid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from seaborn import * | |
| from seaborn.axisgrid import FacetGrid as FacetGrid_orig | |
| class FacetGrid(FacetGrid_orig): | |
| def __init__(self, data, *args, **kwargs): | |
| super(FacetGrid, self).__init__(data, *args, **kwargs) | |
| # The original palette isn't preserved by Seaborn, which seems unfortunate | |
| self._palette = kwargs['palette'] if 'palette' in kwargs.keys() else None | |
| # col_order and hue_order also aren't preserved | |
| self._col_order = kwargs['col_order'] if 'col_order' in kwargs.keys() else None | |
| self._hue_order = kwargs['hue_order'] if 'hue_order' in kwargs.keys() else None | |
| return | |
| def set_data(self, data): | |
| # Update the data | |
| self.data = data | |
| # Update the hue and color information since these are done at intilization | |
| # instead of when a plotting function is called by 'map' | |
| hue = self._hue_var | |
| palette = self._palette | |
| hue_order = self._hue_order | |
| if hue is None: | |
| hue_names = None | |
| else: | |
| hue_names = utils.categorical_order(data[hue], hue_order) | |
| colors = self._get_palette(data, hue, hue_order, palette) | |
| self.hue_names = hue_names | |
| self._colors = colors | |
| # Update the boolean mask | |
| row = self._row_var | |
| col = self._col_var | |
| dropna = self._dropna | |
| none_na = np.zeros(len(data), np.bool) | |
| if dropna: | |
| row_na = none_na if row is None else data[row].isnull() | |
| col_na = none_na if col is None else data[col].isnull() | |
| hue_na = none_na if hue is None else data[hue].isnull() | |
| not_na = ~(row_na | col_na | hue_na) | |
| else: | |
| not_na = ~none_na | |
| self._not_na = not_na | |
| # Update the column names | |
| col = self._col_var | |
| col_order = self._col_order | |
| if col is None: | |
| col_names = [] | |
| else: | |
| col_names = utils.categorical_order(data[col], col_order) | |
| self.col_names = col_names | |
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resi | B0 | scale | gamma | gamma_err | xcalc | ycalc | |
|---|---|---|---|---|---|---|---|
| 3 | Fit | 0.0 | 0.0 | ||||
| 3 | Fit | 5240079443.4 | 2.55606950571 | ||||
| 5 | Fit | 0.0 | 0.0 | ||||
| 5 | Fit | 5240079443.4 | 5.89165835339 | ||||
| 6 | Fit | 0.0 | 0.0 | ||||
| 6 | Fit | 5240079443.4 | 6.27576773129 | ||||
| 7 | Fit | 0.0 | 0.0 | ||||
| 7 | Fit | 5240079443.4 | 6.73190746211 | ||||
| 8 | Fit | 0.0 | 0.0 | ||||
| 8 | Fit | 5240079443.4 | 7.77856391734 | ||||
| 3 | 14.10 T | 3562332513.08 | 2.40603361903 | 0.382329119198 | |||
| 3 | 16.45 T | 3909405965.05 | 0.873311349907 | 0.110121377924 | |||
| 3 | 18.80 T | 4309864655.66 | 2.98320473117 | 0.0603941853768 | |||
| 3 | 21.10 T | 4763708584.91 | 1.51255705237 | 0.0730594744376 | |||
| 5 | 14.10 T | 3562332513.08 | 4.20614090702 | 0.83630635618 | |||
| 5 | 16.45 T | 3909405965.05 | 5.10571280111 | 0.314643974305 | |||
| 5 | 18.80 T | 4309864655.66 | 6.24203630625 | 0.13467071675 | |||
| 5 | 21.10 T | 4763708584.91 | 5.20780846136 | 0.0442369090562 | |||
| 6 | 14.10 T | 3562332513.08 | 5.03994895456 | 1.1541660742 | |||
| 6 | 16.45 T | 3909405965.05 | 5.33129280936 | 0.333605163164 | |||
| 6 | 18.80 T | 4309864655.66 | 5.53306383787 | 0.151951611016 | |||
| 6 | 21.10 T | 4763708584.91 | 5.65148102896 | 0.0521438514416 | |||
| 7 | 14.10 T | 3562332513.08 | 5.26152550403 | 0.968516891467 | |||
| 7 | 16.45 T | 3909405965.05 | 5.00594662538 | 0.289483228683 | |||
| 7 | 18.80 T | 4309864655.66 | 6.74248406649 | 0.139921963623 | |||
| 7 | 21.10 T | 4763708584.91 | 6.04179489237 | 0.0373172778449 | |||
| 8 | 14.10 T | 3562332513.08 | 5.3350693969 | 1.07159493156 | |||
| 8 | 16.45 T | 3909405965.05 | 7.63196887539 | 0.376515708395 | |||
| 8 | 18.80 T | 4309864655.66 | 6.72006206918 | 0.154076715691 | |||
| 8 | 21.10 T | 4763708584.91 | 7.02096370678 | 0.0469389087629 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment