Skip to content

Commit

Permalink
Merge pull request #57 from Serapieum-of-alex/new
Browse files Browse the repository at this point in the history
fix color scale when vmax is defined
  • Loading branch information
MAfarrag authored Apr 26, 2023
2 parents 030f29a + 9ecae1a commit 8f6fced
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ History
0.3.3 (2023-04-25)
------------------
* change the default value for the color bar label.

0.3.4 (2023-04-26)
------------------
* pass the plot kwargs to the init of the array to scale the color bar using the vmin and vmax.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pip install git+https://github.com/MAfarrag/cleopatra
## pip
to install the last release you can easly use pip
```
pip install cleopatra==0.3.3
pip install cleopatra==0.3.4
```

Quick start
Expand Down
15 changes: 11 additions & 4 deletions cleopatra/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
rgb: List[int] = None,
surface_reflectance: int = 10000,
cutoff: List = None,
**kwargs,
):
"""Plot array.
Expand Down Expand Up @@ -91,8 +92,14 @@ def __init__(
self.rgb = False

self._exclude_value = exclude_value
self._vmin = np.nanmin(array)
self._vmax = np.nanmax(array)

self._vmax = (
np.nanmax(array) if kwargs.get("vmax") is None else kwargs.get("vmax")
)
self._vmin = (
np.nanmin(array) if kwargs.get("vmin") is None else kwargs.get("vmin")
)

self.arr = array
# get the tick spacing that have 10 ticks only
self.ticks_spacing = (self._vmax - self._vmin) / 10
Expand All @@ -105,7 +112,7 @@ def __init__(
no_elem = np.size(array[:, :]) - np.count_nonzero((array[np.isnan(array)]))

self.no_elem = no_elem
self._default_options = DEFAULT_OPTIONS
self._default_options = DEFAULT_OPTIONS.copy()

def _prepare_rgb(
self,
Expand Down Expand Up @@ -191,7 +198,7 @@ def get_ticks(self) -> np.ndarray:
except ValueError:
raise ValueError(
"The number of ticks exceeded the max allowed size, possible errors"
f"is the value of the NodataValue you entered-{self.exclude_value}"
f" is the value of the NodataValue you entered-{self.exclude_value}"
)
ticks = np.append(
ticks,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

setup(
name="cleopatra",
version="0.3.3",
version="0.3.4",
description="visualization package",
author="Mostafa Farrag",
author_email="[email protected]",
url="https://github.com/MAfarrag/cleopatra",
keywords=["matplotlib", "arrays", "visualization"],
keywords=["matplotlib", "visualization"],
long_description=readme + "\n\n" + history,
repository="https://github.com/MAfarrag/celopatra",
documentation="https://celopatra.readthedocs.io/",
Expand Down

0 comments on commit 8f6fced

Please sign in to comment.