Skip to content

Commit

Permalink
Issue 90 (#93)
Browse files Browse the repository at this point in the history
* (reattempt) Point release to fix deprecation breakage introduced by matplotlib

Matplotlib 3.6.0 introduces breaking deprecation on writeout
of non-ps backend plots specifying papertype and orientation

This only shows for code paths using Python 3.8
  • Loading branch information
bennahugo authored Sep 27, 2022
1 parent a638316 commit 3c9f5e3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
54 changes: 44 additions & 10 deletions Owlcat/Plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,15 @@ def make_figure(self, keylist=None, suptitle=None, save=None,
if suptitle:
fig.suptitle(suptitle, y=ytitle, size=8)
if save:
fig.savefig(save, papertype=papertype, dpi=dpi,
orientation='portrait' if not landscape else 'landscape')
dicokwargs = {
"dpi": dpi
}
# fix for matplotlib becoming stricter on papertype
if matplotlib.get_backend() == "ps":
dicokwargs["papertype"] = papertype
dicokwargs["orientation"] = 'portrait' if not landscape else 'landscape'

fig.savefig(save, **dicokwargs)
print("===> Wrote", save)
return fig

Expand Down Expand Up @@ -494,8 +501,14 @@ def make_figure(self, suptitle=None, save=None, xlabel=None, ylabel=None,
if suptitle:
fig.suptitle(suptitle, y=ytitle, size=10)
if save:
fig.savefig(save, papertype=papertype, dpi=dpi,
orientation='portrait' if not landscape else 'landscape')
dicokwargs = {
"dpi": dpi
}
# fix for matplotlib becoming stricter on papertype
if matplotlib.get_backend() == "ps":
dicokwargs["papertype"] = papertype
dicokwargs["orientation"] = 'portrait' if not landscape else 'landscape'
fig.savefig(save, **dicokwargs)
print("===> Wrote", save)
return fig

Expand Down Expand Up @@ -810,8 +823,15 @@ def plot_text(plt, lines):
orientation = 'landscape'
else:
orientation = 'portrait' if figsize[0] < figsize[1] else 'landscape'
fig.savefig(save, papertype=self.options.papertype, dpi=self.options.dpi,
orientation=orientation)
dicokwargs = {
"dpi": self.options.dpi
}
# fix for matplotlib becoming stricter on papertype
if matplotlib.get_backend() == "ps":
dicokwargs["papertype"] = self.options.papertype
dicokwargs["orientation"] = orientation

fig.savefig(save, **dicokwargs)
print("Wrote", save, "in", orientation, "orientation")
fig = None
pyplot.close("all")
Expand Down Expand Up @@ -965,8 +985,15 @@ def make_figure(self, ll, mm,
orientation = 'landscape'
else:
orientation = 'portrait' if figsize[0] < figsize[1] else 'landscape'
fig.savefig(save, papertype=self.options.papertype, dpi=self.options.dpi,
orientation=orientation)
dicokwargs = {
"dpi": self.options.dpi
}
# fix for matplotlib becoming stricter on papertype
if matplotlib.get_backend() == "ps":
dicokwargs["papertype"] = self.options.papertype
dicokwargs["orientation"] = orientation

fig.savefig(save, **dicokwargs)
print("Wrote", save, "in", orientation, "orientation")
fig = None
pyplot.close("all")
Expand Down Expand Up @@ -1137,8 +1164,15 @@ def utc2lst(utc):
orientation = 'landscape'
else:
orientation = 'portrait' if figsize[0] < figsize[1] else 'landscape'
fig.savefig(save, papertype=self.options.papertype, dpi=self.options.dpi,
orientation=orientation)
dicokwargs = {
"dpi": self.options.dpi
}
# fix for matplotlib becoming stricter on papertype
if matplotlib.get_backend() == "ps":
dicokwargs["papertype"] = self.options.papertype
dicokwargs["orientation"] = orientation

fig.savefig(save, **dicokwargs)
print("Wrote", save, "in", orientation, "orientation")
fig = None
pyplot.close("all")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]

setup(name='owlcat',
version='1.7.8.3',
version='1.7.8.4',
python_requires='>=3.6.0',
description='miscellaneous utility scripts for manipulating radio interferometry data',
author='Oleg Smirnov',
Expand Down

0 comments on commit 3c9f5e3

Please sign in to comment.