Commit 02d11ad2 authored by Emmanuel PIGNAT's avatar Emmanuel PIGNAT
Browse files

various updates in plot

parent c3fbee75
......@@ -269,7 +269,7 @@ def plot_linear_system(K, b=None, name=None, nb_sub=10, ax0=None, xlim=[-1, 1],
return [strm]
def plot_function_map(f, nb_sub=10, ax0=None, xlim=[-1, 1], ylim=[-1, 1], opp=False):
def plot_function_map(f, nb_sub=10, ax=None, xlim=[-1, 1], ylim=[-1, 1], opp=False, exp=False):
"""
:param f: [function]
......@@ -290,13 +290,17 @@ def plot_function_map(f, nb_sub=10, ax0=None, xlim=[-1, 1], ylim=[-1, 1], opp=Fa
zz = f(mesh_data)
except: # if function cannot take a vector as input
zz = np.array([f(_x) for _x in mesh_data])
z = zz.reshape(xx.shape)
if ax is None:
ax = plt
CS = plt.contour(xx, yy, z, cmap='viridis')
plt.clabel(CS, inline=1, fontsize=10)
CS = ax.contour(xx, yy, z, cmap='viridis')
ax.clabel(CS, inline=1, fontsize=10)
if opp: z = -z
plt.imshow(np.exp(z), interpolation='bilinear', origin='lower', extent=xlim + ylim,
if exp: z = np.exp(z)
ax.imshow(z, interpolation='bilinear', origin='lower', extent=xlim + ylim,
alpha=0.5, cmap='viridis')
def plot_mixture_linear_system(model, mode='glob', nb_sub=20, gmm=True, min_alpha=0.,
......@@ -542,7 +546,8 @@ def plot_gaussian(mu, sigma, dim=None, color='r', alpha=0.5, lw=1, markersize=6,
return center, line
def plot_y_gaussian(x, mu, sigma, dim=0, alpha=1., alpha_fill=None, color='r', lw=1.):
def plot_y_gaussian(x, mu, sigma, dim=0, alpha=1., alpha_fill=None, color='r', lw=1.,
ax=None):
"""
:param mu: [n_states]
......@@ -557,8 +562,11 @@ def plot_y_gaussian(x, mu, sigma, dim=0, alpha=1., alpha_fill=None, color='r', l
if alpha_fill is None:
alpha_fill = 0.4 * alpha
plt.plot(x, mu[:, dim], alpha=alpha, color=color)
plt.fill_between(x,
if ax is None:
ax = plt
ax.plot(x, mu[:, dim], alpha=alpha, color=color)
ax.fill_between(x,
mu[:, dim] - sigma[:, dim, dim] ** 0.5,
mu[:, dim] + sigma[:, dim, dim] ** 0.5,
alpha=alpha_fill, color=color)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment