repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
has2k1/plotnine | plotnine/geoms/geom.py | geom.draw_layer | def draw_layer(self, data, layout, coord, **params):
"""
Draw layer across all panels
geoms should not override this method.
Parameters
----------
data : DataFrame
DataFrame specific for this layer
layout : Lanel
Layout object created whe... | python | def draw_layer(self, data, layout, coord, **params):
"""
Draw layer across all panels
geoms should not override this method.
Parameters
----------
data : DataFrame
DataFrame specific for this layer
layout : Lanel
Layout object created whe... | [
"def",
"draw_layer",
"(",
"self",
",",
"data",
",",
"layout",
",",
"coord",
",",
"*",
"*",
"params",
")",
":",
"for",
"pid",
",",
"pdata",
"in",
"data",
".",
"groupby",
"(",
"'PANEL'",
")",
":",
"if",
"len",
"(",
"pdata",
")",
"==",
"0",
":",
"... | Draw layer across all panels
geoms should not override this method.
Parameters
----------
data : DataFrame
DataFrame specific for this layer
layout : Lanel
Layout object created when the plot is getting
built
coord : coord
... | [
"Draw",
"layer",
"across",
"all",
"panels"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L195-L221 | train |
has2k1/plotnine | plotnine/geoms/geom.py | geom.draw_panel | def draw_panel(self, data, panel_params, coord, ax, **params):
"""
Plot all groups
For effeciency, geoms that do not need to partition
different groups before plotting should override this
method and avoid the groupby.
Parameters
----------
data : datafr... | python | def draw_panel(self, data, panel_params, coord, ax, **params):
"""
Plot all groups
For effeciency, geoms that do not need to partition
different groups before plotting should override this
method and avoid the groupby.
Parameters
----------
data : datafr... | [
"def",
"draw_panel",
"(",
"self",
",",
"data",
",",
"panel_params",
",",
"coord",
",",
"ax",
",",
"*",
"*",
"params",
")",
":",
"for",
"_",
",",
"gdata",
"in",
"data",
".",
"groupby",
"(",
"'group'",
")",
":",
"gdata",
".",
"reset_index",
"(",
"inp... | Plot all groups
For effeciency, geoms that do not need to partition
different groups before plotting should override this
method and avoid the groupby.
Parameters
----------
data : dataframe
Data to be plotted by this geom. This is the
dataframe ... | [
"Plot",
"all",
"groups"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L223-L256 | train |
has2k1/plotnine | plotnine/geoms/geom.py | geom._verify_arguments | def _verify_arguments(self, kwargs):
"""
Verify arguments passed to the geom
"""
geom_stat_args = kwargs.keys() | self._stat._kwargs.keys()
unknown = (geom_stat_args -
self.aesthetics() - # geom aesthetics
self.DEFAULT_PARAMS.k... | python | def _verify_arguments(self, kwargs):
"""
Verify arguments passed to the geom
"""
geom_stat_args = kwargs.keys() | self._stat._kwargs.keys()
unknown = (geom_stat_args -
self.aesthetics() - # geom aesthetics
self.DEFAULT_PARAMS.k... | [
"def",
"_verify_arguments",
"(",
"self",
",",
"kwargs",
")",
":",
"geom_stat_args",
"=",
"kwargs",
".",
"keys",
"(",
")",
"|",
"self",
".",
"_stat",
".",
"_kwargs",
".",
"keys",
"(",
")",
"unknown",
"=",
"(",
"geom_stat_args",
"-",
"self",
".",
"aesthe... | Verify arguments passed to the geom | [
"Verify",
"arguments",
"passed",
"to",
"the",
"geom"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L358-L373 | train |
has2k1/plotnine | plotnine/geoms/geom.py | geom.handle_na | def handle_na(self, data):
"""
Remove rows with NaN values
geoms that infer extra information from missing values
should override this method. For example
:class:`~plotnine.geoms.geom_path`.
Parameters
----------
data : dataframe
Data
... | python | def handle_na(self, data):
"""
Remove rows with NaN values
geoms that infer extra information from missing values
should override this method. For example
:class:`~plotnine.geoms.geom_path`.
Parameters
----------
data : dataframe
Data
... | [
"def",
"handle_na",
"(",
"self",
",",
"data",
")",
":",
"return",
"remove_missing",
"(",
"data",
",",
"self",
".",
"params",
"[",
"'na_rm'",
"]",
",",
"list",
"(",
"self",
".",
"REQUIRED_AES",
"|",
"self",
".",
"NON_MISSING_AES",
")",
",",
"self",
".",... | Remove rows with NaN values
geoms that infer extra information from missing values
should override this method. For example
:class:`~plotnine.geoms.geom_path`.
Parameters
----------
data : dataframe
Data
Returns
-------
out : datafra... | [
"Remove",
"rows",
"with",
"NaN",
"values"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L375-L402 | train |
has2k1/plotnine | plotnine/positions/position_stack.py | position_stack.setup_params | def setup_params(self, data):
"""
Verify, modify & return a copy of the params.
"""
# Variable for which to do the stacking
if 'ymax' in data:
if any((data['ymin'] != 0) & (data['ymax'] != 0)):
warn("Stacking not well defined when not "
... | python | def setup_params(self, data):
"""
Verify, modify & return a copy of the params.
"""
# Variable for which to do the stacking
if 'ymax' in data:
if any((data['ymin'] != 0) & (data['ymax'] != 0)):
warn("Stacking not well defined when not "
... | [
"def",
"setup_params",
"(",
"self",
",",
"data",
")",
":",
"# Variable for which to do the stacking",
"if",
"'ymax'",
"in",
"data",
":",
"if",
"any",
"(",
"(",
"data",
"[",
"'ymin'",
"]",
"!=",
"0",
")",
"&",
"(",
"data",
"[",
"'ymax'",
"]",
"!=",
"0",... | Verify, modify & return a copy of the params. | [
"Verify",
"modify",
"&",
"return",
"a",
"copy",
"of",
"the",
"params",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position_stack.py#L24-L45 | train |
has2k1/plotnine | plotnine/positions/position_stack.py | position_stack.strategy | def strategy(data, params):
"""
Stack overlapping intervals.
Assumes that each set has the same horizontal position
"""
vjust = params['vjust']
y = data['y'].copy()
y[np.isnan(y)] = 0
heights = np.append(0, y.cumsum())
if params['fill']:
... | python | def strategy(data, params):
"""
Stack overlapping intervals.
Assumes that each set has the same horizontal position
"""
vjust = params['vjust']
y = data['y'].copy()
y[np.isnan(y)] = 0
heights = np.append(0, y.cumsum())
if params['fill']:
... | [
"def",
"strategy",
"(",
"data",
",",
"params",
")",
":",
"vjust",
"=",
"params",
"[",
"'vjust'",
"]",
"y",
"=",
"data",
"[",
"'y'",
"]",
".",
"copy",
"(",
")",
"y",
"[",
"np",
".",
"isnan",
"(",
"y",
")",
"]",
"=",
"0",
"heights",
"=",
"np",
... | Stack overlapping intervals.
Assumes that each set has the same horizontal position | [
"Stack",
"overlapping",
"intervals",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position_stack.py#L83-L104 | train |
has2k1/plotnine | plotnine/stats/stat_bindot.py | densitybin | def densitybin(x, weight=None, binwidth=None, bins=None, rangee=None):
"""
Do density binning
It does not collapse each bin with a count.
Parameters
----------
x : array-like
Numbers to bin
weight : array-like
Weights
binwidth : numeric
Size of the bins
rang... | python | def densitybin(x, weight=None, binwidth=None, bins=None, rangee=None):
"""
Do density binning
It does not collapse each bin with a count.
Parameters
----------
x : array-like
Numbers to bin
weight : array-like
Weights
binwidth : numeric
Size of the bins
rang... | [
"def",
"densitybin",
"(",
"x",
",",
"weight",
"=",
"None",
",",
"binwidth",
"=",
"None",
",",
"bins",
"=",
"None",
",",
"rangee",
"=",
"None",
")",
":",
"if",
"all",
"(",
"pd",
".",
"isnull",
"(",
"x",
")",
")",
":",
"return",
"pd",
".",
"DataF... | Do density binning
It does not collapse each bin with a count.
Parameters
----------
x : array-like
Numbers to bin
weight : array-like
Weights
binwidth : numeric
Size of the bins
rangee : tuple
Range of x
Returns
-------
data : DataFrame | [
"Do",
"density",
"binning"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat_bindot.py#L215-L278 | train |
has2k1/plotnine | plotnine/themes/theme.py | theme_get | def theme_get():
"""
Return the default theme
The default theme is the one set (using :func:`theme_set`) by
the user. If none has been set, then :class:`theme_gray` is
the default.
"""
from .theme_gray import theme_gray
_theme = get_option('current_theme')
if isinstance(_theme, type... | python | def theme_get():
"""
Return the default theme
The default theme is the one set (using :func:`theme_set`) by
the user. If none has been set, then :class:`theme_gray` is
the default.
"""
from .theme_gray import theme_gray
_theme = get_option('current_theme')
if isinstance(_theme, type... | [
"def",
"theme_get",
"(",
")",
":",
"from",
".",
"theme_gray",
"import",
"theme_gray",
"_theme",
"=",
"get_option",
"(",
"'current_theme'",
")",
"if",
"isinstance",
"(",
"_theme",
",",
"type",
")",
":",
"_theme",
"=",
"_theme",
"(",
")",
"return",
"_theme",... | Return the default theme
The default theme is the one set (using :func:`theme_set`) by
the user. If none has been set, then :class:`theme_gray` is
the default. | [
"Return",
"the",
"default",
"theme"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/theme.py#L277-L289 | train |
has2k1/plotnine | plotnine/themes/theme.py | theme.apply | def apply(self, ax):
"""
Apply this theme, then apply additional modifications in order.
Subclasses that override this method should make sure that
the base class method is called.
"""
for th in self.themeables.values():
th.apply(ax) | python | def apply(self, ax):
"""
Apply this theme, then apply additional modifications in order.
Subclasses that override this method should make sure that
the base class method is called.
"""
for th in self.themeables.values():
th.apply(ax) | [
"def",
"apply",
"(",
"self",
",",
"ax",
")",
":",
"for",
"th",
"in",
"self",
".",
"themeables",
".",
"values",
"(",
")",
":",
"th",
".",
"apply",
"(",
"ax",
")"
] | Apply this theme, then apply additional modifications in order.
Subclasses that override this method should make sure that
the base class method is called. | [
"Apply",
"this",
"theme",
"then",
"apply",
"additional",
"modifications",
"in",
"order",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/theme.py#L114-L122 | train |
has2k1/plotnine | plotnine/themes/theme.py | theme.apply_rcparams | def apply_rcparams(self):
"""
Set the rcParams
"""
from matplotlib import rcParams
for key, val in self.rcParams.items():
try:
rcParams[key] = val
except Exception as e:
msg = ("""Setting "mpl.rcParams['{}']={}" """
... | python | def apply_rcparams(self):
"""
Set the rcParams
"""
from matplotlib import rcParams
for key, val in self.rcParams.items():
try:
rcParams[key] = val
except Exception as e:
msg = ("""Setting "mpl.rcParams['{}']={}" """
... | [
"def",
"apply_rcparams",
"(",
"self",
")",
":",
"from",
"matplotlib",
"import",
"rcParams",
"for",
"key",
",",
"val",
"in",
"self",
".",
"rcParams",
".",
"items",
"(",
")",
":",
"try",
":",
"rcParams",
"[",
"key",
"]",
"=",
"val",
"except",
"Exception"... | Set the rcParams | [
"Set",
"the",
"rcParams"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/theme.py#L148-L159 | train |
has2k1/plotnine | plotnine/themes/theme.py | theme.rcParams | def rcParams(self):
"""
Return rcParams dict for this theme.
Notes
-----
Subclasses should not need to override this method method as long as
self._rcParams is constructed properly.
rcParams are used during plotting. Sometimes the same theme can be
achie... | python | def rcParams(self):
"""
Return rcParams dict for this theme.
Notes
-----
Subclasses should not need to override this method method as long as
self._rcParams is constructed properly.
rcParams are used during plotting. Sometimes the same theme can be
achie... | [
"def",
"rcParams",
"(",
"self",
")",
":",
"try",
":",
"rcParams",
"=",
"deepcopy",
"(",
"self",
".",
"_rcParams",
")",
"except",
"NotImplementedError",
":",
"# deepcopy raises an error for objects that are drived from or",
"# composed of matplotlib.transform.TransformNode.",
... | Return rcParams dict for this theme.
Notes
-----
Subclasses should not need to override this method method as long as
self._rcParams is constructed properly.
rcParams are used during plotting. Sometimes the same theme can be
achieved by setting rcParams before plotting ... | [
"Return",
"rcParams",
"dict",
"for",
"this",
"theme",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/theme.py#L162-L193 | train |
has2k1/plotnine | plotnine/themes/theme.py | theme.add_theme | def add_theme(self, other, inplace=False):
"""Add themes together.
Subclasses should not override this method.
This will be called when adding two instances of class 'theme'
together.
A complete theme will annihilate any previous themes. Partial themes
can be added toge... | python | def add_theme(self, other, inplace=False):
"""Add themes together.
Subclasses should not override this method.
This will be called when adding two instances of class 'theme'
together.
A complete theme will annihilate any previous themes. Partial themes
can be added toge... | [
"def",
"add_theme",
"(",
"self",
",",
"other",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"other",
".",
"complete",
":",
"return",
"other",
"theme_copy",
"=",
"self",
"if",
"inplace",
"else",
"deepcopy",
"(",
"self",
")",
"theme_copy",
".",
"themeable... | Add themes together.
Subclasses should not override this method.
This will be called when adding two instances of class 'theme'
together.
A complete theme will annihilate any previous themes. Partial themes
can be added together and can be added to a complete theme. | [
"Add",
"themes",
"together",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/theme.py#L195-L210 | train |
has2k1/plotnine | plotnine/animation.py | PlotnineAnimation._draw_plots | def _draw_plots(self, plots):
"""
Plot and return the figure and artists
Parameters
----------
plots : iterable
ggplot objects that make up the the frames of the animation
Returns
-------
figure : matplotlib.figure.Figure
Matplotl... | python | def _draw_plots(self, plots):
"""
Plot and return the figure and artists
Parameters
----------
plots : iterable
ggplot objects that make up the the frames of the animation
Returns
-------
figure : matplotlib.figure.Figure
Matplotl... | [
"def",
"_draw_plots",
"(",
"self",
",",
"plots",
")",
":",
"# For keeping track of artists for each frame",
"artist_offsets",
"=",
"{",
"'collections'",
":",
"[",
"]",
",",
"'patches'",
":",
"[",
"]",
",",
"'lines'",
":",
"[",
"]",
",",
"'texts'",
":",
"[",
... | Plot and return the figure and artists
Parameters
----------
plots : iterable
ggplot objects that make up the the frames of the animation
Returns
-------
figure : matplotlib.figure.Figure
Matplotlib figure
artists : list
List ... | [
"Plot",
"and",
"return",
"the",
"figure",
"and",
"artists"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/animation.py#L54-L194 | train |
has2k1/plotnine | plotnine/coords/coord_flip.py | flip_labels | def flip_labels(obj):
"""
Rename fields x to y and y to x
Parameters
----------
obj : dict_like
Object with labels to rename
"""
def sub(a, b):
"""
Substitute all keys that start with a to b
"""
for label in list(obj.keys()):
if label.star... | python | def flip_labels(obj):
"""
Rename fields x to y and y to x
Parameters
----------
obj : dict_like
Object with labels to rename
"""
def sub(a, b):
"""
Substitute all keys that start with a to b
"""
for label in list(obj.keys()):
if label.star... | [
"def",
"flip_labels",
"(",
"obj",
")",
":",
"def",
"sub",
"(",
"a",
",",
"b",
")",
":",
"\"\"\"\n Substitute all keys that start with a to b\n \"\"\"",
"for",
"label",
"in",
"list",
"(",
"obj",
".",
"keys",
"(",
")",
")",
":",
"if",
"label",
".... | Rename fields x to y and y to x
Parameters
----------
obj : dict_like
Object with labels to rename | [
"Rename",
"fields",
"x",
"to",
"y",
"and",
"y",
"to",
"x"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/coords/coord_flip.py#L58-L79 | train |
has2k1/plotnine | plotnine/stats/stat_summary.py | bootstrap_statistics | def bootstrap_statistics(series, statistic, n_samples=1000,
confidence_interval=0.95, random_state=None):
"""
Default parameters taken from
R's Hmisc smean.cl.boot
"""
if random_state is None:
random_state = np.random
alpha = 1 - confidence_interval
size = (... | python | def bootstrap_statistics(series, statistic, n_samples=1000,
confidence_interval=0.95, random_state=None):
"""
Default parameters taken from
R's Hmisc smean.cl.boot
"""
if random_state is None:
random_state = np.random
alpha = 1 - confidence_interval
size = (... | [
"def",
"bootstrap_statistics",
"(",
"series",
",",
"statistic",
",",
"n_samples",
"=",
"1000",
",",
"confidence_interval",
"=",
"0.95",
",",
"random_state",
"=",
"None",
")",
":",
"if",
"random_state",
"is",
"None",
":",
"random_state",
"=",
"np",
".",
"rand... | Default parameters taken from
R's Hmisc smean.cl.boot | [
"Default",
"parameters",
"taken",
"from",
"R",
"s",
"Hmisc",
"smean",
".",
"cl",
".",
"boot"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat_summary.py#L11-L27 | train |
has2k1/plotnine | plotnine/stats/stat_summary.py | mean_cl_boot | def mean_cl_boot(series, n_samples=1000, confidence_interval=0.95,
random_state=None):
"""
Bootstrapped mean with confidence limits
"""
return bootstrap_statistics(series, np.mean,
n_samples=n_samples,
confidence_interval=c... | python | def mean_cl_boot(series, n_samples=1000, confidence_interval=0.95,
random_state=None):
"""
Bootstrapped mean with confidence limits
"""
return bootstrap_statistics(series, np.mean,
n_samples=n_samples,
confidence_interval=c... | [
"def",
"mean_cl_boot",
"(",
"series",
",",
"n_samples",
"=",
"1000",
",",
"confidence_interval",
"=",
"0.95",
",",
"random_state",
"=",
"None",
")",
":",
"return",
"bootstrap_statistics",
"(",
"series",
",",
"np",
".",
"mean",
",",
"n_samples",
"=",
"n_sampl... | Bootstrapped mean with confidence limits | [
"Bootstrapped",
"mean",
"with",
"confidence",
"limits"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat_summary.py#L30-L38 | train |
has2k1/plotnine | plotnine/stats/stat_summary.py | mean_sdl | def mean_sdl(series, mult=2):
"""
mean plus or minus a constant times the standard deviation
"""
m = series.mean()
s = series.std()
return pd.DataFrame({'y': [m],
'ymin': m-mult*s,
'ymax': m+mult*s}) | python | def mean_sdl(series, mult=2):
"""
mean plus or minus a constant times the standard deviation
"""
m = series.mean()
s = series.std()
return pd.DataFrame({'y': [m],
'ymin': m-mult*s,
'ymax': m+mult*s}) | [
"def",
"mean_sdl",
"(",
"series",
",",
"mult",
"=",
"2",
")",
":",
"m",
"=",
"series",
".",
"mean",
"(",
")",
"s",
"=",
"series",
".",
"std",
"(",
")",
"return",
"pd",
".",
"DataFrame",
"(",
"{",
"'y'",
":",
"[",
"m",
"]",
",",
"'ymin'",
":",... | mean plus or minus a constant times the standard deviation | [
"mean",
"plus",
"or",
"minus",
"a",
"constant",
"times",
"the",
"standard",
"deviation"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat_summary.py#L54-L62 | train |
has2k1/plotnine | plotnine/stats/stat_summary.py | median_hilow | def median_hilow(series, confidence_interval=0.95):
"""
Median and a selected pair of outer quantiles having equal tail areas
"""
tail = (1 - confidence_interval) / 2
return pd.DataFrame({'y': [np.median(series)],
'ymin': np.percentile(series, 100 * tail),
... | python | def median_hilow(series, confidence_interval=0.95):
"""
Median and a selected pair of outer quantiles having equal tail areas
"""
tail = (1 - confidence_interval) / 2
return pd.DataFrame({'y': [np.median(series)],
'ymin': np.percentile(series, 100 * tail),
... | [
"def",
"median_hilow",
"(",
"series",
",",
"confidence_interval",
"=",
"0.95",
")",
":",
"tail",
"=",
"(",
"1",
"-",
"confidence_interval",
")",
"/",
"2",
"return",
"pd",
".",
"DataFrame",
"(",
"{",
"'y'",
":",
"[",
"np",
".",
"median",
"(",
"series",
... | Median and a selected pair of outer quantiles having equal tail areas | [
"Median",
"and",
"a",
"selected",
"pair",
"of",
"outer",
"quantiles",
"having",
"equal",
"tail",
"areas"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat_summary.py#L65-L72 | train |
has2k1/plotnine | plotnine/stats/stat_summary.py | mean_se | def mean_se(series, mult=1):
"""
Calculate mean and standard errors on either side
"""
m = np.mean(series)
se = mult * np.sqrt(np.var(series) / len(series))
return pd.DataFrame({'y': [m],
'ymin': m-se,
'ymax': m+se}) | python | def mean_se(series, mult=1):
"""
Calculate mean and standard errors on either side
"""
m = np.mean(series)
se = mult * np.sqrt(np.var(series) / len(series))
return pd.DataFrame({'y': [m],
'ymin': m-se,
'ymax': m+se}) | [
"def",
"mean_se",
"(",
"series",
",",
"mult",
"=",
"1",
")",
":",
"m",
"=",
"np",
".",
"mean",
"(",
"series",
")",
"se",
"=",
"mult",
"*",
"np",
".",
"sqrt",
"(",
"np",
".",
"var",
"(",
"series",
")",
"/",
"len",
"(",
"series",
")",
")",
"r... | Calculate mean and standard errors on either side | [
"Calculate",
"mean",
"and",
"standard",
"errors",
"on",
"either",
"side"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat_summary.py#L75-L83 | train |
has2k1/plotnine | plotnine/facets/facet_null.py | facet_null.set_breaks_and_labels | def set_breaks_and_labels(self, ranges, layout_info, pidx):
"""
Add breaks and labels to the axes
Parameters
----------
ranges : dict-like
range information for the axes
layout_info : dict-like
facet layout information
pidx : int
... | python | def set_breaks_and_labels(self, ranges, layout_info, pidx):
"""
Add breaks and labels to the axes
Parameters
----------
ranges : dict-like
range information for the axes
layout_info : dict-like
facet layout information
pidx : int
... | [
"def",
"set_breaks_and_labels",
"(",
"self",
",",
"ranges",
",",
"layout_info",
",",
"pidx",
")",
":",
"ax",
"=",
"self",
".",
"axs",
"[",
"pidx",
"]",
"facet",
".",
"set_breaks_and_labels",
"(",
"self",
",",
"ranges",
",",
"layout_info",
",",
"pidx",
")... | Add breaks and labels to the axes
Parameters
----------
ranges : dict-like
range information for the axes
layout_info : dict-like
facet layout information
pidx : int
Panel index | [
"Add",
"breaks",
"and",
"labels",
"to",
"the",
"axes"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet_null.py#L27-L43 | train |
has2k1/plotnine | plotnine/facets/facet_null.py | facet_null.spaceout_and_resize_panels | def spaceout_and_resize_panels(self):
"""
Adjust the space between the panels
"""
# Only deal with the aspect ratio
figure = self.figure
theme = self.theme
try:
aspect_ratio = theme.themeables.property('aspect_ratio')
except KeyError:
... | python | def spaceout_and_resize_panels(self):
"""
Adjust the space between the panels
"""
# Only deal with the aspect ratio
figure = self.figure
theme = self.theme
try:
aspect_ratio = theme.themeables.property('aspect_ratio')
except KeyError:
... | [
"def",
"spaceout_and_resize_panels",
"(",
"self",
")",
":",
"# Only deal with the aspect ratio",
"figure",
"=",
"self",
".",
"figure",
"theme",
"=",
"self",
".",
"theme",
"try",
":",
"aspect_ratio",
"=",
"theme",
".",
"themeables",
".",
"property",
"(",
"'aspect... | Adjust the space between the panels | [
"Adjust",
"the",
"space",
"between",
"the",
"panels"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet_null.py#L45-L72 | train |
has2k1/plotnine | plotnine/geoms/geom_path.py | _draw_segments | def _draw_segments(data, ax, **params):
"""
Draw independent line segments between all the
points
"""
color = to_rgba(data['color'], data['alpha'])
# All we do is line-up all the points in a group
# into segments, all in a single list.
# Along the way the other parameters are put in
... | python | def _draw_segments(data, ax, **params):
"""
Draw independent line segments between all the
points
"""
color = to_rgba(data['color'], data['alpha'])
# All we do is line-up all the points in a group
# into segments, all in a single list.
# Along the way the other parameters are put in
... | [
"def",
"_draw_segments",
"(",
"data",
",",
"ax",
",",
"*",
"*",
"params",
")",
":",
"color",
"=",
"to_rgba",
"(",
"data",
"[",
"'color'",
"]",
",",
"data",
"[",
"'alpha'",
"]",
")",
"# All we do is line-up all the points in a group",
"# into segments, all in a s... | Draw independent line segments between all the
points | [
"Draw",
"independent",
"line",
"segments",
"between",
"all",
"the",
"points"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom_path.py#L341-L375 | train |
has2k1/plotnine | plotnine/geoms/geom_path.py | _draw_lines | def _draw_lines(data, ax, **params):
"""
Draw a path with the same characteristics from the
first point to the last point
"""
color = to_rgba(data['color'].iloc[0], data['alpha'].iloc[0])
join_style = _get_joinstyle(data, params)
lines = mlines.Line2D(data['x'],
dat... | python | def _draw_lines(data, ax, **params):
"""
Draw a path with the same characteristics from the
first point to the last point
"""
color = to_rgba(data['color'].iloc[0], data['alpha'].iloc[0])
join_style = _get_joinstyle(data, params)
lines = mlines.Line2D(data['x'],
dat... | [
"def",
"_draw_lines",
"(",
"data",
",",
"ax",
",",
"*",
"*",
"params",
")",
":",
"color",
"=",
"to_rgba",
"(",
"data",
"[",
"'color'",
"]",
".",
"iloc",
"[",
"0",
"]",
",",
"data",
"[",
"'alpha'",
"]",
".",
"iloc",
"[",
"0",
"]",
")",
"join_sty... | Draw a path with the same characteristics from the
first point to the last point | [
"Draw",
"a",
"path",
"with",
"the",
"same",
"characteristics",
"from",
"the",
"first",
"point",
"to",
"the",
"last",
"point"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom_path.py#L378-L392 | train |
has2k1/plotnine | plotnine/geoms/geom_path.py | arrow.get_paths | def get_paths(self, x1, y1, x2, y2, panel_params, coord, ax):
"""
Compute paths that create the arrow heads
Parameters
----------
x1, y1, x2, y2 : array_like
List of points that define the tails of the arrows.
The arrow heads will be at x1, y1. If you nee... | python | def get_paths(self, x1, y1, x2, y2, panel_params, coord, ax):
"""
Compute paths that create the arrow heads
Parameters
----------
x1, y1, x2, y2 : array_like
List of points that define the tails of the arrows.
The arrow heads will be at x1, y1. If you nee... | [
"def",
"get_paths",
"(",
"self",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"panel_params",
",",
"coord",
",",
"ax",
")",
":",
"Path",
"=",
"mpath",
".",
"Path",
"# Create reusable lists of vertices and codes",
"# arrowhead path has 3 vertices (Nones),",
"... | Compute paths that create the arrow heads
Parameters
----------
x1, y1, x2, y2 : array_like
List of points that define the tails of the arrows.
The arrow heads will be at x1, y1. If you need them
at x2, y2 reverse the input.
Returns
-------
... | [
"Compute",
"paths",
"that",
"create",
"the",
"arrow",
"heads"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom_path.py#L276-L338 | train |
has2k1/plotnine | plotnine/facets/facet.py | combine_vars | def combine_vars(data, environment=None, vars=None, drop=True):
"""
Base layout function that generates all combinations of data
needed for facetting
The first data frame in the list should be the default data
for the plot. Other data frames in the list are ones that are
added to the layers.
... | python | def combine_vars(data, environment=None, vars=None, drop=True):
"""
Base layout function that generates all combinations of data
needed for facetting
The first data frame in the list should be the default data
for the plot. Other data frames in the list are ones that are
added to the layers.
... | [
"def",
"combine_vars",
"(",
"data",
",",
"environment",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"drop",
"=",
"True",
")",
":",
"if",
"not",
"vars",
":",
"return",
"pd",
".",
"DataFrame",
"(",
")",
"# For each layer, compute the facet values",
"values",
... | Base layout function that generates all combinations of data
needed for facetting
The first data frame in the list should be the default data
for the plot. Other data frames in the list are ones that are
added to the layers. | [
"Base",
"layout",
"function",
"that",
"generates",
"all",
"combinations",
"of",
"data",
"needed",
"for",
"facetting",
"The",
"first",
"data",
"frame",
"in",
"the",
"list",
"should",
"be",
"the",
"default",
"data",
"for",
"the",
"plot",
".",
"Other",
"data",
... | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L556-L603 | train |
has2k1/plotnine | plotnine/facets/facet.py | unique_combs | def unique_combs(df):
"""
Return data frame with all possible combinations
of the values in the columns
"""
# List of unique values from every column
lst = (x.unique() for x in (df[c] for c in df))
rows = list(itertools.product(*lst))
_df = pd.DataFrame(rows, columns=df.columns)
# p... | python | def unique_combs(df):
"""
Return data frame with all possible combinations
of the values in the columns
"""
# List of unique values from every column
lst = (x.unique() for x in (df[c] for c in df))
rows = list(itertools.product(*lst))
_df = pd.DataFrame(rows, columns=df.columns)
# p... | [
"def",
"unique_combs",
"(",
"df",
")",
":",
"# List of unique values from every column",
"lst",
"=",
"(",
"x",
".",
"unique",
"(",
")",
"for",
"x",
"in",
"(",
"df",
"[",
"c",
"]",
"for",
"c",
"in",
"df",
")",
")",
"rows",
"=",
"list",
"(",
"itertools... | Return data frame with all possible combinations
of the values in the columns | [
"Return",
"data",
"frame",
"with",
"all",
"possible",
"combinations",
"of",
"the",
"values",
"in",
"the",
"columns"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L606-L619 | train |
has2k1/plotnine | plotnine/facets/facet.py | eval_facet_vars | def eval_facet_vars(data, vars, env):
"""
Evaluate facet variables
Parameters
----------
data : DataFrame
Factet dataframe
vars : list
Facet variables
env : environment
Plot environment
Returns
-------
facet_vals : DataFrame
Facet values that cor... | python | def eval_facet_vars(data, vars, env):
"""
Evaluate facet variables
Parameters
----------
data : DataFrame
Factet dataframe
vars : list
Facet variables
env : environment
Plot environment
Returns
-------
facet_vals : DataFrame
Facet values that cor... | [
"def",
"eval_facet_vars",
"(",
"data",
",",
"vars",
",",
"env",
")",
":",
"# To allow expressions in facet formula",
"def",
"I",
"(",
"value",
")",
":",
"return",
"value",
"env",
"=",
"env",
".",
"with_outer_namespace",
"(",
"{",
"'I'",
":",
"I",
"}",
")",... | Evaluate facet variables
Parameters
----------
data : DataFrame
Factet dataframe
vars : list
Facet variables
env : environment
Plot environment
Returns
-------
facet_vals : DataFrame
Facet values that correspond to the specified
variables. | [
"Evaluate",
"facet",
"variables"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L654-L697 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet.map | def map(self, data, layout):
"""
Assign a data points to panels
Parameters
----------
data : DataFrame
Data for a layer
layout : DataFrame
As returned by self.compute_layout
Returns
-------
data : DataFrame
Dat... | python | def map(self, data, layout):
"""
Assign a data points to panels
Parameters
----------
data : DataFrame
Data for a layer
layout : DataFrame
As returned by self.compute_layout
Returns
-------
data : DataFrame
Dat... | [
"def",
"map",
"(",
"self",
",",
"data",
",",
"layout",
")",
":",
"msg",
"=",
"\"{} should implement this method.\"",
"raise",
"NotImplementedError",
"(",
"msg",
".",
"format",
"(",
"self",
".",
"__class",
".",
"__name__",
")",
")"
] | Assign a data points to panels
Parameters
----------
data : DataFrame
Data for a layer
layout : DataFrame
As returned by self.compute_layout
Returns
-------
data : DataFrame
Data with all points mapped to the panels
... | [
"Assign",
"a",
"data",
"points",
"to",
"panels"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L160-L179 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet.train_position_scales | def train_position_scales(self, layout, layers):
"""
Compute ranges for the x and y scales
"""
_layout = layout.layout
panel_scales_x = layout.panel_scales_x
panel_scales_y = layout.panel_scales_y
# loop over each layer, training x and y scales in turn
fo... | python | def train_position_scales(self, layout, layers):
"""
Compute ranges for the x and y scales
"""
_layout = layout.layout
panel_scales_x = layout.panel_scales_x
panel_scales_y = layout.panel_scales_y
# loop over each layer, training x and y scales in turn
fo... | [
"def",
"train_position_scales",
"(",
"self",
",",
"layout",
",",
"layers",
")",
":",
"_layout",
"=",
"layout",
".",
"layout",
"panel_scales_x",
"=",
"layout",
".",
"panel_scales_x",
"panel_scales_y",
"=",
"layout",
".",
"panel_scales_y",
"# loop over each layer, tra... | Compute ranges for the x and y scales | [
"Compute",
"ranges",
"for",
"the",
"x",
"and",
"y",
"scales"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L210-L236 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet._create_subplots | def _create_subplots(self, fig, layout):
"""
Create suplots and return axs
"""
num_panels = len(layout)
axsarr = np.empty((self.nrow, self.ncol), dtype=object)
# Create axes
i = 1
for row in range(self.nrow):
for col in range(self.ncol):
... | python | def _create_subplots(self, fig, layout):
"""
Create suplots and return axs
"""
num_panels = len(layout)
axsarr = np.empty((self.nrow, self.ncol), dtype=object)
# Create axes
i = 1
for row in range(self.nrow):
for col in range(self.ncol):
... | [
"def",
"_create_subplots",
"(",
"self",
",",
"fig",
",",
"layout",
")",
":",
"num_panels",
"=",
"len",
"(",
"layout",
")",
"axsarr",
"=",
"np",
".",
"empty",
"(",
"(",
"self",
".",
"nrow",
",",
"self",
".",
"ncol",
")",
",",
"dtype",
"=",
"object",... | Create suplots and return axs | [
"Create",
"suplots",
"and",
"return",
"axs"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L319-L350 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet.make_axes | def make_axes(self, figure, layout, coordinates):
"""
Create and return Matplotlib axes
"""
axs = self._create_subplots(figure, layout)
# Used for labelling the x and y axes, the first and
# last axes according to how MPL creates them.
self.first_ax = figure.axes... | python | def make_axes(self, figure, layout, coordinates):
"""
Create and return Matplotlib axes
"""
axs = self._create_subplots(figure, layout)
# Used for labelling the x and y axes, the first and
# last axes according to how MPL creates them.
self.first_ax = figure.axes... | [
"def",
"make_axes",
"(",
"self",
",",
"figure",
",",
"layout",
",",
"coordinates",
")",
":",
"axs",
"=",
"self",
".",
"_create_subplots",
"(",
"figure",
",",
"layout",
")",
"# Used for labelling the x and y axes, the first and",
"# last axes according to how MPL creates... | Create and return Matplotlib axes | [
"Create",
"and",
"return",
"Matplotlib",
"axes"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L352-L364 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet.strip_size | def strip_size(self, location='top', num_lines=None):
"""
Breadth of the strip background in inches
Parameters
----------
location : str in ``['top', 'right']``
Location of the strip text
num_lines : int
Number of text lines
"""
dp... | python | def strip_size(self, location='top', num_lines=None):
"""
Breadth of the strip background in inches
Parameters
----------
location : str in ``['top', 'right']``
Location of the strip text
num_lines : int
Number of text lines
"""
dp... | [
"def",
"strip_size",
"(",
"self",
",",
"location",
"=",
"'top'",
",",
"num_lines",
"=",
"None",
")",
":",
"dpi",
"=",
"72",
"theme",
"=",
"self",
".",
"theme",
"get_property",
"=",
"theme",
".",
"themeables",
".",
"property",
"if",
"location",
"==",
"'... | Breadth of the strip background in inches
Parameters
----------
location : str in ``['top', 'right']``
Location of the strip text
num_lines : int
Number of text lines | [
"Breadth",
"of",
"the",
"strip",
"background",
"in",
"inches"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L392-L436 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet.strip_dimensions | def strip_dimensions(self, text_lines, location, pid):
"""
Calculate the dimension
Returns
-------
out : types.SimpleNamespace
A structure with all the coordinates required
to draw the strip text and the background box.
"""
dpi = 72
... | python | def strip_dimensions(self, text_lines, location, pid):
"""
Calculate the dimension
Returns
-------
out : types.SimpleNamespace
A structure with all the coordinates required
to draw the strip text and the background box.
"""
dpi = 72
... | [
"def",
"strip_dimensions",
"(",
"self",
",",
"text_lines",
",",
"location",
",",
"pid",
")",
":",
"dpi",
"=",
"72",
"num_lines",
"=",
"len",
"(",
"text_lines",
")",
"get_property",
"=",
"self",
".",
"theme",
".",
"themeables",
".",
"property",
"ax",
"=",... | Calculate the dimension
Returns
-------
out : types.SimpleNamespace
A structure with all the coordinates required
to draw the strip text and the background box. | [
"Calculate",
"the",
"dimension"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L438-L505 | train |
has2k1/plotnine | plotnine/facets/facet.py | facet.draw_strip_text | def draw_strip_text(self, text_lines, location, pid):
"""
Create a background patch and put a label on it
"""
ax = self.axs[pid]
themeable = self.figure._themeable
dim = self.strip_dimensions(text_lines, location, pid)
if location == 'right':
rotation... | python | def draw_strip_text(self, text_lines, location, pid):
"""
Create a background patch and put a label on it
"""
ax = self.axs[pid]
themeable = self.figure._themeable
dim = self.strip_dimensions(text_lines, location, pid)
if location == 'right':
rotation... | [
"def",
"draw_strip_text",
"(",
"self",
",",
"text_lines",
",",
"location",
",",
"pid",
")",
":",
"ax",
"=",
"self",
".",
"axs",
"[",
"pid",
"]",
"themeable",
"=",
"self",
".",
"figure",
".",
"_themeable",
"dim",
"=",
"self",
".",
"strip_dimensions",
"(... | Create a background patch and put a label on it | [
"Create",
"a",
"background",
"patch",
"and",
"put",
"a",
"label",
"on",
"it"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L507-L553 | train |
has2k1/plotnine | plotnine/facets/facet.py | MyFixedFormatter.format_data | def format_data(self, value):
"""
Return a formatted string representation of a number.
"""
s = locale.format_string('%1.10e', (value,))
return self.fix_minus(s) | python | def format_data(self, value):
"""
Return a formatted string representation of a number.
"""
s = locale.format_string('%1.10e', (value,))
return self.fix_minus(s) | [
"def",
"format_data",
"(",
"self",
",",
"value",
")",
":",
"s",
"=",
"locale",
".",
"format_string",
"(",
"'%1.10e'",
",",
"(",
"value",
",",
")",
")",
"return",
"self",
".",
"fix_minus",
"(",
"s",
")"
] | Return a formatted string representation of a number. | [
"Return",
"a",
"formatted",
"string",
"representation",
"of",
"a",
"number",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet.py#L701-L706 | train |
has2k1/plotnine | plotnine/guides/guide_colorbar.py | add_interpolated_colorbar | def add_interpolated_colorbar(da, colors, direction):
"""
Add 'rastered' colorbar to DrawingArea
"""
# Special case that arises due to not so useful
# aesthetic mapping.
if len(colors) == 1:
colors = [colors[0], colors[0]]
# Number of horizontal egdes(breaks) in the grid
# No ne... | python | def add_interpolated_colorbar(da, colors, direction):
"""
Add 'rastered' colorbar to DrawingArea
"""
# Special case that arises due to not so useful
# aesthetic mapping.
if len(colors) == 1:
colors = [colors[0], colors[0]]
# Number of horizontal egdes(breaks) in the grid
# No ne... | [
"def",
"add_interpolated_colorbar",
"(",
"da",
",",
"colors",
",",
"direction",
")",
":",
"# Special case that arises due to not so useful",
"# aesthetic mapping.",
"if",
"len",
"(",
"colors",
")",
"==",
"1",
":",
"colors",
"=",
"[",
"colors",
"[",
"0",
"]",
","... | Add 'rastered' colorbar to DrawingArea | [
"Add",
"rastered",
"colorbar",
"to",
"DrawingArea"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L242-L292 | train |
has2k1/plotnine | plotnine/guides/guide_colorbar.py | add_segmented_colorbar | def add_segmented_colorbar(da, colors, direction):
"""
Add 'non-rastered' colorbar to DrawingArea
"""
nbreak = len(colors)
if direction == 'vertical':
linewidth = da.height/nbreak
verts = [None] * nbreak
x1, x2 = 0, da.width
for i, color in enumerate(colors):
... | python | def add_segmented_colorbar(da, colors, direction):
"""
Add 'non-rastered' colorbar to DrawingArea
"""
nbreak = len(colors)
if direction == 'vertical':
linewidth = da.height/nbreak
verts = [None] * nbreak
x1, x2 = 0, da.width
for i, color in enumerate(colors):
... | [
"def",
"add_segmented_colorbar",
"(",
"da",
",",
"colors",
",",
"direction",
")",
":",
"nbreak",
"=",
"len",
"(",
"colors",
")",
"if",
"direction",
"==",
"'vertical'",
":",
"linewidth",
"=",
"da",
".",
"height",
"/",
"nbreak",
"verts",
"=",
"[",
"None",
... | Add 'non-rastered' colorbar to DrawingArea | [
"Add",
"non",
"-",
"rastered",
"colorbar",
"to",
"DrawingArea"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L295-L321 | train |
has2k1/plotnine | plotnine/guides/guide_colorbar.py | create_labels | def create_labels(da, labels, locations, direction):
"""
Return an OffsetBox with label texts
"""
# The box dimensions are determined by the size of
# the text objects. We put two dummy children at
# either end to gaurantee that when center packed
# the labels in the labels_box matchup with ... | python | def create_labels(da, labels, locations, direction):
"""
Return an OffsetBox with label texts
"""
# The box dimensions are determined by the size of
# the text objects. We put two dummy children at
# either end to gaurantee that when center packed
# the labels in the labels_box matchup with ... | [
"def",
"create_labels",
"(",
"da",
",",
"labels",
",",
"locations",
",",
"direction",
")",
":",
"# The box dimensions are determined by the size of",
"# the text objects. We put two dummy children at",
"# either end to gaurantee that when center packed",
"# the labels in the labels_box... | Return an OffsetBox with label texts | [
"Return",
"an",
"OffsetBox",
"with",
"label",
"texts"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L344-L381 | train |
has2k1/plotnine | plotnine/guides/guide_colorbar.py | guide_colorbar.create_geoms | def create_geoms(self, plot):
"""
This guide is not geom based
Return self if colorbar will be drawn and None if not.
"""
for l in plot.layers:
exclude = set()
if isinstance(l.show_legend, dict):
l.show_legend = rename_aesthetics(l.show_le... | python | def create_geoms(self, plot):
"""
This guide is not geom based
Return self if colorbar will be drawn and None if not.
"""
for l in plot.layers:
exclude = set()
if isinstance(l.show_legend, dict):
l.show_legend = rename_aesthetics(l.show_le... | [
"def",
"create_geoms",
"(",
"self",
",",
"plot",
")",
":",
"for",
"l",
"in",
"plot",
".",
"layers",
":",
"exclude",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"l",
".",
"show_legend",
",",
"dict",
")",
":",
"l",
".",
"show_legend",
"=",
"rename... | This guide is not geom based
Return self if colorbar will be drawn and None if not. | [
"This",
"guide",
"is",
"not",
"geom",
"based"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L108-L132 | train |
has2k1/plotnine | plotnine/guides/guide_colorbar.py | MyAuxTransformBox.draw | def draw(self, renderer):
"""
Draw the children
"""
dpi_cor = renderer.points_to_pixels(1.)
self.dpi_transform.clear()
self.dpi_transform.scale(dpi_cor, dpi_cor)
for c in self._children:
c.draw(renderer)
self.stale = False | python | def draw(self, renderer):
"""
Draw the children
"""
dpi_cor = renderer.points_to_pixels(1.)
self.dpi_transform.clear()
self.dpi_transform.scale(dpi_cor, dpi_cor)
for c in self._children:
c.draw(renderer)
self.stale = False | [
"def",
"draw",
"(",
"self",
",",
"renderer",
")",
":",
"dpi_cor",
"=",
"renderer",
".",
"points_to_pixels",
"(",
"1.",
")",
"self",
".",
"dpi_transform",
".",
"clear",
"(",
")",
"self",
".",
"dpi_transform",
".",
"scale",
"(",
"dpi_cor",
",",
"dpi_cor",
... | Draw the children | [
"Draw",
"the",
"children"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide_colorbar.py#L404-L415 | train |
has2k1/plotnine | plotnine/themes/themeable.py | themeable.from_class_name | def from_class_name(name, theme_element):
"""
Create an themeable by name
Parameters
----------
name : str
Class name
theme_element : element object
One of :class:`element_line`, :class:`element_rect`,
:class:`element_text` or :class:`... | python | def from_class_name(name, theme_element):
"""
Create an themeable by name
Parameters
----------
name : str
Class name
theme_element : element object
One of :class:`element_line`, :class:`element_rect`,
:class:`element_text` or :class:`... | [
"def",
"from_class_name",
"(",
"name",
",",
"theme_element",
")",
":",
"msg",
"=",
"\"No such themeable element {}\"",
".",
"format",
"(",
"name",
")",
"try",
":",
"klass",
"=",
"themeable",
".",
"_registry",
"[",
"name",
"]",
"except",
"KeyError",
":",
"rai... | Create an themeable by name
Parameters
----------
name : str
Class name
theme_element : element object
One of :class:`element_line`, :class:`element_rect`,
:class:`element_text` or :class:`element_blank`
Returns
-------
out : ... | [
"Create",
"an",
"themeable",
"by",
"name"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/themeable.py#L96-L121 | train |
has2k1/plotnine | plotnine/themes/themeable.py | themeable.merge | def merge(self, other):
"""
Merge properties of other into self
Raises ValueError if any them are a blank
"""
if self.is_blank() or other.is_blank():
raise ValueError('Cannot merge if there is a blank.')
else:
self.properties.update(other.properti... | python | def merge(self, other):
"""
Merge properties of other into self
Raises ValueError if any them are a blank
"""
if self.is_blank() or other.is_blank():
raise ValueError('Cannot merge if there is a blank.')
else:
self.properties.update(other.properti... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"is_blank",
"(",
")",
"or",
"other",
".",
"is_blank",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot merge if there is a blank.'",
")",
"else",
":",
"self",
".",
"properties",
"... | Merge properties of other into self
Raises ValueError if any them are a blank | [
"Merge",
"properties",
"of",
"other",
"into",
"self"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/themeable.py#L129-L138 | train |
has2k1/plotnine | plotnine/themes/themeable.py | Themeables.update | def update(self, other):
"""
Update themeables with those from `other`
This method takes care of inserting the `themeable`
into the underlying dictionary. Before doing the
insertion, any existing themeables that will be
affected by a new from `other` will either be merge... | python | def update(self, other):
"""
Update themeables with those from `other`
This method takes care of inserting the `themeable`
into the underlying dictionary. Before doing the
insertion, any existing themeables that will be
affected by a new from `other` will either be merge... | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"for",
"new",
"in",
"other",
".",
"values",
"(",
")",
":",
"new_key",
"=",
"new",
".",
"__class__",
".",
"__name__",
"# 1st in the mro is self, the",
"# last 2 are (themeable, object)",
"for",
"child",
"in"... | Update themeables with those from `other`
This method takes care of inserting the `themeable`
into the underlying dictionary. Before doing the
insertion, any existing themeables that will be
affected by a new from `other` will either be merged
or removed. This makes sure that a ... | [
"Update",
"themeables",
"with",
"those",
"from",
"other"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/themeable.py#L225-L256 | train |
has2k1/plotnine | plotnine/themes/themeable.py | Themeables.values | def values(self):
"""
Return a list themeables sorted in reverse based
on the their depth in the inheritance hierarchy.
The sorting is key applying and merging the themeables
so that they do not clash i.e :class:`axis_line`
applied before :class:`axis_line_x`.
""... | python | def values(self):
"""
Return a list themeables sorted in reverse based
on the their depth in the inheritance hierarchy.
The sorting is key applying and merging the themeables
so that they do not clash i.e :class:`axis_line`
applied before :class:`axis_line_x`.
""... | [
"def",
"values",
"(",
"self",
")",
":",
"def",
"key",
"(",
"th",
")",
":",
"return",
"len",
"(",
"th",
".",
"__class__",
".",
"__mro__",
")",
"return",
"sorted",
"(",
"dict",
".",
"values",
"(",
"self",
")",
",",
"key",
"=",
"key",
",",
"reverse"... | Return a list themeables sorted in reverse based
on the their depth in the inheritance hierarchy.
The sorting is key applying and merging the themeables
so that they do not clash i.e :class:`axis_line`
applied before :class:`axis_line_x`. | [
"Return",
"a",
"list",
"themeables",
"sorted",
"in",
"reverse",
"based",
"on",
"the",
"their",
"depth",
"in",
"the",
"inheritance",
"hierarchy",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/themes/themeable.py#L258-L270 | train |
has2k1/plotnine | plotnine/positions/position.py | position.setup_data | def setup_data(self, data, params):
"""
Verify & return data
"""
check_required_aesthetics(
self.REQUIRED_AES,
data.columns,
self.__class__.__name__)
return data | python | def setup_data(self, data, params):
"""
Verify & return data
"""
check_required_aesthetics(
self.REQUIRED_AES,
data.columns,
self.__class__.__name__)
return data | [
"def",
"setup_data",
"(",
"self",
",",
"data",
",",
"params",
")",
":",
"check_required_aesthetics",
"(",
"self",
".",
"REQUIRED_AES",
",",
"data",
".",
"columns",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
"return",
"data"
] | Verify & return data | [
"Verify",
"&",
"return",
"data"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position.py#L24-L32 | train |
has2k1/plotnine | plotnine/positions/position.py | position.compute_layer | def compute_layer(cls, data, params, layout):
"""
Compute position for the layer in all panels
Positions can override this function instead of
`compute_panel` if the position computations are
independent of the panel. i.e when not colliding
"""
def fn(pdata):
... | python | def compute_layer(cls, data, params, layout):
"""
Compute position for the layer in all panels
Positions can override this function instead of
`compute_panel` if the position computations are
independent of the panel. i.e when not colliding
"""
def fn(pdata):
... | [
"def",
"compute_layer",
"(",
"cls",
",",
"data",
",",
"params",
",",
"layout",
")",
":",
"def",
"fn",
"(",
"pdata",
")",
":",
"\"\"\"\n Helper compute function\n \"\"\"",
"# Given data belonging to a specific panel, grab",
"# the corresponding scales and... | Compute position for the layer in all panels
Positions can override this function instead of
`compute_panel` if the position computations are
independent of the panel. i.e when not colliding | [
"Compute",
"position",
"for",
"the",
"layer",
"in",
"all",
"panels"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position.py#L35-L55 | train |
has2k1/plotnine | plotnine/positions/position.py | position.compute_panel | def compute_panel(cls, data, scales, params):
"""
Positions must override this function
Notes
-----
Make necessary adjustments to the columns in the dataframe.
Create the position transformation functions and
use self.transform_position() do the rest.
S... | python | def compute_panel(cls, data, scales, params):
"""
Positions must override this function
Notes
-----
Make necessary adjustments to the columns in the dataframe.
Create the position transformation functions and
use self.transform_position() do the rest.
S... | [
"def",
"compute_panel",
"(",
"cls",
",",
"data",
",",
"scales",
",",
"params",
")",
":",
"msg",
"=",
"'{} needs to implement this method'",
"raise",
"NotImplementedError",
"(",
"msg",
".",
"format",
"(",
"cls",
".",
"__name__",
")",
")"
] | Positions must override this function
Notes
-----
Make necessary adjustments to the columns in the dataframe.
Create the position transformation functions and
use self.transform_position() do the rest.
See Also
--------
position_jitter.compute_panel | [
"Positions",
"must",
"override",
"this",
"function"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position.py#L58-L74 | train |
has2k1/plotnine | plotnine/positions/position.py | position.transform_position | def transform_position(data, trans_x=None, trans_y=None):
"""
Transform all the variables that map onto the x and y scales.
Parameters
----------
data : dataframe
trans_x : function
Transforms x scale mappings
Takes one argument, either a scala... | python | def transform_position(data, trans_x=None, trans_y=None):
"""
Transform all the variables that map onto the x and y scales.
Parameters
----------
data : dataframe
trans_x : function
Transforms x scale mappings
Takes one argument, either a scala... | [
"def",
"transform_position",
"(",
"data",
",",
"trans_x",
"=",
"None",
",",
"trans_y",
"=",
"None",
")",
":",
"# Aesthetics that map onto the x and y scales",
"X",
"=",
"{",
"'x'",
",",
"'xmin'",
",",
"'xmax'",
",",
"'xend'",
",",
"'xintercept'",
"}",
"Y",
"... | Transform all the variables that map onto the x and y scales.
Parameters
----------
data : dataframe
trans_x : function
Transforms x scale mappings
Takes one argument, either a scalar or an array-type
trans_y : function
Transforms y scale m... | [
"Transform",
"all",
"the",
"variables",
"that",
"map",
"onto",
"the",
"x",
"and",
"y",
"scales",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position.py#L77-L103 | train |
has2k1/plotnine | plotnine/positions/position.py | position.from_geom | def from_geom(geom):
"""
Create and return a position object for the geom
Parameters
----------
geom : geom
An instantiated geom object.
Returns
-------
out : position
A position object
Raises :class:`PlotnineError` if un... | python | def from_geom(geom):
"""
Create and return a position object for the geom
Parameters
----------
geom : geom
An instantiated geom object.
Returns
-------
out : position
A position object
Raises :class:`PlotnineError` if un... | [
"def",
"from_geom",
"(",
"geom",
")",
":",
"name",
"=",
"geom",
".",
"params",
"[",
"'position'",
"]",
"if",
"issubclass",
"(",
"type",
"(",
"name",
")",
",",
"position",
")",
":",
"return",
"name",
"if",
"isinstance",
"(",
"name",
",",
"type",
")",
... | Create and return a position object for the geom
Parameters
----------
geom : geom
An instantiated geom object.
Returns
-------
out : position
A position object
Raises :class:`PlotnineError` if unable to create a `position`. | [
"Create",
"and",
"return",
"a",
"position",
"object",
"for",
"the",
"geom"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position.py#L106-L136 | train |
has2k1/plotnine | plotnine/scales/scales.py | make_scale | def make_scale(ae, series, *args, **kwargs):
"""
Return a proper scale object for the series
The scale is for the aesthetic ae, and args & kwargs
are passed on to the scale creating class
"""
stype = scale_type(series)
# filter parameters by scale type
if stype == 'discrete':
w... | python | def make_scale(ae, series, *args, **kwargs):
"""
Return a proper scale object for the series
The scale is for the aesthetic ae, and args & kwargs
are passed on to the scale creating class
"""
stype = scale_type(series)
# filter parameters by scale type
if stype == 'discrete':
w... | [
"def",
"make_scale",
"(",
"ae",
",",
"series",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"stype",
"=",
"scale_type",
"(",
"series",
")",
"# filter parameters by scale type",
"if",
"stype",
"==",
"'discrete'",
":",
"with",
"suppress",
"(",
"KeyEr... | Return a proper scale object for the series
The scale is for the aesthetic ae, and args & kwargs
are passed on to the scale creating class | [
"Return",
"a",
"proper",
"scale",
"object",
"for",
"the",
"series"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L293-L309 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.append | def append(self, sc):
"""
Add scale 'sc' and remove any previous
scales that cover the same aesthetics
"""
ae = sc.aesthetics[0]
cover_ae = self.find(ae)
if any(cover_ae):
warn(_TPL_DUPLICATE_SCALE.format(ae), PlotnineWarning)
idx = cover_a... | python | def append(self, sc):
"""
Add scale 'sc' and remove any previous
scales that cover the same aesthetics
"""
ae = sc.aesthetics[0]
cover_ae = self.find(ae)
if any(cover_ae):
warn(_TPL_DUPLICATE_SCALE.format(ae), PlotnineWarning)
idx = cover_a... | [
"def",
"append",
"(",
"self",
",",
"sc",
")",
":",
"ae",
"=",
"sc",
".",
"aesthetics",
"[",
"0",
"]",
"cover_ae",
"=",
"self",
".",
"find",
"(",
"ae",
")",
"if",
"any",
"(",
"cover_ae",
")",
":",
"warn",
"(",
"_TPL_DUPLICATE_SCALE",
".",
"format",
... | Add scale 'sc' and remove any previous
scales that cover the same aesthetics | [
"Add",
"scale",
"sc",
"and",
"remove",
"any",
"previous",
"scales",
"that",
"cover",
"the",
"same",
"aesthetics"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L20-L32 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.input | def input(self):
"""
Return a list of all the aesthetics covered by
the scales.
"""
lst = [s.aesthetics for s in self]
return list(itertools.chain(*lst)) | python | def input(self):
"""
Return a list of all the aesthetics covered by
the scales.
"""
lst = [s.aesthetics for s in self]
return list(itertools.chain(*lst)) | [
"def",
"input",
"(",
"self",
")",
":",
"lst",
"=",
"[",
"s",
".",
"aesthetics",
"for",
"s",
"in",
"self",
"]",
"return",
"list",
"(",
"itertools",
".",
"chain",
"(",
"*",
"lst",
")",
")"
] | Return a list of all the aesthetics covered by
the scales. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"aesthetics",
"covered",
"by",
"the",
"scales",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L41-L47 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.get_scales | def get_scales(self, aesthetic):
"""
Return the scale for the aesthetic or None if there
isn't one.
These are the scales specified by the user e.g
`ggplot() + scale_x_continuous()`
or those added by default during the plot building
process
"""
... | python | def get_scales(self, aesthetic):
"""
Return the scale for the aesthetic or None if there
isn't one.
These are the scales specified by the user e.g
`ggplot() + scale_x_continuous()`
or those added by default during the plot building
process
"""
... | [
"def",
"get_scales",
"(",
"self",
",",
"aesthetic",
")",
":",
"bool_lst",
"=",
"self",
".",
"find",
"(",
"aesthetic",
")",
"try",
":",
"idx",
"=",
"bool_lst",
".",
"index",
"(",
"True",
")",
"return",
"self",
"[",
"idx",
"]",
"except",
"ValueError",
... | Return the scale for the aesthetic or None if there
isn't one.
These are the scales specified by the user e.g
`ggplot() + scale_x_continuous()`
or those added by default during the plot building
process | [
"Return",
"the",
"scale",
"for",
"the",
"aesthetic",
"or",
"None",
"if",
"there",
"isn",
"t",
"one",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L49-L64 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.non_position_scales | def non_position_scales(self):
"""
Return a list of the non-position scales that
are present
"""
l = [s for s in self
if not ('x' in s.aesthetics) and not ('y' in s.aesthetics)]
return Scales(l) | python | def non_position_scales(self):
"""
Return a list of the non-position scales that
are present
"""
l = [s for s in self
if not ('x' in s.aesthetics) and not ('y' in s.aesthetics)]
return Scales(l) | [
"def",
"non_position_scales",
"(",
"self",
")",
":",
"l",
"=",
"[",
"s",
"for",
"s",
"in",
"self",
"if",
"not",
"(",
"'x'",
"in",
"s",
".",
"aesthetics",
")",
"and",
"not",
"(",
"'y'",
"in",
"s",
".",
"aesthetics",
")",
"]",
"return",
"Scales",
"... | Return a list of the non-position scales that
are present | [
"Return",
"a",
"list",
"of",
"the",
"non",
"-",
"position",
"scales",
"that",
"are",
"present"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L80-L87 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.position_scales | def position_scales(self):
"""
Return a list of the position scales that are present
"""
l = [s for s in self
if ('x' in s.aesthetics) or ('y' in s.aesthetics)]
return Scales(l) | python | def position_scales(self):
"""
Return a list of the position scales that are present
"""
l = [s for s in self
if ('x' in s.aesthetics) or ('y' in s.aesthetics)]
return Scales(l) | [
"def",
"position_scales",
"(",
"self",
")",
":",
"l",
"=",
"[",
"s",
"for",
"s",
"in",
"self",
"if",
"(",
"'x'",
"in",
"s",
".",
"aesthetics",
")",
"or",
"(",
"'y'",
"in",
"s",
".",
"aesthetics",
")",
"]",
"return",
"Scales",
"(",
"l",
")"
] | Return a list of the position scales that are present | [
"Return",
"a",
"list",
"of",
"the",
"position",
"scales",
"that",
"are",
"present"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L89-L95 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.train_df | def train_df(self, df, drop=False):
"""
Train scales from a dataframe
"""
if (len(df) == 0) or (len(self) == 0):
return df
# Each scale trains the columns it understands
for sc in self:
sc.train_df(df)
return df | python | def train_df(self, df, drop=False):
"""
Train scales from a dataframe
"""
if (len(df) == 0) or (len(self) == 0):
return df
# Each scale trains the columns it understands
for sc in self:
sc.train_df(df)
return df | [
"def",
"train_df",
"(",
"self",
",",
"df",
",",
"drop",
"=",
"False",
")",
":",
"if",
"(",
"len",
"(",
"df",
")",
"==",
"0",
")",
"or",
"(",
"len",
"(",
"self",
")",
"==",
"0",
")",
":",
"return",
"df",
"# Each scale trains the columns it understands... | Train scales from a dataframe | [
"Train",
"scales",
"from",
"a",
"dataframe"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L173-L183 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.map_df | def map_df(self, df):
"""
Map values from a dataframe.
Returns dataframe
"""
if (len(df) == 0) or (len(self) == 0):
return df
# Each scale maps the columns it understands
for sc in self:
df = sc.map_df(df)
return df | python | def map_df(self, df):
"""
Map values from a dataframe.
Returns dataframe
"""
if (len(df) == 0) or (len(self) == 0):
return df
# Each scale maps the columns it understands
for sc in self:
df = sc.map_df(df)
return df | [
"def",
"map_df",
"(",
"self",
",",
"df",
")",
":",
"if",
"(",
"len",
"(",
"df",
")",
"==",
"0",
")",
"or",
"(",
"len",
"(",
"self",
")",
"==",
"0",
")",
":",
"return",
"df",
"# Each scale maps the columns it understands",
"for",
"sc",
"in",
"self",
... | Map values from a dataframe.
Returns dataframe | [
"Map",
"values",
"from",
"a",
"dataframe",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L185-L197 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.transform_df | def transform_df(self, df):
"""
Transform values in a dataframe.
Returns dataframe
"""
if (len(df) == 0) or (len(self) == 0):
return df
# Each scale transforms the columns it understands
for sc in self:
df = sc.transform_df(df)
re... | python | def transform_df(self, df):
"""
Transform values in a dataframe.
Returns dataframe
"""
if (len(df) == 0) or (len(self) == 0):
return df
# Each scale transforms the columns it understands
for sc in self:
df = sc.transform_df(df)
re... | [
"def",
"transform_df",
"(",
"self",
",",
"df",
")",
":",
"if",
"(",
"len",
"(",
"df",
")",
"==",
"0",
")",
"or",
"(",
"len",
"(",
"self",
")",
"==",
"0",
")",
":",
"return",
"df",
"# Each scale transforms the columns it understands",
"for",
"sc",
"in",... | Transform values in a dataframe.
Returns dataframe | [
"Transform",
"values",
"in",
"a",
"dataframe",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L199-L211 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.add_defaults | def add_defaults(self, data, aesthetics):
"""
Add default scales for the aesthetics if none are
present
Scales are added only if the aesthetic is mapped to
a column in the dataframe. This function may have to be
called separately after evaluating the aesthetics.
... | python | def add_defaults(self, data, aesthetics):
"""
Add default scales for the aesthetics if none are
present
Scales are added only if the aesthetic is mapped to
a column in the dataframe. This function may have to be
called separately after evaluating the aesthetics.
... | [
"def",
"add_defaults",
"(",
"self",
",",
"data",
",",
"aesthetics",
")",
":",
"if",
"not",
"aesthetics",
":",
"return",
"# aesthetics with scales",
"aws",
"=",
"set",
"(",
")",
"if",
"self",
":",
"for",
"s",
"in",
"(",
"set",
"(",
"sc",
".",
"aesthetic... | Add default scales for the aesthetics if none are
present
Scales are added only if the aesthetic is mapped to
a column in the dataframe. This function may have to be
called separately after evaluating the aesthetics. | [
"Add",
"default",
"scales",
"for",
"the",
"aesthetics",
"if",
"none",
"are",
"present"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L213-L256 | train |
has2k1/plotnine | plotnine/scales/scales.py | Scales.add_missing | def add_missing(self, aesthetics):
"""
Add missing but required scales.
Parameters
----------
aesthetics : list | tuple
Aesthetic names. Typically, ('x', 'y').
"""
# Keep only aesthetics that don't have scales
aesthetics = set(aesthetics) - se... | python | def add_missing(self, aesthetics):
"""
Add missing but required scales.
Parameters
----------
aesthetics : list | tuple
Aesthetic names. Typically, ('x', 'y').
"""
# Keep only aesthetics that don't have scales
aesthetics = set(aesthetics) - se... | [
"def",
"add_missing",
"(",
"self",
",",
"aesthetics",
")",
":",
"# Keep only aesthetics that don't have scales",
"aesthetics",
"=",
"set",
"(",
"aesthetics",
")",
"-",
"set",
"(",
"self",
".",
"input",
"(",
")",
")",
"for",
"ae",
"in",
"aesthetics",
":",
"sc... | Add missing but required scales.
Parameters
----------
aesthetics : list | tuple
Aesthetic names. Typically, ('x', 'y'). | [
"Add",
"missing",
"but",
"required",
"scales",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/scales/scales.py#L258-L273 | train |
has2k1/plotnine | plotnine/facets/labelling.py | label_value | def label_value(label_info, multi_line=True):
"""
Convert series values to str and maybe concatenate them
Parameters
----------
label_info : series
Series whose values will be returned
multi_line : bool
Whether to place each variable on a separate line
Returns
-------
... | python | def label_value(label_info, multi_line=True):
"""
Convert series values to str and maybe concatenate them
Parameters
----------
label_info : series
Series whose values will be returned
multi_line : bool
Whether to place each variable on a separate line
Returns
-------
... | [
"def",
"label_value",
"(",
"label_info",
",",
"multi_line",
"=",
"True",
")",
":",
"label_info",
"=",
"label_info",
".",
"astype",
"(",
"str",
")",
"if",
"not",
"multi_line",
":",
"label_info",
"=",
"collapse_label_lines",
"(",
"label_info",
")",
"return",
"... | Convert series values to str and maybe concatenate them
Parameters
----------
label_info : series
Series whose values will be returned
multi_line : bool
Whether to place each variable on a separate line
Returns
-------
out : series
Label text strings | [
"Convert",
"series",
"values",
"to",
"str",
"and",
"maybe",
"concatenate",
"them"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/labelling.py#L14-L34 | train |
has2k1/plotnine | plotnine/facets/labelling.py | label_both | def label_both(label_info, multi_line=True, sep=': '):
"""
Concatenate the index and the value of the series.
Parameters
----------
label_info : series
Series whose values will be returned. It must have
an index made of variable names.
multi_line : bool
Whether to place ... | python | def label_both(label_info, multi_line=True, sep=': '):
"""
Concatenate the index and the value of the series.
Parameters
----------
label_info : series
Series whose values will be returned. It must have
an index made of variable names.
multi_line : bool
Whether to place ... | [
"def",
"label_both",
"(",
"label_info",
",",
"multi_line",
"=",
"True",
",",
"sep",
"=",
"': '",
")",
":",
"label_info",
"=",
"label_info",
".",
"astype",
"(",
"str",
")",
"for",
"var",
"in",
"label_info",
".",
"index",
":",
"label_info",
"[",
"var",
"... | Concatenate the index and the value of the series.
Parameters
----------
label_info : series
Series whose values will be returned. It must have
an index made of variable names.
multi_line : bool
Whether to place each variable on a separate line
sep : str
Separation ... | [
"Concatenate",
"the",
"index",
"and",
"the",
"value",
"of",
"the",
"series",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/labelling.py#L37-L63 | train |
has2k1/plotnine | plotnine/facets/labelling.py | label_context | def label_context(label_info, multi_line=True, sep=': '):
"""
Create an unabiguous label string
If facetting over a single variable, `label_value` is
used, if two or more variables then `label_both` is used.
Parameters
----------
label_info : series
Series whose values will be retu... | python | def label_context(label_info, multi_line=True, sep=': '):
"""
Create an unabiguous label string
If facetting over a single variable, `label_value` is
used, if two or more variables then `label_both` is used.
Parameters
----------
label_info : series
Series whose values will be retu... | [
"def",
"label_context",
"(",
"label_info",
",",
"multi_line",
"=",
"True",
",",
"sep",
"=",
"': '",
")",
":",
"if",
"len",
"(",
"label_info",
")",
"==",
"1",
":",
"return",
"label_value",
"(",
"label_info",
",",
"multi_line",
")",
"else",
":",
"return",
... | Create an unabiguous label string
If facetting over a single variable, `label_value` is
used, if two or more variables then `label_both` is used.
Parameters
----------
label_info : series
Series whose values will be returned. It must have
an index made of variable names
multi_l... | [
"Create",
"an",
"unabiguous",
"label",
"string"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/labelling.py#L66-L92 | train |
has2k1/plotnine | plotnine/facets/labelling.py | as_labeller | def as_labeller(x, default=label_value, multi_line=True):
"""
Coerse to labeller function
Parameters
----------
x : function | dict
Object to coerce
default : function | str
Default labeller. If it is a string,
it should be the name of one the labelling
functions... | python | def as_labeller(x, default=label_value, multi_line=True):
"""
Coerse to labeller function
Parameters
----------
x : function | dict
Object to coerce
default : function | str
Default labeller. If it is a string,
it should be the name of one the labelling
functions... | [
"def",
"as_labeller",
"(",
"x",
",",
"default",
"=",
"label_value",
",",
"multi_line",
"=",
"True",
")",
":",
"if",
"x",
"is",
"None",
":",
"x",
"=",
"default",
"# One of the labelling functions as string",
"with",
"suppress",
"(",
"KeyError",
",",
"TypeError"... | Coerse to labeller function
Parameters
----------
x : function | dict
Object to coerce
default : function | str
Default labeller. If it is a string,
it should be the name of one the labelling
functions provided by plotnine.
multi_line : bool
Whether to place ... | [
"Coerse",
"to",
"labeller",
"function"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/labelling.py#L101-L154 | train |
has2k1/plotnine | plotnine/facets/labelling.py | labeller | def labeller(rows=None, cols=None, multi_line=True,
default=label_value, **kwargs):
"""
Return a labeller function
Parameters
----------
rows : str | function | None
How to label the rows
cols : str | function | None
How to label the columns
multi_line : bool
... | python | def labeller(rows=None, cols=None, multi_line=True,
default=label_value, **kwargs):
"""
Return a labeller function
Parameters
----------
rows : str | function | None
How to label the rows
cols : str | function | None
How to label the columns
multi_line : bool
... | [
"def",
"labeller",
"(",
"rows",
"=",
"None",
",",
"cols",
"=",
"None",
",",
"multi_line",
"=",
"True",
",",
"default",
"=",
"label_value",
",",
"*",
"*",
"kwargs",
")",
":",
"# Sort out the labellers along each dimension",
"rows_labeller",
"=",
"as_labeller",
... | Return a labeller function
Parameters
----------
rows : str | function | None
How to label the rows
cols : str | function | None
How to label the columns
multi_line : bool
Whether to place each variable on a separate line
default : function | str
Fallback labelli... | [
"Return",
"a",
"labeller",
"function"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/labelling.py#L157-L210 | train |
has2k1/plotnine | plotnine/geoms/geom_violin.py | make_quantile_df | def make_quantile_df(data, draw_quantiles):
"""
Return a dataframe with info needed to draw quantile segments
"""
dens = data['density'].cumsum() / data['density'].sum()
ecdf = interp1d(dens, data['y'], assume_sorted=True)
ys = ecdf(draw_quantiles)
# Get the violin bounds for the requested ... | python | def make_quantile_df(data, draw_quantiles):
"""
Return a dataframe with info needed to draw quantile segments
"""
dens = data['density'].cumsum() / data['density'].sum()
ecdf = interp1d(dens, data['y'], assume_sorted=True)
ys = ecdf(draw_quantiles)
# Get the violin bounds for the requested ... | [
"def",
"make_quantile_df",
"(",
"data",
",",
"draw_quantiles",
")",
":",
"dens",
"=",
"data",
"[",
"'density'",
"]",
".",
"cumsum",
"(",
")",
"/",
"data",
"[",
"'density'",
"]",
".",
"sum",
"(",
")",
"ecdf",
"=",
"interp1d",
"(",
"dens",
",",
"data",... | Return a dataframe with info needed to draw quantile segments | [
"Return",
"a",
"dataframe",
"with",
"info",
"needed",
"to",
"draw",
"quantile",
"segments"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom_violin.py#L97-L114 | train |
has2k1/plotnine | plotnine/stats/stat.py | stat.from_geom | def from_geom(geom):
"""
Return an instantiated stat object
stats should not override this method.
Parameters
----------
geom : geom
`geom`
Returns
-------
out : stat
A stat object
Raises
------
:... | python | def from_geom(geom):
"""
Return an instantiated stat object
stats should not override this method.
Parameters
----------
geom : geom
`geom`
Returns
-------
out : stat
A stat object
Raises
------
:... | [
"def",
"from_geom",
"(",
"geom",
")",
":",
"name",
"=",
"geom",
".",
"params",
"[",
"'stat'",
"]",
"kwargs",
"=",
"geom",
".",
"_kwargs",
"# More stable when reloading modules than",
"# using issubclass",
"if",
"(",
"not",
"isinstance",
"(",
"name",
",",
"type... | Return an instantiated stat object
stats should not override this method.
Parameters
----------
geom : geom
`geom`
Returns
-------
out : stat
A stat object
Raises
------
:class:`PlotnineError` if unable to create... | [
"Return",
"an",
"instantiated",
"stat",
"object"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat.py#L49-L95 | train |
has2k1/plotnine | plotnine/stats/stat.py | stat.aesthetics | def aesthetics(cls):
"""
Return a set of all non-computed aesthetics for this stat.
stats should not override this method.
"""
aesthetics = cls.REQUIRED_AES.copy()
calculated = get_calculated_aes(cls.DEFAULT_AES)
for ae in set(cls.DEFAULT_AES) - set(calculated):
... | python | def aesthetics(cls):
"""
Return a set of all non-computed aesthetics for this stat.
stats should not override this method.
"""
aesthetics = cls.REQUIRED_AES.copy()
calculated = get_calculated_aes(cls.DEFAULT_AES)
for ae in set(cls.DEFAULT_AES) - set(calculated):
... | [
"def",
"aesthetics",
"(",
"cls",
")",
":",
"aesthetics",
"=",
"cls",
".",
"REQUIRED_AES",
".",
"copy",
"(",
")",
"calculated",
"=",
"get_calculated_aes",
"(",
"cls",
".",
"DEFAULT_AES",
")",
"for",
"ae",
"in",
"set",
"(",
"cls",
".",
"DEFAULT_AES",
")",
... | Return a set of all non-computed aesthetics for this stat.
stats should not override this method. | [
"Return",
"a",
"set",
"of",
"all",
"non",
"-",
"computed",
"aesthetics",
"for",
"this",
"stat",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat.py#L118-L128 | train |
has2k1/plotnine | plotnine/stats/stat.py | stat.compute_layer | def compute_layer(cls, data, params, layout):
"""
Calculate statistics for this layers
This is the top-most computation method for the
stat. It does not do any computations, but it
knows how to verify the data, partition it call the
next computation method and merge resu... | python | def compute_layer(cls, data, params, layout):
"""
Calculate statistics for this layers
This is the top-most computation method for the
stat. It does not do any computations, but it
knows how to verify the data, partition it call the
next computation method and merge resu... | [
"def",
"compute_layer",
"(",
"cls",
",",
"data",
",",
"params",
",",
"layout",
")",
":",
"check_required_aesthetics",
"(",
"cls",
".",
"REQUIRED_AES",
",",
"list",
"(",
"data",
".",
"columns",
")",
"+",
"list",
"(",
"params",
".",
"keys",
"(",
")",
")"... | Calculate statistics for this layers
This is the top-most computation method for the
stat. It does not do any computations, but it
knows how to verify the data, partition it call the
next computation method and merge results.
stats should not override this method.
Para... | [
"Calculate",
"statistics",
"for",
"this",
"layers"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat.py#L223-L267 | train |
has2k1/plotnine | plotnine/stats/stat.py | stat.compute_panel | def compute_panel(cls, data, scales, **params):
"""
Calculate the stats of all the groups and
return the results in a single dataframe.
This is a default function that can be overriden
by individual stats
Parameters
----------
data : dataframe
... | python | def compute_panel(cls, data, scales, **params):
"""
Calculate the stats of all the groups and
return the results in a single dataframe.
This is a default function that can be overriden
by individual stats
Parameters
----------
data : dataframe
... | [
"def",
"compute_panel",
"(",
"cls",
",",
"data",
",",
"scales",
",",
"*",
"*",
"params",
")",
":",
"if",
"not",
"len",
"(",
"data",
")",
":",
"return",
"type",
"(",
"data",
")",
"(",
")",
"stats",
"=",
"[",
"]",
"for",
"_",
",",
"old",
"in",
... | Calculate the stats of all the groups and
return the results in a single dataframe.
This is a default function that can be overriden
by individual stats
Parameters
----------
data : dataframe
data for the computing
scales : types.SimpleNamespace
... | [
"Calculate",
"the",
"stats",
"of",
"all",
"the",
"groups",
"and",
"return",
"the",
"results",
"in",
"a",
"single",
"dataframe",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/stat.py#L270-L317 | train |
has2k1/plotnine | plotnine/stats/density.py | kde_scipy | def kde_scipy(data, grid, **kwargs):
"""
Kernel Density Estimation with Scipy
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
Data point... | python | def kde_scipy(data, grid, **kwargs):
"""
Kernel Density Estimation with Scipy
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
Data point... | [
"def",
"kde_scipy",
"(",
"data",
",",
"grid",
",",
"*",
"*",
"kwargs",
")",
":",
"kde",
"=",
"gaussian_kde",
"(",
"data",
".",
"T",
",",
"*",
"*",
"kwargs",
")",
"return",
"kde",
".",
"evaluate",
"(",
"grid",
".",
"T",
")"
] | Kernel Density Estimation with Scipy
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
Data points at which the desity will be estimated. It
... | [
"Kernel",
"Density",
"Estimation",
"with",
"Scipy"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/density.py#L23-L44 | train |
has2k1/plotnine | plotnine/stats/density.py | kde_statsmodels_u | def kde_statsmodels_u(data, grid, **kwargs):
"""
Univariate Kernel Density Estimation with Statsmodels
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x 1` dimensions, representing n points and p
variables.
grid : numpy... | python | def kde_statsmodels_u(data, grid, **kwargs):
"""
Univariate Kernel Density Estimation with Statsmodels
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x 1` dimensions, representing n points and p
variables.
grid : numpy... | [
"def",
"kde_statsmodels_u",
"(",
"data",
",",
"grid",
",",
"*",
"*",
"kwargs",
")",
":",
"kde",
"=",
"KDEUnivariate",
"(",
"data",
")",
"kde",
".",
"fit",
"(",
"*",
"*",
"kwargs",
")",
"return",
"kde",
".",
"evaluate",
"(",
"grid",
")"
] | Univariate Kernel Density Estimation with Statsmodels
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x 1` dimensions, representing n points and p
variables.
grid : numpy.array
Data points at which the desity will be es... | [
"Univariate",
"Kernel",
"Density",
"Estimation",
"with",
"Statsmodels"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/density.py#L47-L69 | train |
has2k1/plotnine | plotnine/stats/density.py | kde_statsmodels_m | def kde_statsmodels_m(data, grid, **kwargs):
"""
Multivariate Kernel Density Estimation with Statsmodels
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : num... | python | def kde_statsmodels_m(data, grid, **kwargs):
"""
Multivariate Kernel Density Estimation with Statsmodels
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : num... | [
"def",
"kde_statsmodels_m",
"(",
"data",
",",
"grid",
",",
"*",
"*",
"kwargs",
")",
":",
"kde",
"=",
"KDEMultivariate",
"(",
"data",
",",
"*",
"*",
"kwargs",
")",
"return",
"kde",
".",
"pdf",
"(",
"grid",
")"
] | Multivariate Kernel Density Estimation with Statsmodels
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
Data points at which the desity will be ... | [
"Multivariate",
"Kernel",
"Density",
"Estimation",
"with",
"Statsmodels"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/density.py#L72-L93 | train |
has2k1/plotnine | plotnine/stats/density.py | kde_sklearn | def kde_sklearn(data, grid, **kwargs):
"""
Kernel Density Estimation with Scikit-learn
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
D... | python | def kde_sklearn(data, grid, **kwargs):
"""
Kernel Density Estimation with Scikit-learn
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
D... | [
"def",
"kde_sklearn",
"(",
"data",
",",
"grid",
",",
"*",
"*",
"kwargs",
")",
":",
"kde_skl",
"=",
"KernelDensity",
"(",
"*",
"*",
"kwargs",
")",
"kde_skl",
".",
"fit",
"(",
"data",
")",
"# score_samples() returns the log-likelihood of the samples",
"log_pdf",
... | Kernel Density Estimation with Scikit-learn
Parameters
----------
data : numpy.array
Data points used to compute a density estimator. It
has `n x p` dimensions, representing n points and p
variables.
grid : numpy.array
Data points at which the desity will be estimated. I... | [
"Kernel",
"Density",
"Estimation",
"with",
"Scikit",
"-",
"learn"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/density.py#L96-L120 | train |
has2k1/plotnine | plotnine/stats/density.py | kde | def kde(data, grid, package, **kwargs):
"""
Kernel Density Estimation
Parameters
----------
package : str
Package whose kernel density estimation to use.
Should be one of
`['statsmodels-u', 'statsmodels-m', 'scipy', 'sklearn']`.
data : numpy.array
Data points use... | python | def kde(data, grid, package, **kwargs):
"""
Kernel Density Estimation
Parameters
----------
package : str
Package whose kernel density estimation to use.
Should be one of
`['statsmodels-u', 'statsmodels-m', 'scipy', 'sklearn']`.
data : numpy.array
Data points use... | [
"def",
"kde",
"(",
"data",
",",
"grid",
",",
"package",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"package",
"==",
"'statsmodels'",
":",
"package",
"=",
"'statsmodels-m'",
"func",
"=",
"KDE_FUNCS",
"[",
"package",
"]",
"return",
"func",
"(",
"data",
","... | Kernel Density Estimation
Parameters
----------
package : str
Package whose kernel density estimation to use.
Should be one of
`['statsmodels-u', 'statsmodels-m', 'scipy', 'sklearn']`.
data : numpy.array
Data points used to compute a density estimator. It
has `n ... | [
"Kernel",
"Density",
"Estimation"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/density.py#L132-L159 | train |
has2k1/plotnine | plotnine/positions/position_dodge.py | position_dodge.strategy | def strategy(data, params):
"""
Dodge overlapping interval
Assumes that each set has the same horizontal position.
"""
width = params['width']
with suppress(TypeError):
iter(width)
width = np.asarray(width)
width = width[data.index]
... | python | def strategy(data, params):
"""
Dodge overlapping interval
Assumes that each set has the same horizontal position.
"""
width = params['width']
with suppress(TypeError):
iter(width)
width = np.asarray(width)
width = width[data.index]
... | [
"def",
"strategy",
"(",
"data",
",",
"params",
")",
":",
"width",
"=",
"params",
"[",
"'width'",
"]",
"with",
"suppress",
"(",
"TypeError",
")",
":",
"iter",
"(",
"width",
")",
"width",
"=",
"np",
".",
"asarray",
"(",
"width",
")",
"width",
"=",
"w... | Dodge overlapping interval
Assumes that each set has the same horizontal position. | [
"Dodge",
"overlapping",
"interval"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/positions/position_dodge.py#L59-L98 | train |
has2k1/plotnine | plotnine/facets/facet_grid.py | parse_grid_facets | def parse_grid_facets(facets):
"""
Return two lists of facetting variables, for the rows & columns
"""
valid_seqs = ["('var1', '.')", "('var1', 'var2')",
"('.', 'var1')", "((var1, var2), (var3, var4))"]
error_msg_s = ("Valid sequences for specifying 'facets' look like"
... | python | def parse_grid_facets(facets):
"""
Return two lists of facetting variables, for the rows & columns
"""
valid_seqs = ["('var1', '.')", "('var1', 'var2')",
"('.', 'var1')", "((var1, var2), (var3, var4))"]
error_msg_s = ("Valid sequences for specifying 'facets' look like"
... | [
"def",
"parse_grid_facets",
"(",
"facets",
")",
":",
"valid_seqs",
"=",
"[",
"\"('var1', '.')\"",
",",
"\"('var1', 'var2')\"",
",",
"\"('.', 'var1')\"",
",",
"\"((var1, var2), (var3, var4))\"",
"]",
"error_msg_s",
"=",
"(",
"\"Valid sequences for specifying 'facets' look like... | Return two lists of facetting variables, for the rows & columns | [
"Return",
"two",
"lists",
"of",
"facetting",
"variables",
"for",
"the",
"rows",
"&",
"columns"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/facets/facet_grid.py#L254-L315 | train |
has2k1/plotnine | plotnine/coords/coord.py | coord.expand_default | def expand_default(self, scale, discrete=(0, 0.6, 0, 0.6),
continuous=(0.05, 0, 0.05, 0)):
"""
Expand a single scale
"""
if is_waive(scale.expand):
if isinstance(scale, scale_discrete):
return discrete
elif isinstance(scale, ... | python | def expand_default(self, scale, discrete=(0, 0.6, 0, 0.6),
continuous=(0.05, 0, 0.05, 0)):
"""
Expand a single scale
"""
if is_waive(scale.expand):
if isinstance(scale, scale_discrete):
return discrete
elif isinstance(scale, ... | [
"def",
"expand_default",
"(",
"self",
",",
"scale",
",",
"discrete",
"=",
"(",
"0",
",",
"0.6",
",",
"0",
",",
"0.6",
")",
",",
"continuous",
"=",
"(",
"0.05",
",",
"0",
",",
"0.05",
",",
"0",
")",
")",
":",
"if",
"is_waive",
"(",
"scale",
".",... | Expand a single scale | [
"Expand",
"a",
"single",
"scale"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/coords/coord.py#L113-L128 | train |
has2k1/plotnine | plotnine/doctools.py | dict_to_table | def dict_to_table(header, contents):
"""
Convert dict to table
Parameters
----------
header : tuple
Table header. Should have a length of 2.
contents : dict
The key becomes column 1 of table and the
value becomes column 2 of table.
"""
def to_text(row):
n... | python | def dict_to_table(header, contents):
"""
Convert dict to table
Parameters
----------
header : tuple
Table header. Should have a length of 2.
contents : dict
The key becomes column 1 of table and the
value becomes column 2 of table.
"""
def to_text(row):
n... | [
"def",
"dict_to_table",
"(",
"header",
",",
"contents",
")",
":",
"def",
"to_text",
"(",
"row",
")",
":",
"name",
",",
"value",
"=",
"row",
"m",
"=",
"max_col1_size",
"+",
"1",
"-",
"len",
"(",
"name",
")",
"spacing",
"=",
"' '",
"*",
"m",
"return"... | Convert dict to table
Parameters
----------
header : tuple
Table header. Should have a length of 2.
contents : dict
The key becomes column 1 of table and the
value becomes column 2 of table. | [
"Convert",
"dict",
"to",
"table"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L128-L163 | train |
has2k1/plotnine | plotnine/doctools.py | make_signature | def make_signature(name, params, common_params, common_param_values):
"""
Create a signature for a geom or stat
Gets the DEFAULT_PARAMS (params) and creates are comma
separated list of the `name=value` pairs. The common_params
come first in the list, and they get take their values from
either t... | python | def make_signature(name, params, common_params, common_param_values):
"""
Create a signature for a geom or stat
Gets the DEFAULT_PARAMS (params) and creates are comma
separated list of the `name=value` pairs. The common_params
come first in the list, and they get take their values from
either t... | [
"def",
"make_signature",
"(",
"name",
",",
"params",
",",
"common_params",
",",
"common_param_values",
")",
":",
"tokens",
"=",
"[",
"]",
"seen",
"=",
"set",
"(",
")",
"def",
"tokens_append",
"(",
"key",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
... | Create a signature for a geom or stat
Gets the DEFAULT_PARAMS (params) and creates are comma
separated list of the `name=value` pairs. The common_params
come first in the list, and they get take their values from
either the params-dict or the common_geom_param_values-dict. | [
"Create",
"a",
"signature",
"for",
"a",
"geom",
"or",
"stat"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L166-L203 | train |
has2k1/plotnine | plotnine/doctools.py | docstring_section_lines | def docstring_section_lines(docstring, section_name):
"""
Return a section of a numpydoc string
Paramters
---------
docstring : str
Docstring
section_name : str
Name of section to return
Returns
-------
section : str
Section minus the header
"""
line... | python | def docstring_section_lines(docstring, section_name):
"""
Return a section of a numpydoc string
Paramters
---------
docstring : str
Docstring
section_name : str
Name of section to return
Returns
-------
section : str
Section minus the header
"""
line... | [
"def",
"docstring_section_lines",
"(",
"docstring",
",",
"section_name",
")",
":",
"lines",
"=",
"[",
"]",
"inside_section",
"=",
"False",
"underline",
"=",
"'-'",
"*",
"len",
"(",
"section_name",
")",
"expect_underline",
"=",
"False",
"for",
"line",
"in",
"... | Return a section of a numpydoc string
Paramters
---------
docstring : str
Docstring
section_name : str
Name of section to return
Returns
-------
section : str
Section minus the header | [
"Return",
"a",
"section",
"of",
"a",
"numpydoc",
"string"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L207-L243 | train |
has2k1/plotnine | plotnine/doctools.py | parameters_str_to_dict | def parameters_str_to_dict(param_section):
"""
Convert a param section to a dict
Parameters
----------
param_section : str
Text in the parameter section
Returns
-------
d : OrderedDict
Dictionary of the parameters in the order that they
are described in the para... | python | def parameters_str_to_dict(param_section):
"""
Convert a param section to a dict
Parameters
----------
param_section : str
Text in the parameter section
Returns
-------
d : OrderedDict
Dictionary of the parameters in the order that they
are described in the para... | [
"def",
"parameters_str_to_dict",
"(",
"param_section",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"previous_param",
"=",
"None",
"param_desc",
"=",
"None",
"for",
"line",
"in",
"param_section",
".",
"split",
"(",
"'\\n'",
")",
":",
"param",
"=",
"param_spe... | Convert a param section to a dict
Parameters
----------
param_section : str
Text in the parameter section
Returns
-------
d : OrderedDict
Dictionary of the parameters in the order that they
are described in the parameters section. The dict
is of the form ``{para... | [
"Convert",
"a",
"param",
"section",
"to",
"a",
"dict"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L279-L317 | train |
has2k1/plotnine | plotnine/doctools.py | document_geom | def document_geom(geom):
"""
Create a structured documentation for the geom
It replaces `{usage}`, `{common_parameters}` and
`{aesthetics}` with generated documentation.
"""
# Dedented so that it lineups (in sphinx) with the part
# generated parts when put together
docstring = dedent(ge... | python | def document_geom(geom):
"""
Create a structured documentation for the geom
It replaces `{usage}`, `{common_parameters}` and
`{aesthetics}` with generated documentation.
"""
# Dedented so that it lineups (in sphinx) with the part
# generated parts when put together
docstring = dedent(ge... | [
"def",
"document_geom",
"(",
"geom",
")",
":",
"# Dedented so that it lineups (in sphinx) with the part",
"# generated parts when put together",
"docstring",
"=",
"dedent",
"(",
"geom",
".",
"__doc__",
")",
"# usage",
"signature",
"=",
"make_signature",
"(",
"geom",
".",
... | Create a structured documentation for the geom
It replaces `{usage}`, `{common_parameters}` and
`{aesthetics}` with generated documentation. | [
"Create",
"a",
"structured",
"documentation",
"for",
"the",
"geom"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L341-L387 | train |
has2k1/plotnine | plotnine/doctools.py | document_stat | def document_stat(stat):
"""
Create a structured documentation for the stat
It replaces `{usage}`, `{common_parameters}` and
`{aesthetics}` with generated documentation.
"""
# Dedented so that it lineups (in sphinx) with the part
# generated parts when put together
docstring = dedent(st... | python | def document_stat(stat):
"""
Create a structured documentation for the stat
It replaces `{usage}`, `{common_parameters}` and
`{aesthetics}` with generated documentation.
"""
# Dedented so that it lineups (in sphinx) with the part
# generated parts when put together
docstring = dedent(st... | [
"def",
"document_stat",
"(",
"stat",
")",
":",
"# Dedented so that it lineups (in sphinx) with the part",
"# generated parts when put together",
"docstring",
"=",
"dedent",
"(",
"stat",
".",
"__doc__",
")",
"# usage:",
"signature",
"=",
"make_signature",
"(",
"stat",
".",... | Create a structured documentation for the stat
It replaces `{usage}`, `{common_parameters}` and
`{aesthetics}` with generated documentation. | [
"Create",
"a",
"structured",
"documentation",
"for",
"the",
"stat"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L390-L431 | train |
has2k1/plotnine | plotnine/doctools.py | document_scale | def document_scale(cls):
"""
Create a documentation for a scale
Import the superclass parameters
It replaces `{superclass_parameters}` with the documentation
of the parameters from the superclass.
Parameters
----------
cls : type
A scale class
Returns
-------
cls ... | python | def document_scale(cls):
"""
Create a documentation for a scale
Import the superclass parameters
It replaces `{superclass_parameters}` with the documentation
of the parameters from the superclass.
Parameters
----------
cls : type
A scale class
Returns
-------
cls ... | [
"def",
"document_scale",
"(",
"cls",
")",
":",
"params_list",
"=",
"[",
"]",
"# Get set of cls params",
"cls_param_string",
"=",
"docstring_parameters_section",
"(",
"cls",
")",
"cls_param_dict",
"=",
"parameters_str_to_dict",
"(",
"cls_param_string",
")",
"cls_params",... | Create a documentation for a scale
Import the superclass parameters
It replaces `{superclass_parameters}` with the documentation
of the parameters from the superclass.
Parameters
----------
cls : type
A scale class
Returns
-------
cls : type
The scale class with a... | [
"Create",
"a",
"documentation",
"for",
"a",
"scale"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L434-L488 | train |
has2k1/plotnine | plotnine/doctools.py | document | def document(cls):
"""
Decorator to document a class
"""
if cls.__doc__ is None:
return cls
baseclass_name = cls.mro()[-2].__name__
try:
return DOC_FUNCTIONS[baseclass_name](cls)
except KeyError:
return cls | python | def document(cls):
"""
Decorator to document a class
"""
if cls.__doc__ is None:
return cls
baseclass_name = cls.mro()[-2].__name__
try:
return DOC_FUNCTIONS[baseclass_name](cls)
except KeyError:
return cls | [
"def",
"document",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"__doc__",
"is",
"None",
":",
"return",
"cls",
"baseclass_name",
"=",
"cls",
".",
"mro",
"(",
")",
"[",
"-",
"2",
"]",
".",
"__name__",
"try",
":",
"return",
"DOC_FUNCTIONS",
"[",
"baseclass_... | Decorator to document a class | [
"Decorator",
"to",
"document",
"a",
"class"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/doctools.py#L498-L510 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._draw_using_figure | def _draw_using_figure(self, figure, axs):
"""
Draw onto already created figure and axes
This is can be used to draw animation frames,
or inset plots. It is intended to be used
after the key plot has been drawn.
Parameters
----------
figure : ~matplotlib... | python | def _draw_using_figure(self, figure, axs):
"""
Draw onto already created figure and axes
This is can be used to draw animation frames,
or inset plots. It is intended to be used
after the key plot has been drawn.
Parameters
----------
figure : ~matplotlib... | [
"def",
"_draw_using_figure",
"(",
"self",
",",
"figure",
",",
"axs",
")",
":",
"self",
"=",
"deepcopy",
"(",
"self",
")",
"self",
".",
"_build",
"(",
")",
"self",
".",
"theme",
"=",
"self",
".",
"theme",
"or",
"theme_get",
"(",
")",
"self",
".",
"f... | Draw onto already created figure and axes
This is can be used to draw animation frames,
or inset plots. It is intended to be used
after the key plot has been drawn.
Parameters
----------
figure : ~matplotlib.figure.Figure
Matplotlib figure
axs : arra... | [
"Draw",
"onto",
"already",
"created",
"figure",
"and",
"axes"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L228-L263 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._build | def _build(self):
"""
Build ggplot for rendering.
Notes
-----
This method modifies the ggplot object. The caller is
responsible for making a copy and using that to make
the method call.
"""
if not self.layers:
self += geom_blank()
... | python | def _build(self):
"""
Build ggplot for rendering.
Notes
-----
This method modifies the ggplot object. The caller is
responsible for making a copy and using that to make
the method call.
"""
if not self.layers:
self += geom_blank()
... | [
"def",
"_build",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"layers",
":",
"self",
"+=",
"geom_blank",
"(",
")",
"self",
".",
"layout",
"=",
"Layout",
"(",
")",
"layers",
"=",
"self",
".",
"layers",
"scales",
"=",
"self",
".",
"scales",
"layo... | Build ggplot for rendering.
Notes
-----
This method modifies the ggplot object. The caller is
responsible for making a copy and using that to make
the method call. | [
"Build",
"ggplot",
"for",
"rendering",
"."
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L265-L339 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._setup_parameters | def _setup_parameters(self):
"""
Set facet properties
"""
# facet
self.facet.set(
layout=self.layout,
theme=self.theme,
coordinates=self.coordinates,
figure=self.figure,
axs=self.axs
)
# layout
s... | python | def _setup_parameters(self):
"""
Set facet properties
"""
# facet
self.facet.set(
layout=self.layout,
theme=self.theme,
coordinates=self.coordinates,
figure=self.figure,
axs=self.axs
)
# layout
s... | [
"def",
"_setup_parameters",
"(",
"self",
")",
":",
"# facet",
"self",
".",
"facet",
".",
"set",
"(",
"layout",
"=",
"self",
".",
"layout",
",",
"theme",
"=",
"self",
".",
"theme",
",",
"coordinates",
"=",
"self",
".",
"coordinates",
",",
"figure",
"=",... | Set facet properties | [
"Set",
"facet",
"properties"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L341-L357 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._create_figure | def _create_figure(self):
"""
Create Matplotlib figure and axes
"""
# Good for development
if get_option('close_all_figures'):
plt.close('all')
figure = plt.figure()
axs = self.facet.make_axes(
figure,
self.layout.layout,
... | python | def _create_figure(self):
"""
Create Matplotlib figure and axes
"""
# Good for development
if get_option('close_all_figures'):
plt.close('all')
figure = plt.figure()
axs = self.facet.make_axes(
figure,
self.layout.layout,
... | [
"def",
"_create_figure",
"(",
"self",
")",
":",
"# Good for development",
"if",
"get_option",
"(",
"'close_all_figures'",
")",
":",
"plt",
".",
"close",
"(",
"'all'",
")",
"figure",
"=",
"plt",
".",
"figure",
"(",
")",
"axs",
"=",
"self",
".",
"facet",
"... | Create Matplotlib figure and axes | [
"Create",
"Matplotlib",
"figure",
"and",
"axes"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L359-L379 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._draw_facet_labels | def _draw_facet_labels(self):
"""
Draw facet labels a.k.a strip texts
"""
# Decorate the axes
# - xaxis & yaxis breaks, labels, limits, ...
# - facet labels
#
# pidx is the panel index (location left to right, top to bottom)
for pidx, layout_in... | python | def _draw_facet_labels(self):
"""
Draw facet labels a.k.a strip texts
"""
# Decorate the axes
# - xaxis & yaxis breaks, labels, limits, ...
# - facet labels
#
# pidx is the panel index (location left to right, top to bottom)
for pidx, layout_in... | [
"def",
"_draw_facet_labels",
"(",
"self",
")",
":",
"# Decorate the axes",
"# - xaxis & yaxis breaks, labels, limits, ...",
"# - facet labels",
"#",
"# pidx is the panel index (location left to right, top to bottom)",
"for",
"pidx",
",",
"layout_info",
"in",
"self",
".",
"lay... | Draw facet labels a.k.a strip texts | [
"Draw",
"facet",
"labels",
"a",
".",
"k",
".",
"a",
"strip",
"texts"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L395-L408 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._draw_legend | def _draw_legend(self):
"""
Draw legend onto the figure
"""
legend_box = self.guides.build(self)
if not legend_box:
return
figure = self.figure
left = figure.subplotpars.left
right = figure.subplotpars.right
top = figure.subplotpars.to... | python | def _draw_legend(self):
"""
Draw legend onto the figure
"""
legend_box = self.guides.build(self)
if not legend_box:
return
figure = self.figure
left = figure.subplotpars.left
right = figure.subplotpars.right
top = figure.subplotpars.to... | [
"def",
"_draw_legend",
"(",
"self",
")",
":",
"legend_box",
"=",
"self",
".",
"guides",
".",
"build",
"(",
"self",
")",
"if",
"not",
"legend_box",
":",
"return",
"figure",
"=",
"self",
".",
"figure",
"left",
"=",
"figure",
".",
"subplotpars",
".",
"lef... | Draw legend onto the figure | [
"Draw",
"legend",
"onto",
"the",
"figure"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L410-L481 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._draw_labels | def _draw_labels(self):
"""
Draw x and y labels onto the figure
"""
# This is very laboured. Should be changed when MPL
# finally has a constraint based layout manager.
figure = self.figure
get_property = self.theme.themeables.property
try:
ma... | python | def _draw_labels(self):
"""
Draw x and y labels onto the figure
"""
# This is very laboured. Should be changed when MPL
# finally has a constraint based layout manager.
figure = self.figure
get_property = self.theme.themeables.property
try:
ma... | [
"def",
"_draw_labels",
"(",
"self",
")",
":",
"# This is very laboured. Should be changed when MPL",
"# finally has a constraint based layout manager.",
"figure",
"=",
"self",
".",
"figure",
"get_property",
"=",
"self",
".",
"theme",
".",
"themeables",
".",
"property",
"t... | Draw x and y labels onto the figure | [
"Draw",
"x",
"and",
"y",
"labels",
"onto",
"the",
"figure"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L483-L533 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._draw_title | def _draw_title(self):
"""
Draw title onto the figure
"""
# This is very laboured. Should be changed when MPL
# finally has a constraint based layout manager.
figure = self.figure
title = self.labels.get('title', '')
rcParams = self.theme.rcParams
... | python | def _draw_title(self):
"""
Draw title onto the figure
"""
# This is very laboured. Should be changed when MPL
# finally has a constraint based layout manager.
figure = self.figure
title = self.labels.get('title', '')
rcParams = self.theme.rcParams
... | [
"def",
"_draw_title",
"(",
"self",
")",
":",
"# This is very laboured. Should be changed when MPL",
"# finally has a constraint based layout manager.",
"figure",
"=",
"self",
".",
"figure",
"title",
"=",
"self",
".",
"labels",
".",
"get",
"(",
"'title'",
",",
"''",
")... | Draw title onto the figure | [
"Draw",
"title",
"onto",
"the",
"figure"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L535-L590 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._apply_theme | def _apply_theme(self):
"""
Apply theme attributes to Matplotlib objects
"""
self.theme.apply_axs(self.axs)
self.theme.apply_figure(self.figure) | python | def _apply_theme(self):
"""
Apply theme attributes to Matplotlib objects
"""
self.theme.apply_axs(self.axs)
self.theme.apply_figure(self.figure) | [
"def",
"_apply_theme",
"(",
"self",
")",
":",
"self",
".",
"theme",
".",
"apply_axs",
"(",
"self",
".",
"axs",
")",
"self",
".",
"theme",
".",
"apply_figure",
"(",
"self",
".",
"figure",
")"
] | Apply theme attributes to Matplotlib objects | [
"Apply",
"theme",
"attributes",
"to",
"Matplotlib",
"objects"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L599-L604 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot._save_filename | def _save_filename(self, ext):
"""
Default filename used by the save method
Parameters
----------
ext : str
Extension e.g. png, pdf, ...
"""
hash_token = abs(self.__hash__())
return 'plotnine-save-{}.{}'.format(hash_token, ext) | python | def _save_filename(self, ext):
"""
Default filename used by the save method
Parameters
----------
ext : str
Extension e.g. png, pdf, ...
"""
hash_token = abs(self.__hash__())
return 'plotnine-save-{}.{}'.format(hash_token, ext) | [
"def",
"_save_filename",
"(",
"self",
",",
"ext",
")",
":",
"hash_token",
"=",
"abs",
"(",
"self",
".",
"__hash__",
"(",
")",
")",
"return",
"'plotnine-save-{}.{}'",
".",
"format",
"(",
"hash_token",
",",
"ext",
")"
] | Default filename used by the save method
Parameters
----------
ext : str
Extension e.g. png, pdf, ... | [
"Default",
"filename",
"used",
"by",
"the",
"save",
"method"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L606-L616 | train |
has2k1/plotnine | plotnine/ggplot.py | ggplot.save | def save(self, filename=None, format=None, path=None,
width=None, height=None, units='in',
dpi=None, limitsize=True, verbose=True, **kwargs):
"""
Save a ggplot object as an image file
Parameters
----------
filename : str, optional
File name ... | python | def save(self, filename=None, format=None, path=None,
width=None, height=None, units='in',
dpi=None, limitsize=True, verbose=True, **kwargs):
"""
Save a ggplot object as an image file
Parameters
----------
filename : str, optional
File name ... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"format",
"=",
"None",
",",
"path",
"=",
"None",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"units",
"=",
"'in'",
",",
"dpi",
"=",
"None",
",",
"limitsize",
"=",
"Tru... | Save a ggplot object as an image file
Parameters
----------
filename : str, optional
File name to write the plot to. If not specified, a name
like “plotnine-save-<hash>.<format>” is used.
format : str
Image format to use, automatically extract from
... | [
"Save",
"a",
"ggplot",
"object",
"as",
"an",
"image",
"file"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/ggplot.py#L618-L730 | train |
has2k1/plotnine | plotnine/stats/smoothers.py | mavg | def mavg(data, xseq, **params):
"""
Fit moving average
"""
window = params['method_args']['window']
# The first average comes after the full window size
# has been swept over
rolling = data['y'].rolling(**params['method_args'])
y = rolling.mean()[window:]
n = len(data)
stderr = ... | python | def mavg(data, xseq, **params):
"""
Fit moving average
"""
window = params['method_args']['window']
# The first average comes after the full window size
# has been swept over
rolling = data['y'].rolling(**params['method_args'])
y = rolling.mean()[window:]
n = len(data)
stderr = ... | [
"def",
"mavg",
"(",
"data",
",",
"xseq",
",",
"*",
"*",
"params",
")",
":",
"window",
"=",
"params",
"[",
"'method_args'",
"]",
"[",
"'window'",
"]",
"# The first average comes after the full window size",
"# has been swept over",
"rolling",
"=",
"data",
"[",
"'... | Fit moving average | [
"Fit",
"moving",
"average"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/smoothers.py#L221-L243 | train |
has2k1/plotnine | plotnine/stats/smoothers.py | gpr | def gpr(data, xseq, **params):
"""
Fit gaussian process
"""
try:
from sklearn import gaussian_process
except ImportError:
raise PlotnineError(
"To use gaussian process smoothing, "
"You need to install scikit-learn.")
kwargs = params['method_args']
if... | python | def gpr(data, xseq, **params):
"""
Fit gaussian process
"""
try:
from sklearn import gaussian_process
except ImportError:
raise PlotnineError(
"To use gaussian process smoothing, "
"You need to install scikit-learn.")
kwargs = params['method_args']
if... | [
"def",
"gpr",
"(",
"data",
",",
"xseq",
",",
"*",
"*",
"params",
")",
":",
"try",
":",
"from",
"sklearn",
"import",
"gaussian_process",
"except",
"ImportError",
":",
"raise",
"PlotnineError",
"(",
"\"To use gaussian process smoothing, \"",
"\"You need to install sci... | Fit gaussian process | [
"Fit",
"gaussian",
"process"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/smoothers.py#L246-L279 | train |
has2k1/plotnine | plotnine/stats/smoothers.py | tdist_ci | def tdist_ci(x, df, stderr, level):
"""
Confidence Intervals using the t-distribution
"""
q = (1 + level)/2
delta = stats.t.ppf(q, df) * stderr
return x - delta, x + delta | python | def tdist_ci(x, df, stderr, level):
"""
Confidence Intervals using the t-distribution
"""
q = (1 + level)/2
delta = stats.t.ppf(q, df) * stderr
return x - delta, x + delta | [
"def",
"tdist_ci",
"(",
"x",
",",
"df",
",",
"stderr",
",",
"level",
")",
":",
"q",
"=",
"(",
"1",
"+",
"level",
")",
"/",
"2",
"delta",
"=",
"stats",
".",
"t",
".",
"ppf",
"(",
"q",
",",
"df",
")",
"*",
"stderr",
"return",
"x",
"-",
"delta... | Confidence Intervals using the t-distribution | [
"Confidence",
"Intervals",
"using",
"the",
"t",
"-",
"distribution"
] | 566e579af705367e584fb27a74e6c5199624ca89 | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/stats/smoothers.py#L282-L288 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.