Closed atoparseks closed 1 year ago
Hi @atoparseks, I fully agree - I actually wanted to address this issue already a while ago and remember that I gave up a bit frustrated because matplotlib ignored the color argument for the background. But we should definitely solve the issue and also five the user the chance to use a custom background color.
Hi @atoparseks, I now figured out how to change the color of the nodata pixels, i.e., those pixels masked out. To do so, I added a new optional keyword argument in RasterCollection.plot_multiple_bands
named nodata_color
. By default it is set to 'white' to mimic the default behavior of the Band.plot
method.
nodata_color
can be set, however, to any color name available in matplotlib (see here for a full list of named colors).
The code snippet below shows the usage:
from eodal.core.band import Band, GeoInfo
from eodal.core.raster import RasterCollection
import numpy as np
# open sample data
rc = RasterCollection.from_multi_band_raster(fpath_raster='data/20190530_T32TMT_MSIL2A_S2A_pixel_division_10m.tiff')
# mask some pixels so we can test the new functionality
masked = rc.mask(mask=rc['B8A'] > 1000, bands_to_mask=rc.band_names)
# no-data colored white [255,255,255] (new default) -> same no-data color as Band.plot
masked.plot_multiple_bands(band_selection=['B02', 'B03', 'B04'], nodata_color='white')
# i.e., omitting the nodata_color argument will have the same effect as the
# previous statement
masked.plot_multiple_bands(band_selection=['B02', 'B03', 'B04'])
# no-data colored black [0,0,0] (old default until version 0.2.0)
masked.plot_multiple_bands(band_selection=['B02', 'B03', 'B04'], nodata_color='black')
# no-data colored in an example matplotlib color, e.g. "red"
masked.plot_multiple_bands(band_selection=['B02', 'B03', 'B04'], nodata_color='red')
# or some other color, e.g., "darkkhaki"
masked.plot_multiple_bands(band_selection=['B02', 'B03', 'B04'], nodata_color='darkkhaki')
I close this issue since it is resolved by #61
Thanks! Looks really neat!
When I use scene.plot_multiple_bands, masked pixels are black:
For one band I can use scene.plot_band , and the masked pixels are white
I suggest white for both cases. Or black. This doesn't look good when placed side to side.