Created
August 2, 2023 16:05
-
-
Save ncalm/93ea267c9305a7a0256e62f9f4b3d66b to your computer and use it in GitHub Desktop.
This Excel LAMBDA function calculates the coordinates for two series to add to a scatterplot to produce a vertical and horizontal line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chart.Quadrants = LAMBDA(seriesData, | |
LET( | |
// The first column (x values) | |
x, TAKE(seriesData, , 1), | |
// The second column (y values) | |
y, TAKE(seriesData, , -1), | |
xMax, MAX(x), | |
yMax, MAX(y), | |
// Assuming we want lines as close to the "middle" as possible | |
xMid, INT(xMax / 2), | |
yMid, INT(yMax / 2), | |
// To make the use of HSTACK shorter - that's all! | |
H, LAMBDA(one, two, HSTACK(one, two)), | |
// Create the coordinates of the beginning and end of each line | |
H( | |
{"Vertical Line"; ""; "Horizontal Line"; ""}, | |
VSTACK(H(xMid, 0), H(xMid, yMax), H(0, yMid), H(xMax, yMid)) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment