Skip to content

Commit

Permalink
Timeseries visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
nschaetti committed Jan 25, 2019
1 parent 93981b0 commit 1c8e58b
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
4 changes: 3 additions & 1 deletion echotorch/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# Imports
from .error_measures import nrmse, nmse, rmse, mse, perplexity, cumperplexity
from .utility_functions import spectral_radius, deep_spectral_radius, normalize, average_prob, max_average_through_time
from .visualisation import show_3d_timeseries, show_2d_timeseries, show_1d_timeseries

__all__ = [
'nrmse', 'nmse', 'rmse', 'mse', 'perplexity', 'cumperplexity', 'spectral_radius', 'deep_spectral_radius',
'normalize', 'average_prob', 'max_average_through_time'
'normalize', 'average_prob', 'max_average_through_time', 'show_3d_timeseries', 'show_2d_timeseries',
'show_1d_timeseries'
]
68 changes: 68 additions & 0 deletions echotorch/utils/visualisation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
#

# Imports
import torch
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D


# Show 3D time series
def show_3d_timeseries(ts, title):
"""
Show 3D timeseries
:param axis:
:param title:
:return:
"""
# Fig
fig = plt.figure()
ax = fig.gca(projection='3d')

ax.plot(ts[:, 0].numpy(), ts[:, 1].numpy(), ts[:, 2].numpy(), lw=0.5)
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.set_zlabel("Z Axis")
ax.set_title(title)
plt.show()
# end show_3d_timeseries


# Show 2D time series
def show_2d_timeseries(ts, title):
"""
Show 2D timeseries
:param ts:
:param title:
:return:
"""
# Fig
fig = plt.figure()
ax = fig.gca()

ax.plot(ts[:, 0].numpy(), ts[:, 1].numpy(), lw=0.5)
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.set_title(title)
plt.show()
# end show_2d_timeseries


# Show 1D time series
def show_1d_timeseries(ts, title):
"""
Show 1D time series
:param ts:
:param title:
:return:
"""
# Fig
fig = plt.figure()
ax = fig.gca()

ax.plot(ts[:, 0].numpy())
ax.set_xlabel("X Axis")
ax.set_title(title)
plt.show()
# end show_1d_timeseries

0 comments on commit 1c8e58b

Please sign in to comment.