Skip to content

Commit

Permalink
UPDATE: utils_plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
jungtaekkim committed Apr 25, 2020
1 parent a9b0e82 commit d303af9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
48 changes: 24 additions & 24 deletions bayeso/utils/utils_plotting.py
Expand Up @@ -17,6 +17,24 @@
from bayeso.utils import utils_common


def _set_font_config(is_tex):
"""
It sets a font configuration.
:param is_tex: flag for using latex.
:type is_tex: bool.
:returns: None.
:rtype: NoneType
"""

if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
return

def _set_ax_config(ax, str_x_axis, str_y_axis,
size_labels=32,
size_ticks=22,
Expand Down Expand Up @@ -178,10 +196,7 @@ def plot_gp_sampled(X, Ys,

if plt is None or pylab is None:
return
if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
_set_font_config(is_tex)

fig = plt.figure(figsize=(8, 6))
ax = plt.gca()
Expand Down Expand Up @@ -290,10 +305,7 @@ def plot_gp(X_train, Y_train, X_test, mu, sigma,

if plt is None or pylab is None:
return
if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
_set_font_config(is_tex)

fig = plt.figure(figsize=(8, 6))
ax = plt.gca()
Expand Down Expand Up @@ -403,10 +415,7 @@ def plot_minimum(arr_minima, list_str_label, int_init, is_std,

if plt is None or pylab is None:
return
if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
_set_font_config(is_tex)

fig = plt.figure(figsize=(8, 6))
ax = plt.gca()
Expand Down Expand Up @@ -542,10 +551,7 @@ def plot_minimum_time(arr_times, arr_minima, list_str_label, int_init, is_std,

if plt is None or pylab is None:
return
if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
_set_font_config(is_tex)

fig = plt.figure(figsize=(8, 6))
ax = plt.gca()
Expand Down Expand Up @@ -686,10 +692,7 @@ def plot_bo_step(X_train, Y_train, X_test, Y_test, mean_test, std_test,

if plt is None or pylab is None:
return
if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
_set_font_config(is_tex)

fig = plt.figure(figsize=(8, 6))
ax = plt.gca()
Expand Down Expand Up @@ -815,10 +818,7 @@ def plot_bo_step_acq(X_train, Y_train, X_test, Y_test, mean_test, std_test, acq_

if plt is None or pylab is None:
return
if is_tex:
plt.rc('text', usetex=True)
else:
plt.rc('pdf', fonttype=42)
_set_font_config(is_tex)

fig, (ax1, ax2) = plt.subplots(2, 1, gridspec_kw = {'height_ratios':[3, 1]})

Expand Down
12 changes: 6 additions & 6 deletions examples/99_notebooks/example_ts_gp_prior.ipynb
Expand Up @@ -14,7 +14,8 @@
"\n",
"from bayeso import gp\n",
"from bayeso import covariance\n",
"from bayeso.utils import utils_covariance"
"from bayeso.utils import utils_covariance\n",
"from bayeso.utils import utils_plotting"
]
},
{
Expand Down Expand Up @@ -78,11 +79,10 @@
"metadata": {},
"outputs": [],
"source": [
"plt.plot(np.arange(0, 51), np.mean(Ys, axis=0), lw=4)\n",
"plt.fill_between(np.arange(0, 51),\n",
" np.mean(Ys, axis=0) - 0.2 * np.std(Ys, axis=0),\n",
" np.mean(Ys, axis=0) + 0.2 * np.std(Ys, axis=0),\n",
" alpha=0.3)"
"utils_plotting.plot_minimum(np.array([Ys]), ['TS'], 1, True,\n",
" is_tex=True,\n",
" str_x_axis=r'\\textrm{Iteration}',\n",
" str_y_axis=r'\\textrm{Minimum regret}')"
]
},
{
Expand Down

0 comments on commit d303af9

Please sign in to comment.