Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special cmap #22

Open
raresionut1 opened this issue Apr 13, 2023 · 1 comment
Open

Special cmap #22

raresionut1 opened this issue Apr 13, 2023 · 1 comment
Assignees
Labels
doc Documentation update

Comments

@raresionut1
Copy link

I've seen this confusion matrix example using your code, but I can't manage to find the specific color map that was used here.

NuOUD

@Financialnomad
Copy link

Financialnomad commented May 23, 2023

Hello, I couldn´t find it either so chatgpt created a custom one for me:
`import matplotlib.pyplot as plt
import matplotlib.colors as colors

Define the RGB values of regular green and dark green

white = (0.56, 0.7372, 0.56) #Abbreviated RGB notation applis a division by 255
regn_green = (0.596, 0.984, 0.596) # regular green: (red, green, blue) = (0, 1, 0)
dark_green = (0, 0.2, 0) # dark green: (red, green, blue) = (0, 0.2, 0)

Use LinearSegmentedColormap to define the colorscale

cdict = {'red': ((0.0, white[0], white[0]), (0.25, regn_green[0], regn_green[0]), (1.0, dark_green[0], dark_green[0])),
'green': ((0.0, white[1], white[1]), (0.25, regn_green[1], regn_green[1]), (1.0, dark_green[1], dark_green[1])),
'blue': ((0.0, white[2], white[2]), (0.25, regn_green[2], regn_green[2]), (1.0, dark_green[2], dark_green[2]))}

mycmap = colors.LinearSegmentedColormap('myGreen', cdict)

Test the colorscale with a colorbar

plt.colorbar(plt.imshow([[0,.25,.50,.75, 1]], cmap=mycmap)) # adjust the data range if needed
plt.show()`

@wcipriano wcipriano self-assigned this May 9, 2024
@wcipriano wcipriano added the doc Documentation update label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Documentation update
Projects
None yet
Development

No branches or pull requests

3 participants