festim-dev / festim-dev/FESTIM-workshop
Correct colour norm for permeation regimes tutorial
- Dominant language
- Jupyter Notebook
- Stars
- 29
- Forks
- 12
- Avg merge
- 1d 35m
- Merged PRs (30d)
- 1
Description
```python
class MidPointLogNorm(mcolors.LogNorm):
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
mcolors.LogNorm.__init__(self,vmin=vmin, vmax=vmax, clip=clip)
self.midpoint=midpoint
def __call__(self, value, clip=None):
result, is_scalar = self.process_value(value)
x, y = [np.log(self.vmin), np.log(self.midpoint), np.log(self.vmax)], [0, 0.5, 1]
return np.ma.array(np.interp(np.log(value), x, y), mask=result.mask, copy=False)
# norm = mcolors.SymLogNorm(linthresh=permeation_number(pressures[0]), vmin=permeation_number(pressures[0]), vmax=permeation_number(pressures[-1]))
norm = MidPointLogNorm(vmin=permeation_number(pressures[0]), midpoint=1, vmax=permeation_number(pressures[-1]))
cmap = plt.cm.RdYlGn
```
Issue: for some reason making the colourbar with:
```python
sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
plt.colorbar(
sm,
label="Permeation number",
ax=plt.gca(),
)
```
Doesn't generate the right colourbar.... (the center is not on 1)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.