Skip to content

Commit

Permalink
plot function
Browse files Browse the repository at this point in the history
  • Loading branch information
derohde committed May 7, 2022
1 parent 8bf2296 commit c28d39e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions Fred/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,40 @@

def plot_curve(*curves, savename=None, saveextension=None):
import matplotlib.pyplot as plt
max_compl = 1
for curve in curves:
if isinstance(curve, backend.Curve):
max_compl = max(max_compl, curve.complexity)
elif isinstance(curve, backend.Curves):
for curv in curve:
max_compl = max(max_compl, curv.complexity)
elif isinstance(curve, backend.Clustering_Result):
for curv in curve:
max_compl = max(max_compl, curv.complexity)
for curve in curves:
if isinstance(curve, backend.Curve):
if curve.dimensions >= 2:
p = plt.plot(curve.values[:, 0], curve.values[:, 1], '--o', label = curve.name, markersize = 7, markevery = curve.complexity)
plt.plot(curve.values[1:, 0], curve.values[1:, 1], 'x', label = None, color = p[0].get_color(), markersize = 7)
else:
p = plt.plot(range(0, len(curve)), curve.values, '--o', label = curve.name, markersize = 7, markevery = curve.complexity)
plt.plot(range(1, len(curve)), curve.values[1:], 'x', label = None, color = p[0].get_color(), markersize = 7)
p = plt.plot([i * max_compl / len(curve) for i in range(len(curve))], curve.values, '--o', label = curve.name, markersize = 7, markevery = curve.complexity)
plt.plot([i * max_compl / len(curve) for i in range(1, len(curve))], curve.values[1:], 'x', label = None, color = p[0].get_color(), markersize = 7)
elif isinstance(curve, backend.Curves):
for curv in curve:
if curv.dimensions >= 2:
p = plt.plot(curv.values[:, 0], curv.values[:, 1], '--o', label = curv.name, markersize = 7, markevery = curv.complexity)
plt.plot(curv.values[1:, 0], curv.values[1:, 1], 'x', label = None, color = p[0].get_color(), markersize = 7)
else:
p = plt.plot(range(0, len(curv)), curv.values, '--o', label = curv.name, markersize = 7, markevery = curv.complexity)
plt.plot(range(1, len(curv)), curv.values[1:], 'x', label = None, color = p[0].get_color(), markersize = 7)
p = plt.plot([i * max_compl / len(curv) for i in range(len(curv))], curv.values, '--o', label = curv.name, markersize = 7, markevery = curv.complexity)
plt.plot([i * max_compl / len(curv) for i in range(1, len(curv))], curv.values[1:], 'x', label = None, color = p[0].get_color(), markersize = 7)
elif isinstance(curve, backend.Clustering_Result):
for curv in curve:
if curv.dimensions >= 2:
p = plt.plot(curv.values[:, 0], curv.values[:, 1], '-o', label = curv.name, markersize = 7, markevery = curv.complexity)
plt.plot(curv.values[1:, 0], curv.values[1:, 1], 'x', label = None, color = p[0].get_color(), markersize = 7)
else:
p = plt.plot(range(0, len(curv)), curv.values, '-o', label = curv.name, markersize = 7, markevery = curv.complexity)
plt.plot(range(0, len(curv)), curv.values[1:], 'x', label = None, color = p[0].get_color(), markersize = 7)

p = plt.plot([i * max_compl / len(curv) for i in range(len(curv))], curv.values, '-o', label = curv.name, markersize = 7, markevery = curv.complexity)
plt.plot([i * max_compl / len(curv) for i in range(1, len(curv))], curv.values[1:], 'x', label = None, color = p[0].get_color(), markersize = 7)
plt.legend(title='Curve names:')
plt.title('Fred Curves')
if savename is None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def build_extension(self, ext):

setup(
name='Fred-Frechet',
version='1.9.10',
version='1.9.11',
author='Dennis Rohde',
author_email='[email protected]',
description='A fast, scalable and light-weight C++ Fréchet distance library, exposed to python and focused on (k,l)-clustering of polygonal curves.',
Expand Down

0 comments on commit c28d39e

Please sign in to comment.