PK!\Ňadvanced_plot/__init__.py__version__ = '0.1.1' from .stack_vertical_bar import stack_vertical_bar from .vertical_bar import vertical_bar from .hist import histPK!Wwwadvanced_plot/hist.pyimport seaborn as sns import matplotlib.pyplot as plt import pandas as pd def hist(data: pd.Series, ax=None, ratio=True, fontsize=20, distplot_opt={}): if ax is None: n = data.shape[0] fig = plt.figure(figsize=(16, 5)) ax = fig.add_subplot(1, 1, 1) all_ = data.shape[0] mean = data.mean().round(1) median = data.median().round(1) mode = data.mode().values[0].round(1) sns.distplot(data, ax=ax, **distplot_opt) text = f"""All: {all_} Mean: {mean} Median: {median} Mode: {mode}""" ax.text( 0.99, 0.99, text, ha='right', va='top', transform=ax.transAxes, fontsize=fontsize)PK!xw}#advanced_plot/stack_vertical_bar.pyimport matplotlib.pyplot as plt import pandas as pd def stack_vertical_bar(data: pd.DataFrame, label: str, value: str, ax=None, fontsize=20): if ax is None: fig = plt.figure(figsize=(16, 2)) ax = fig.add_subplot(1, 1, 1) labels = getattr(data, label) values = getattr(data, value) sum_ = values.sum() before_rate = 0 for l, v in zip(labels, values): rate = v / sum_ x = before_rate + rate ax.barh(0, x, left=before_rate) text_x = before_rate + rate / 2 text = f"{l}\n{value} ({rate:.1%})" ax.text(text_x, 0, text, fontsize=fontsize, horizontalalignment='center', verticalalignment='center') before_rate = x ax.grid(False) ax.set_xlim(0, 1) ax.tick_params(axis='both', bottom=False, left=False, labelbottom=False, labelleft=False) [spine.set_visible(False) for spine in ax.spines.values()] return axPK! _nadvanced_plot/vertical_bar.pyimport matplotlib.pyplot as plt import pandas as pd import seaborn as sns def vertical_bar(data: pd.DataFrame, label: str, value: str, ax=None, ratio=True, fontsize=14): if ax is None: n = data.shape[0] fig = plt.figure(figsize=(16, 1 * n)) ax = fig.add_subplot(1, 1, 1) labels = getattr(data, label) values = getattr(data, value) max_ = values.max() sum_ = values.sum() base = sum_ # TODO: max version for base sns.barplot(x=value, y=label, data=data.reset_index(), ax=ax, order=labels) margin = ax.get_xlim()[1] / 100 for i, (l, v) in enumerate(zip(labels, values)): text = f'{v}' if ratio: v_ratio = v / base text = f'{text} ({v_ratio:.1%})' ax.text(v + margin, i, text, color='black', ha="left", va='center', fontsize=fontsize) [spine.set_visible(False) for spine in ax.spines.values()] ax.tick_params(bottom=False, left=False, labelbottom=False) ax.tick_params(axis='y', labelsize='x-large') return axPK!rI,,%advanced_plot-0.1.1.dist-info/LICENSEMIT License Copyright (c) 2019 IkedaYutaro Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HڽTU#advanced_plot-0.1.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H&advanced_plot-0.1.1.dist-info/METADATAMK09*شʊAEуZeW b enhFc0FOn,%Vŏw9GU]5#~QS9AVW7m5\k|e>zXٽX3)u¤ȃ/a2:;TS'NtpSO< f5h9saNxF-<,]rRgɊfD8:-xn o6^;BweofYNd$J3񀮺0tZ| hSH\:]⯭ٗ،~46h4{G^RpUNJ<J۞z7P;lB_R$_zNZ_B"y~\t: eU(PK!\Ňadvanced_plot/__init__.pyPK!Wwwadvanced_plot/hist.pyPK!xw}#hadvanced_plot/stack_vertical_bar.pyPK! _nAadvanced_plot/vertical_bar.pyPK!rI,,% advanced_plot-0.1.1.dist-info/LICENSEPK!HڽTU#advanced_plot-0.1.1.dist-info/WHEELPK!H&advanced_plot-0.1.1.dist-info/METADATAPK!H߁$advanced_plot-0.1.1.dist-info/RECORDPKp