Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple plotting backends #65

Merged
merged 25 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f93cdb4
added pytest-depends as test dependency
mmaelicke Nov 30, 2020
c806186
some coverage settings
mmaelicke Nov 30, 2020
7582171
added plotting backend module
mmaelicke Nov 30, 2020
fca849c
moved Variogram.plot to plotting backend
mmaelicke Nov 30, 2020
acf1d91
ported scattergram to backend
mmaelicke Nov 30, 2020
efd6a66
added import check to backend function
mmaelicke Dec 1, 2020
f9dde19
added location_trend plot
mmaelicke Dec 1, 2020
4d61ad5
added distance-difference plot
mmaelicke Dec 1, 2020
ccb1f53
fix some errors
mmaelicke Dec 1, 2020
adc337c
remove dump file
mmaelicke Dec 1, 2020
92e93c0
added plotly to test requirements
mmaelicke Dec 1, 2020
848a6c3
Merge pull request #66 from mmaelicke/master
mmaelicke Dec 1, 2020
b9f5691
testing backend fails
mmaelicke Dec 1, 2020
c92725e
Merge branch 'plotting-backend' of https://github.com/mmaelicke/sciki…
mmaelicke Dec 1, 2020
fe1436c
started on directional_variogram plot
mmaelicke Feb 1, 2021
03f7c47
removed some surviving self references
mmaelicke Feb 1, 2021
ae1288f
fixes in matplotlib function
mmaelicke Feb 1, 2021
05e13e4
added plotly pair_field
mmaelicke Feb 1, 2021
307b28c
layout
mmaelicke Feb 1, 2021
125fb79
working on STV.fit
mmaelicke Feb 8, 2021
fbec8fa
added STVariogram 3D plotting methods
mmaelicke Feb 8, 2021
6d89cf6
plotting integration for 3D STVariograms + fixes
mmaelicke Feb 8, 2021
cf57aa7
name fix
mmaelicke Feb 8, 2021
3a3f92f
added contour plots
mmaelicke Feb 8, 2021
784b929
added marignal variogram plot
mmaelicke Feb 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[run]
omit =
skgstat/tests/*
skgstat/plotting/*
docs/*
setup.py

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ docs/_build
docs/savefig
notebooks
.vscode
container
container

# project specific
Playground.ipynb
4 changes: 3 additions & 1 deletion requirements.unittest.3.5.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pytest
pytest-cov
pytest-depends
pykrige
gstools==1.1.*
gstools==1.1.*
plotly
4 changes: 3 additions & 1 deletion requirements.unittest.3.6.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pytest
pytest-cov
pytest-depends
pykrige
gstools
gstools
plotly
4 changes: 3 additions & 1 deletion requirements.unittest.3.7.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pytest
pytest-cov
pytest-depends
pykrige
gstools
gstools
plotly
4 changes: 3 additions & 1 deletion requirements.unittest.3.8.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pytest
pytest-cov
pytest-depends
pykrige
gstools
gstools
plotly
55 changes: 8 additions & 47 deletions skgstat/DirectionalVariogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import matplotlib.collections

from .Variogram import Variogram
from skgstat import plotting


class DirectionalVariogram(Variogram):
Expand Down Expand Up @@ -551,7 +552,7 @@ def _direction_mask(self, force=False):
self._direction_mask_cache = self._directional_model(self._angles, self._euclidean_dist)
return self._direction_mask_cache

def pair_field(self, ax=None, cmap="gist_rainbow", points='all',add_points=True, alpha=0.3): # pragma: no cover
def pair_field(self, ax=None, cmap="gist_rainbow", points='all', add_points=True, alpha=0.3, **kwargs): # pragma: no cover
"""
Plot a pair field.

Expand All @@ -576,53 +577,13 @@ def pair_field(self, ax=None, cmap="gist_rainbow", points='all',add_points=True,
visualize better. Defaults to ``0.3``.

"""
# get the direction mask
mask = squareform(self._direction_mask())

# build a coordinate meshgrid
r = np.arange(len(self._X))
x1, x2 = np.meshgrid(r, r)
start = self._X[x1[mask]]
end = self._X[x2[mask]]

# handle lesser points
if isinstance(points, int):
points = [points]
if isinstance(points, list):
_start, _end = list(), list()
for p in self._X[points]:
_start.extend(start[np.where(end == p)[0]])
_end.extend(end[np.where(end == p)[0]])
start = np.array(_start)
end = np.array(_end)

# extract all lines and align colors
lines = np.column_stack((start.reshape(len(start), 1, 2), end.reshape(len(end), 1, 2)))
#colors = plt.cm.get_cmap(cmap)(x2[mask] / x2[mask].max())
colors = plt.cm.get_cmap(cmap)(np.linspace(0, 1, len(lines)))
colors[:, 3] = alpha

# get the figure and ax object
if ax is None:
fig, ax = plt.subplots(1, 1, figsize=(8,8))
else:
fig = ax.get_figure()

# plot
lc = matplotlib.collections.LineCollection(lines, colors=colors, linewidths=1)
ax.add_collection(lc)

# add coordinates
if add_points:
ax.scatter(self._X[:, 0], self._X[:, 1], 15, c='k')
if isinstance(points, list):
ax.scatter(self._X[:, 0][points], self._X[:, 1][points], 25, c='r')

# finish plot
ax.autoscale()
ax.margins(0.1)
# get the backend
used_backend = plotting.backend()

return fig
if used_backend == 'matplotlib':
return plotting.matplotlib_pair_field(self, ax=ax, cmap=cmap, points=points, add_points=add_points, alpha=alpha, **kwargs)
elif used_backend == 'plotly':
return plotting.plotly_pair_field(self, fig=ax, points=points, add_points=add_points, alpha=alpha, **kwargs)

def _triangle(self, angles, dists):
r"""Triangular Search Area
Expand Down
Loading