-
Notifications
You must be signed in to change notification settings - Fork 17
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
Error while using cvd_space #11
Comments
Yeah, the CVD model does that. If you're not doing anything weird, then the
out of range values are probably barely out if range, like 1.000003 or
-0.0007. In this case the simplest solution is to clip the values to fall
in the 0-1 range, like the tutorial you linked to does using 'np.clip'.
(The previous section of the tutorial, just above where you linked to, has
a bit of discussion about this.)
…On Jan 2, 2018 12:54 PM, "Nicolás Guarín-Zapata" ***@***.***> wrote:
I am trying to convert the hsv colormap simulating colorblindness as
described here
<https://colorspacious.readthedocs.io/en/latest/tutorial.html#simulating-colorblindness>.
But I obtain the following error
ValueError: RGBA values should be within 0-1 range
Due to values outside of [0, 1].
Following an example
from __future__ import division, print_function
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
from colorspacious import cspace_convert
azimuths = np.arange(0, 361, 1)
zeniths = np.arange(40, 70, 1)
values = azimuths * np.ones((30, 361))
data = plt.cm.hsv(np.linspace(0, 1, 64))
fig = plt.figure()
cvd_space = {"name": "sRGB1+CVD",
"cvd_type": "deuteranomaly",
"severity": 50}
data2 = cspace_convert(data[:, :3], cvd_space, "sRGB1")
cmap = LinearSegmentedColormap.from_list('my_colormap', data2)
ax = plt.subplot(111, projection='polar')
ax.pcolormesh(azimuths*np.pi/180.0, zeniths, values, cmap=cmap)
ax.set_xticks([])
ax.set_yticks([])
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#11>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAlOaMEFB0ITgLDHAT2OjWrUZ0Go6YMLks5tGpdpgaJpZM4RRENj>
.
|
I thought about that, and it worked. The only problem is that I obtained values between -1.989 and 1.047 :-/ |
Huh, yeah, that is weird. I just double-checked the paper, and it looks like we're implementing their formula correctly, and it really does just gives invalid values sometimes. And AFAICT they don't say anything about this or give any suggestions on how to handle it. I guess clipping is ... possibly not totally wrong? Not sure what to tell you. |
Thanks for double checking! You can see the plots I generated, if you are interested, here: https://nicoguaro.github.io/posts/cyclic_colormaps/ |
I am trying to convert the
hsv
colormap simulating colorblindness as described here. But I obtain the following errorDue to values outside of [0, 1].
Following an example
The text was updated successfully, but these errors were encountered: