Closed ericmelse closed 2 months ago
Dear Thomas,
While exercising with your farver
package , I also used the r-wizard of the chatgpt website and that resulted in the correct code:
lab_b_L50 <- farver::encode_colour(
cbind(l=50,
a=0,
b=c(-100, -90, -80, -70, -60, -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)), from="lab")
lab_b_L50
That works just fine and next I create a figure with the result data, like:
So, my little tricky error was that I did not use a second closing bracket that is required )), from="lab")
For those interested in calculating the CIELAB AB plane at a given L-value, this is code how to produce that:
# Create a plane of colors for the CIELAB color space using the farver package
# Define the range and step size for a and b
a_range <- seq(-100, 100, by = 10)
b_range <- seq(-100, 100, by = 10)
# Create a grid of a and b values
lab_grid <- expand.grid(a = a_range, b = b_range)
# Define the constant lightness (L) value
lab_L <- 50
# Create the colors using the farver package
lab_AxB_L50_10 <- farver::encode_colour(
cbind(
l = lab_L,
a = lab_grid$a,
b = lab_grid$b
), from = "lab"
)
Which results in:
Dear Thomas,
With great interest I am exploring your fine package
farver
but I have issues while usingfarver::encode_colour
My objective is to calculate color codes between color spaces. Here I get a range of colours in CIELAB space using:That works just fine and next I create a figure with the result data, like: With the above I want to show (graded) colors along the CIELAB a-axis with the b-axis value of each color set to 0 (neutral point) at the lightness level set to 50.
But, now I want to do the same for the CIELAB b-axis using this command:
As such the command code runs without any complaint, but using
lab_b_L50
after that results in the error message:I also tried:
which produces the same error message. Note that this command code (for the a-axis):
also produces the same error message.
So, maybe I am confused about how to set values for the a and b axis (dimension) in CIELAB but so far I found only one example in the documention that produces the expected result (which I used succesfully for the first example above).
Time permitting, I really apreciate your helping hand how to properly set such parameters for CIELAB (and OKLAB).
Best, Eric