Skip to content

Commit

Permalink
Merge branch 'master' into thull-dive_number_depth
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMohrmann authored Jul 17, 2023
2 parents d5c1662 + 2004155 commit 6b5fc69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ New Features

Breaking changes
~~~~~~~~~~~~~~~~
- GliderTools defaults for Figure creation were changed. Automatic application of plt.tight_layout was dropped in favour of more flexible embedding of GliderTools plots into existing layouts/subplots.
- The mixed layer depth algorithm was corrected. (:pull:`169`, :issue:`168`). By `Martin Mohrmann <https://github.com/MartinMohrmann>`_. API change! Existing mixed layer computation code must be adapted.
- Changed the behavior of `find_dive_phase` and `calc_dive_number` to use a smaller depth threshold when determining a valid dive (15 dbar down from 200 dbar). this is also now adjusteable. (:pull:`134`) By `Tom Hull <https://github.com/tomhull>`_.

Expand Down
32 changes: 12 additions & 20 deletions glidertools/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def pcolormesh(*args, **kwargs):
"""
from datetime import datetime

from matplotlib.pyplot import colorbar, subplots
from matplotlib.pyplot import colorbar, subplot
from numpy import datetime64, nanpercentile

ax = kwargs.pop("ax", None)
Expand All @@ -145,9 +145,7 @@ def pcolormesh(*args, **kwargs):
kwargs["vmax"] = nanpercentile(z.data, 99.5)

if ax is None:
fig, ax = subplots(1, 1, figsize=[9, 3.5], dpi=90)
else:
fig = ax.get_figure()
ax = subplot()

im = ax.pcolormesh(x, y, z, **kwargs)
ax.cb = colorbar(mappable=im, pad=0.02, ax=ax, fraction=0.05)
Expand All @@ -162,7 +160,6 @@ def pcolormesh(*args, **kwargs):
ax.set_title(name)

[tick.set_rotation(45) for tick in ax.get_xticklabels()]
fig.tight_layout()

return ax

Expand Down Expand Up @@ -194,7 +191,7 @@ def contourf(*args, **kwargs):

from datetime import datetime

from matplotlib.pyplot import colorbar, subplots
from matplotlib.pyplot import colorbar, subplot
from numpy import datetime64, nanpercentile

ax = kwargs.pop("ax", None)
Expand All @@ -210,9 +207,7 @@ def contourf(*args, **kwargs):
kwargs["vmax"] = nanpercentile(z[~z.mask], 99.5)

if ax is None:
fig, ax = subplots(1, 1, figsize=[9, 3.5], dpi=90)
else:
fig = ax.get_figure()
ax = subplot()

im = ax.contourf(x, y, z, **kwargs)
ax.cb = colorbar(mappable=im, pad=0.02, ax=ax, fraction=0.05)
Expand All @@ -225,7 +220,6 @@ def contourf(*args, **kwargs):
ax.cb.set_label(name)

[tick.set_rotation(45) for tick in ax.get_xticklabels()]
fig.tight_layout()

return ax

Expand Down Expand Up @@ -259,7 +253,7 @@ def scatter(x, y, z, ax=None, robust=False, **kwargs):

from datetime import datetime

from matplotlib.pyplot import colorbar, subplots
from matplotlib.pyplot import colorbar, subplot
from numpy import array, datetime64, isnan, ma, nanmax, nanmin, nanpercentile

z = ma.masked_invalid(z)
Expand All @@ -285,9 +279,8 @@ def scatter(x, y, z, ax=None, robust=False, **kwargs):
kwargs["vmax"] = nanpercentile(z, 99.5)

if ax is None:
fig, ax = subplots(1, 1, figsize=[9, 3.5], dpi=90)
else:
fig = ax.get_figure()
ax = subplot()

im = ax.scatter(x, y, c=z, rasterized=True, **kwargs)

ax.cb = colorbar(mappable=im, pad=0.02, ax=ax, fraction=0.05)
Expand All @@ -297,7 +290,6 @@ def scatter(x, y, z, ax=None, robust=False, **kwargs):
ax.set_xlabel("Date" if x_time else "Dives")

[tick.set_rotation(45) for tick in ax.get_xticklabels()]
fig.tight_layout()

return ax

Expand Down Expand Up @@ -325,7 +317,7 @@ def bin_size(depth, bins=None, ax=None, add_colorbar=True, **hist_kwargs):
axes
"""
from matplotlib.colors import LogNorm
from matplotlib.pyplot import colorbar, subplots
from matplotlib.pyplot import colorbar, subplot
from numpy import abs, array, diff, isnan, nan, nanmedian, r_

from .mapping import get_optimal_bins
Expand Down Expand Up @@ -355,7 +347,7 @@ def bin_size(depth, bins=None, ax=None, add_colorbar=True, **hist_kwargs):
xbins = r_[nan, xbins]

if ax is None:
fig, ax = subplots(1, 1, figsize=[4, 6])
ax = subplot()

im = ax.hist2d(x, y, bins=bins, norm=LogNorm(), rasterized=True, **hist_kwargs)[
-1
Expand Down Expand Up @@ -648,6 +640,6 @@ def logo_wo_name(n_zigzags=3, ax=None):
return fig, ax


if __name__ == "__main__":
pass
"fun people"
# if __name__ == "__main__":
# pass
# "fun people"

0 comments on commit 6b5fc69

Please sign in to comment.