Commit ae9b671b authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

added a plotting method

parent bfcced83
......@@ -1254,7 +1254,7 @@ class Tensors(AbstractNdarray):
"""
# weights = self.getNormedWeightedAreas(weights=weights)
weights = self._weights(weights)
mean = self.moments(1)
mean = np.array(self).mean(axis=0)
relative_coords = self - mean
cov = np.cov(relative_coords.T,
ddof=0,
......
......@@ -6,7 +6,17 @@ import shutil
import subprocess
import contextlib
import logging
from pathlib import Path
try:
from pathlib import Path as PathlibPath
PathlibPath().expanduser() # not existing in python2 version of pathlib
except (ImportError, AttributeError):
from pathlib2 import Path as PathlibPath
class Path(type(PathlibPath())):
def resolve(self):
new_path = self.expanduser()
return super(Path, new_path).resolve()
def resolve(path):
......
......@@ -445,6 +445,50 @@ def plot_function(fun, **kwargs):
return artist
def plot_errorbar(points, errors_up, errors_down=None, **kwargs):
"""
Args:
axis (matplotlib.Axis) object
Returns:
Artist or list of Artists (imitating the axis.scatter/plot behaviour).
Better Artist not list of Artists
"""
po = tfields.plotting.PlotOptions(kwargs)
po.set_default('marker', '_')
if errors_down is None:
errors_down = errors_up
artists = []
# plot points
# artists.append(po.axis.plot(points, **po.plotKwargs))
# plot errorbars
for i in range(len(points)):
artists.append(
po.axis.plot([points[i, 0] + errors_up[i, 0],
points[i, 0] - errors_down[i, 0]],
[points[i, 1], points[i, 1]],
[points[i, 2], points[i, 2]],
**po.plotKwargs))
artists.append(
po.axis.plot([points[i, 0], points[i, 0]],
[points[i, 1] + errors_up[i, 1],
points[i, 1] - errors_down[i, 1]],
[points[i, 2], points[i, 2]],
**po.plotKwargs))
artists.append(
po.axis.plot([points[i, 0], points[i, 0]],
[points[i, 1], points[i, 1]],
[points[i, 2] + errors_up[i, 2],
points[i, 2] - errors_down[i, 2]],
**po.plotKwargs))
return artists
"""
Color section
"""
......
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