-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from vaaaaanquish/calc_auto_figsize
Calc auto figsize
- Loading branch information
Showing
6 changed files
with
140 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
from cloudia.main import Cloudia | ||
from typing import Any, List | ||
|
||
from cloudia.main import CloudiaBase, Cloudia | ||
import matplotlib.pyplot as plt | ||
from wordcloud import STOPWORDS | ||
import pandas as pd | ||
|
||
|
||
@pd.api.extensions.register_dataframe_accessor('wc') | ||
class CloudiaDataFrame(Cloudia): | ||
class CloudiaDataFrame(CloudiaBase): | ||
def __init__(self, df): | ||
self.df = df | ||
|
||
def plot(self, | ||
single_words=[], | ||
stop_words=STOPWORDS, | ||
extract_postags=['名詞', '英単語', 'ローマ字文'], | ||
word_num=100, | ||
parser=None, | ||
parse_func=None, | ||
sampling_rate=1.0, | ||
dark_theme=False, | ||
figsize=(7.2, 4.8), | ||
wcsize=(720, 480), | ||
title_size=12, | ||
row_num=3): | ||
single_words: List[str] = [], | ||
stop_words: List[str] = STOPWORDS, | ||
extract_postags: List[str] = ['名詞', '英単語', 'ローマ字文'], | ||
word_num: int = 100, | ||
parser: Any = None, | ||
parse_func: Any = None, | ||
sampling_rate: float = 1.0, | ||
dark_theme: bool = False, | ||
title_size: int = 12, | ||
row_num: int = 3, | ||
figsize_rate: int = 2): | ||
Cloudia(self.df, single_words, stop_words, extract_postags, word_num, parser, parse_func, | ||
sampling_rate).plot(dark_theme, figsize, wcsize, title_size, row_num) | ||
sampling_rate).plot(dark_theme, title_size, row_num, figsize_rate) | ||
|
||
def save(self, fig_path, dark_theme, **args): | ||
self.plot(args) | ||
def save(self, fig_path: str, dark_theme: bool, **args: Any): | ||
self.plot(**args) | ||
plt.savefig(fig_path, facecolor=self._color(dark_theme), pad_inches=0.0, bbox_inches="tight") | ||
|
||
|
||
@pd.api.extensions.register_series_accessor('wc') | ||
class CloudiaSeries(Cloudia): | ||
class CloudiaSeries(CloudiaBase): | ||
def __init__(self, series): | ||
self.series = series | ||
|
||
def plot(self, | ||
single_words=[], | ||
stop_words=STOPWORDS, | ||
extract_postags=['名詞', '英単語', 'ローマ字文'], | ||
word_num=100, | ||
parser=None, | ||
parse_func=None, | ||
sampling_rate=1.0, | ||
dark_theme=False, | ||
figsize=(7.2, 4.8), | ||
wcsize=(720, 480), | ||
title_size=12, | ||
row_num=3): | ||
single_words: List[str] = [], | ||
stop_words: List[str] = STOPWORDS, | ||
extract_postags: List[str] = ['名詞', '英単語', 'ローマ字文'], | ||
word_num: int = 100, | ||
parser: Any = None, | ||
parse_func: Any = None, | ||
sampling_rate: float = 1.0, | ||
dark_theme: bool = False, | ||
title_size: int = 12, | ||
row_num: int = 3, | ||
figsize_rate: int = 2): | ||
Cloudia(self.series, single_words, stop_words, extract_postags, word_num, parser, parse_func, | ||
sampling_rate).plot(dark_theme, figsize, wcsize, title_size, row_num) | ||
sampling_rate).plot(dark_theme, title_size, row_num, figsize_rate) | ||
|
||
def save(self, fig_path, dark_theme, **args): | ||
self.plot(args) | ||
def save(self, fig_path: str, dark_theme: bool, **args: Any): | ||
self.plot(**args) | ||
plt.savefig(fig_path, facecolor=self._color(dark_theme), pad_inches=0.0, bbox_inches="tight") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters