So entfernen Sie Xarray Plot schlechte WertkantenfarbePython

Python-Programme
Anonymous
 So entfernen Sie Xarray Plot schlechte Wertkantenfarbe

Post by Anonymous »

Ich weiß, set_bad kann das Pixel in eine bestimmte Farbe färben, aber in meinem Beispiel möchte ich nur eine Kantenfarbe für blaue und graue Pixel mit Werten und nicht den schlechten Pixeln (rot) < /p>
haben

Code: Select all

import matplotlib.pyplot as plt
import xarray as xr
import numpy as np
from matplotlib import colors

fig, ax = plt.subplots(1, 1, figsize=(12, 8))
# provide example data array with a mixture of floats and nans in them
data = xr.DataArray([np.random.rand(10, 10)])  # Example data

# set a few nans
data[0, 1, 1] = np.nan
data[0, 1, 2] = np.nan
data[0, 1, 3] = np.nan
data[0, 2, 1] = np.nan
data[0, 2, 2] = np.nan
data[0, 2, 3] = np.nan
data[0, 3, 1] = np.nan
data[0, 3, 2] = np.nan
data[0, 3, 3] = np.nan

cmap = colors.ListedColormap(['#2c7bb6', "#999999"])
# make nan trends invalid and set edgecolour to white
cmap.set_bad(color = 'red')

data.plot(edgecolor = "grey", cmap = cmap)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post