Skip to content

Commit

Permalink
release: grplot-0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiffaryr committed Jun 7, 2022
1 parent 6160e52 commit 40f17d3
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 22 deletions.
24 changes: 12 additions & 12 deletions doc/Full_Documentation.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion grplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def grplot(plot, # default general value
by ghiffary rifqialdi
based on numpy, scipy, matplotlib, seaborn, squarify, and pandas
version = '0.9.2'
version = '0.9.3'
release date
07/06/2022
Expand Down
9 changes: 5 additions & 4 deletions grplot/features/font/font_def.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pandas.api.types import is_numeric_dtype, is_object_dtype, is_categorical_dtype
from grplot.utils.first_valid_index import first_valid_index


def font_def(plot, df, x, y, ax, tick_fontsize, label_fontsize):
Expand All @@ -9,12 +10,12 @@ def font_def(plot, df, x, y, ax, tick_fontsize, label_fontsize):
except:
raise Exception('Unknown tick fontsize argument!')
if plot == 'paretoplot':
if ((is_object_dtype(df[x]) == True) or (is_object_dtype(type(df[x][df.first_valid_index()])) == True) or (is_categorical_dtype(df[x]) == True) or (is_categorical_dtype(type(df[x][df.first_valid_index()])) == True)) and ((is_numeric_dtype(df[y]) == True) or (is_numeric_dtype(type(df[y][df.first_valid_index()])) == True)):
if ((is_object_dtype(df[x]) == True) or (is_object_dtype(type(df[x][first_valid_index(df)])) == True) or (is_categorical_dtype(df[x]) == True) or (is_categorical_dtype(type(df[x][first_valid_index(df)])) == True)) and ((is_numeric_dtype(df[y]) == True) or (is_numeric_dtype(type(df[y][first_valid_index(df)])) == True)):
try:
ax.get_shared_x_axes().get_siblings(ax)[0].tick_params(axis='both', labelsize=tick_fontsize)
except:
raise Exception('Unknown tick fontsize argument!')
elif ((is_numeric_dtype(df[x]) == True) or (is_numeric_dtype(type(df[x][df.first_valid_index()])) == True)) and ((is_object_dtype(df[y]) == True) or (is_object_dtype(type(df[y][df.first_valid_index()])) == True) or (is_categorical_dtype(df[y]) == True) or (is_categorical_dtype(type(df[y][df.first_valid_index()])) == True)):
elif ((is_numeric_dtype(df[x]) == True) or (is_numeric_dtype(type(df[x][first_valid_index(df)])) == True)) and ((is_object_dtype(df[y]) == True) or (is_object_dtype(type(df[y][first_valid_index(df)])) == True) or (is_categorical_dtype(df[y]) == True) or (is_categorical_dtype(type(df[y][first_valid_index(df)])) == True)):
try:
ax.get_shared_y_axes().get_siblings(ax)[0].tick_params(axis='both', labelsize=tick_fontsize)
except:
Expand All @@ -33,12 +34,12 @@ def font_def(plot, df, x, y, ax, tick_fontsize, label_fontsize):
except:
raise Exception('Unknown label fontsize argument!')
if plot == 'paretoplot':
if ((is_object_dtype(df[x]) == True) or (is_object_dtype(type(df[x][df.first_valid_index()])) == True) or (is_categorical_dtype(df[x]) == True) or (is_categorical_dtype(type(df[x][df.first_valid_index()])) == True)) and ((is_numeric_dtype(df[y]) == True) or (is_numeric_dtype(type(df[y][df.first_valid_index()])) == True)):
if ((is_object_dtype(df[x]) == True) or (is_object_dtype(type(df[x][first_valid_index(df)])) == True) or (is_categorical_dtype(df[x]) == True) or (is_categorical_dtype(type(df[x][first_valid_index(df)])) == True)) and ((is_numeric_dtype(df[y]) == True) or (is_numeric_dtype(type(df[y][first_valid_index(df)])) == True)):
try:
ax.get_shared_x_axes().get_siblings(ax)[0].yaxis.get_label().set_fontsize(label_fontsize)
except:
raise Exception('Unknown label fontsize argument!')
elif ((is_numeric_dtype(df[x]) == True) or (is_numeric_dtype(type(df[x][df.first_valid_index()])) == True)) and ((is_object_dtype(df[y]) == True) or (is_object_dtype(type(df[y][df.first_valid_index()])) == True) or (is_categorical_dtype(df[y]) == True) or (is_categorical_dtype(type(df[y][df.first_valid_index()])) == True)):
elif ((is_numeric_dtype(df[x]) == True) or (is_numeric_dtype(type(df[x][first_valid_index(df)])) == True)) and ((is_object_dtype(df[y]) == True) or (is_object_dtype(type(df[y][first_valid_index(df)])) == True) or (is_categorical_dtype(df[y]) == True) or (is_categorical_dtype(type(df[y][first_valid_index(df)])) == True)):
try:
ax.get_shared_y_axes().get_siblings(ax)[0].xaxis.get_label().set_fontsize(label_fontsize)
except:
Expand Down
5 changes: 3 additions & 2 deletions grplot/features/plot/plot_single_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pandas.api.types import is_numeric_dtype, is_object_dtype, is_categorical_dtype
from grplot.features.plot.packedbubbles import plot as pb
from grplot.features.plot.treemaps import plot as tms
from grplot.utils.first_valid_index import first_valid_index


def plot_single_def(plot,
Expand Down Expand Up @@ -1072,7 +1073,7 @@ def plot_single_def(plot,
raise Exception('Define axis label!')
elif plot == 'paretoplot':
if x is not None and y is not None:
if ((is_object_dtype(data[x]) == True) or (is_object_dtype(type(data[x][data.first_valid_index()])) == True) or (is_categorical_dtype(data[x]) == True) or (is_categorical_dtype(type(data[x][data.first_valid_index()])) == True)) and ((is_numeric_dtype(data[y]) == True) or (is_numeric_dtype(type(data[y][data.first_valid_index()])) == True)):
if ((is_object_dtype(data[x]) == True) or (is_object_dtype(type(data[x][first_valid_index(data)])) == True) or (is_categorical_dtype(data[x]) == True) or (is_categorical_dtype(type(data[x][first_valid_index(data)])) == True)) and ((is_numeric_dtype(data[y]) == True) or (is_numeric_dtype(type(data[y][first_valid_index(data)])) == True)):
data_pareto_x, idx, counts = numpy.unique(data[x], return_inverse=True, return_counts=True)
data_bin_y = numpy.bincount(idx, weights=data[y])
data_pareto_y = data_bin_y / counts
Expand Down Expand Up @@ -1170,7 +1171,7 @@ def plot_single_def(plot,
ax2.grid(False)
ax2.set_ylabel('Cumulative Percentage')
ax.get_shared_x_axes().get_siblings(ax)[0].set_ylim([0,110])
elif ((is_numeric_dtype(data[x]) == True) or (is_numeric_dtype(type(data[x][data.first_valid_index()])) == True)) and ((is_object_dtype(data[y]) == True) or (is_object_dtype(type(data[y][data.first_valid_index()])) == True) or (is_categorical_dtype(data[y]) == True) or (is_categorical_dtype(type(data[y][data.first_valid_index()])) == True)):
elif ((is_numeric_dtype(data[x]) == True) or (is_numeric_dtype(type(data[x][first_valid_index(data)])) == True)) and ((is_object_dtype(data[y]) == True) or (is_object_dtype(type(data[y][first_valid_index(data)])) == True) or (is_categorical_dtype(data[y]) == True) or (is_categorical_dtype(type(data[y][first_valid_index(data)])) == True)):
data_pareto_y, idx, counts = numpy.unique(data[y], return_inverse=True, return_counts=True)
data_bin_x = numpy.bincount(idx, weights=data[x])
data_pareto_x = data_bin_x / counts
Expand Down
3 changes: 2 additions & 1 deletion grplot/features/sep/tick_sep/tick_sep_data_def.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from pandas.api.types import is_numeric_dtype
from grplot.features.sep.tick_sep.tick_sep_def import tick_sep_def
from grplot.utils.first_valid_index import first_valid_index


def tick_sep_data_def(df, ax, axis, axislabel, sep):
if axislabel in df:
if (is_numeric_dtype(df[axislabel]) == True) or (is_numeric_dtype(type(df[axislabel][df.first_valid_index()])) == True):
if (is_numeric_dtype(df[axislabel]) == True) or (is_numeric_dtype(type(df[axislabel][first_valid_index(df)])) == True):
tick_sep_def(ax=ax, axis=axis, sep=sep)
else:
pass
Expand Down
3 changes: 2 additions & 1 deletion grplot/features/text/text_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import matplotlib
from grplot.features.add.text_add.text_add_type import text_add_type
from grplot.features.sep.text_sep.text_sep_type import text_sep_type
from grplot.utils.first_valid_index import first_valid_index


def text_def(plot, df, ax, ci, hue, multiple, axis, text, sep, add, text_fontsize, naxislabel, axislabel, axes):
Expand Down Expand Up @@ -36,7 +37,7 @@ def text_def(plot, df, ax, ci, hue, multiple, axis, text, sep, add, text_fontsiz
# numerical check for main axis of histplot, barplot, countplot, barplot in paretoplot
numeric = False
if axislabel in df:
if (is_numeric_dtype(df[axislabel]) == True) or (is_numeric_dtype(type(df[axislabel][df.first_valid_index()])) == True):
if (is_numeric_dtype(df[axislabel]) == True) or (is_numeric_dtype(type(df[axislabel][first_valid_index(df)])) == True):
numeric = True
else:
pass
Expand Down
12 changes: 12 additions & 0 deletions grplot/utils/first_valid_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy
import pandas


def first_valid_index(df):
if type(df) in [list, numpy.ndarray]:
first_valid_index = 0
elif type(df) == pandas.core.frame.DataFrame:
first_valid_index = df.first_valid_index()
else:
raise Exception('Unsupported data structure!')
return first_valid_index
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

DISTNAME = "grplot"
VERSION = "0.9.2"
VERSION = "0.9.3"
MAINTAINER = "Ghiffary Rifqialdi"
MAINTAINER_EMAIL = "[email protected]"
DESCRIPTION = "grplot: lazy statistical data visualization"
Expand Down

0 comments on commit 40f17d3

Please sign in to comment.