diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index baa2d3b..762cf1b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -32,8 +32,8 @@ jobs: lfs: true # Install emcpy - - name: Upgrade pip - run: $CONDA/bin/pip3 install --upgrade pip + #- name: Upgrade pip + # run: $CONDA/bin/pip3 install --upgrade pip - name: Install emcpy and dependencies run: | $CONDA/bin/pip3 install --use-deprecated=legacy-resolver -r requirements-github.txt --user . diff --git a/requirements-github.txt b/requirements-github.txt index 75322ef..f03954f 100644 --- a/requirements-github.txt +++ b/requirements-github.txt @@ -1,14 +1,14 @@ pyyaml>=6.0 -pycodestyle==2.9.1 -netCDF4==1.6.1 +pycodestyle>=2.9.1 +netCDF4>=1.6.1 matplotlib==3.5.2 -cartopy==0.21.1 -scikit-learn==1.1.2 -xarray==2022.6.0 +cartopy>=0.21.1 +scikit-learn>=1.1.2 +xarray>=2022.6.0 pytest Shapely pdoc -seaborn==0.12.2 +seaborn>=0.12.2 sphinx sphinx_rtd_theme sphinx_gallery diff --git a/setup.cfg b/setup.cfg index 1b0f8c1..418c07e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,7 +46,6 @@ install_requires = scikit-learn pdoc matplotlib - Cython cartopy tests_require = pytest diff --git a/src/emcpy/plots/create_plots.py b/src/emcpy/plots/create_plots.py index f3e8aed..afc28b0 100644 --- a/src/emcpy/plots/create_plots.py +++ b/src/emcpy/plots/create_plots.py @@ -333,7 +333,7 @@ def add_suptitle(self, text, **kwargs): self.fig.suptitle(text, **kwargs) def plot_logo(self, loc, which='noaa/nws', - zoom=1, alpha=0.5): + subplot_orientation='last', zoom=1, alpha=0.5): """ Add branding logo on all axes. """ @@ -343,6 +343,29 @@ def plot_logo(self, loc, which='noaa/nws', 'noaa/nws': 'noaa_nws_logo_150x75.png' } + image_path = os.path.join(emcpy.emcpy_directory, 'logos', image_dict[which]) + im = Image.open(image_path) + + if subplot_orientation.lower() not in ['first', 'last', 'all']: + raise TypeError(f"{subplot_orientation} is not a valid input. " + + "Valid inputs include 'first', 'last', or 'all'") + + ax_list = self.fig.axes + + if subplot_orientation.lower() == 'first': + ax = ax_list[0] + self._display_logo(ax, im, loc, zoom, alpha) + + elif subplot_orientation.lower() == 'last': + ax = ax_list[-1] + self._display_logo(ax, im, loc, zoom, alpha) + + else: + for ax in ax_list: + self._display_logo(ax, im, loc, zoom, alpha) + + def _display_logo(self, ax, im, loc, zoom, alpha): + loc_dict = { 'upper right': 1, 'upper left': 2, @@ -356,23 +379,17 @@ def plot_logo(self, loc, which='noaa/nws', 'center': 10 } - image_path = os.path.join(emcpy.emcpy_directory, 'logos', image_dict[which]) - im = Image.open(image_path) - - ax_list = self.fig.axes - - for ax in ax_list: - width, height = ax.figure.get_size_inches()*self.fig.dpi - wm_width = int(width/4) # make the watermark 1/4 of the figure size - scaling = (wm_width / float(im.size[0])) - wm_height = int(float(im.size[1])*float(scaling)) + width, height = ax.figure.get_size_inches()*self.fig.dpi + wm_width = int(width/4) # make the watermark 1/4 of the figure size + scaling = (wm_width / float(im.size[0])) + wm_height = int(float(im.size[1])*float(scaling)) - imagebox = OffsetImage(im, zoom=zoom, alpha=alpha) - imagebox.image.axes = ax + imagebox = OffsetImage(im, zoom=zoom, alpha=alpha) + imagebox.image.axes = ax - ao = AnchoredOffsetbox(loc_dict[loc], pad=0.1, borderpad=0.1, child=imagebox) - ao.patch.set_alpha(0) - ax.add_artist(ao) + ao = AnchoredOffsetbox(loc_dict[loc], pad=0.1, borderpad=0.1, child=imagebox) + ao.patch.set_alpha(0) + ax.add_artist(ao) def _plot_features(self, plot_obj, feature, ax):