Skip to content

Commit 8f6fced

Browse files
authored
Merge pull request #57 from Serapieum-of-alex/new
fix color scale when vmax is defined
2 parents 030f29a + 9ecae1a commit 8f6fced

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ History
4747
0.3.3 (2023-04-25)
4848
------------------
4949
* change the default value for the color bar label.
50+
51+
0.3.4 (2023-04-26)
52+
------------------
53+
* pass the plot kwargs to the init of the array to scale the color bar using the vmin and vmax.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pip install git+https://github.com/MAfarrag/cleopatra
4848
## pip
4949
to install the last release you can easly use pip
5050
```
51-
pip install cleopatra==0.3.3
51+
pip install cleopatra==0.3.4
5252
```
5353

5454
Quick start

cleopatra/array.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(
3737
rgb: List[int] = None,
3838
surface_reflectance: int = 10000,
3939
cutoff: List = None,
40+
**kwargs,
4041
):
4142
"""Plot array.
4243
@@ -91,8 +92,14 @@ def __init__(
9192
self.rgb = False
9293

9394
self._exclude_value = exclude_value
94-
self._vmin = np.nanmin(array)
95-
self._vmax = np.nanmax(array)
95+
96+
self._vmax = (
97+
np.nanmax(array) if kwargs.get("vmax") is None else kwargs.get("vmax")
98+
)
99+
self._vmin = (
100+
np.nanmin(array) if kwargs.get("vmin") is None else kwargs.get("vmin")
101+
)
102+
96103
self.arr = array
97104
# get the tick spacing that have 10 ticks only
98105
self.ticks_spacing = (self._vmax - self._vmin) / 10
@@ -105,7 +112,7 @@ def __init__(
105112
no_elem = np.size(array[:, :]) - np.count_nonzero((array[np.isnan(array)]))
106113

107114
self.no_elem = no_elem
108-
self._default_options = DEFAULT_OPTIONS
115+
self._default_options = DEFAULT_OPTIONS.copy()
109116

110117
def _prepare_rgb(
111118
self,
@@ -191,7 +198,7 @@ def get_ticks(self) -> np.ndarray:
191198
except ValueError:
192199
raise ValueError(
193200
"The number of ticks exceeded the max allowed size, possible errors"
194-
f"is the value of the NodataValue you entered-{self.exclude_value}"
201+
f" is the value of the NodataValue you entered-{self.exclude_value}"
195202
)
196203
ticks = np.append(
197204
ticks,

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
setup(
1313
name="cleopatra",
14-
version="0.3.3",
14+
version="0.3.4",
1515
description="visualization package",
1616
author="Mostafa Farrag",
1717
author_email="[email protected]",
1818
url="https://github.com/MAfarrag/cleopatra",
19-
keywords=["matplotlib", "arrays", "visualization"],
19+
keywords=["matplotlib", "visualization"],
2020
long_description=readme + "\n\n" + history,
2121
repository="https://github.com/MAfarrag/celopatra",
2222
documentation="https://celopatra.readthedocs.io/",

0 commit comments

Comments
 (0)