# Is it possible to access point coordinates from Plots using the box and lasso select from Plotly(JS)

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [September 26, 2021, 1:17pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776 "2021-09-26T13:17:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego\_Javier\_Zea](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diego_javier_zea/32/1858_2.png) [@Diego\_Javier\_Zea](https://discourse.julialang.org/u/Diego_Javier_Zea)\
**Post date:** [September 26, 2021, 1:17pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/1 "2021-09-26T13:17:35Z")

</div>

Hi! When performing a scatter plot using the Plotly or PlotlyJS backends of Plots, it is possible to use the box and lasso select tools. How can I access the coordinates of the selected points from Julia? Best,

---

<div class="post-metadata">

**Author:** ![jianghaizhu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jianghaizhu/32/1866_2.png) [@jianghaizhu](https://discourse.julialang.org/u/jianghaizhu)\
**Post date:** [April 4, 2022, 10:06pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/2 "2022-04-04T22:06:07Z")

</div>

Have you found any solution for this? If not Plotly(JS), is there any other plotting package in Julia’s ecosystem that can achieve this purpose?

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [February 23, 2024, 11:54am UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/3 "2024-02-23T11:54:36Z")

</div>

Also interested in this, any solutions found perhaps?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 23, 2024, 12:09pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/4 "2024-02-23T12:09:08Z")

</div>

The plotting ecosystem in active development nowadays is Makie.jl, they provide interactive utilities like this one you guys are after.

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [February 23, 2024, 1:29pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/5 "2024-02-23T13:29:01Z")

</div>

It seems that the [Makie page](https://docs.makie.org/stable/explanations/nodes/) on “interraction” doesn’t directly offer any advice on selecting data from a plot (unless I’m missing something).

Would you please be able to offer any advice on creating something like [this](https://codepen.io/plotly/pen/EPEGyE) example?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 23, 2024, 1:36pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/6 "2024-02-23T13:36:46Z")

</div>

Pinging @sdanisch @jules as they know better the current features.

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [May 13, 2024, 10:36am UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/7 "2024-05-13T10:36:50Z")

</div>

Bumping this post just in case we got any updates.

I had a look at makie, and it seems we could select some points in the plot, and use inequalities to define a convex region between them, but I can’t seem to figure out how to select a non-convex region (something like using the lasso tool in plotlyJS).

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [May 14, 2024, 1:25pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/8 "2024-05-14T13:25:13Z")

</div>

Not nonconvex regions, but the Pluto notebook here might be of interest:

> <https://github.com/fonsp/Pluto.jl/pull/2726#issuecomment-1822679377>
>
> Implementing the explorable mandelbrot set is so much easier with this PR!
> 
> ht…tps://github.com/fonsp/Pluto.jl/assets/12846528/009a01c1-8ad5-49c5-b7e1-98ff68ac8c5e
> 
> This code simply recomputes the mandelbrot set with a fixed number of points per dimension (500 over x and 500 over y) over the current range of the axes of the plot. So it is recomputed upon zoom or upon panning.
> 
> The notebook code hidden below should use the version of AbstractPlutoDingetjes from this branch, but it will be overwritten to the latest registered version when adding or removing packages (I believe)
> 
> \<details\>
> 
> \<summary\>Notebook Code\</summary\>
> 
> \`\`\`julia
> \### A Pluto.jl notebook ###
> \# v0.19.32
> 
> using Markdown
> using InteractiveUtils
> 
> \# ╔═╡ d6a4d6f0-8920-11ee-1360-dbb4ff626eb6
> begin
> using PlutoPlotly
> using HypertextLiteral
> using AbstractPlutoDingetjes
> end
> 
> \# ╔═╡ b4655ee1-dfe3-47a4-8b19-48c9fb2b6349
> \# This code is taken from a Mandelbrot notebook shared in https://discourse.julialang.org/t/mandelbrot-with-plots-jl/52410
> begin
> to\_range(raw\_range, n) = range(minimum(raw\_range), maximum(raw\_range); length=n)
> function mandel(z:: Complex) 
> c = z 
> maxiter = 128
> for n = 1:maxiter 
> if abs2(z) \> 4 
> return n-1 
> end 
> z = z^2 + c 
> end 
> return maxiter 
> end
> function mandel\_slice!(grid, ix, x, yrange)
> @inbounds for (iy, y) in enumerate(yrange)
> grid\[iy, ix\] = mandel(Complex(x,y))
> end
> end
> function mandel\_grid(xrange, yrange)
> grid = Matrix{UInt8}(undef, length(xrange), length(yrange))
> futures = Vector{Task}(undef, length(xrange))
> @inbounds for (ix, x) in enumerate(xrange)
> futures\[ix\] = Threads.@spawn mandel\_slice!(grid, ix, x, yrange)
> end
> wait.(futures)
> grid
> end
> end
> 
> \# ╔═╡ 059bbb92-5a68-46d7-a210-69fc1ce91aff
> let # This code generates the plot with re-computation upon zooming
> n = 500
> x = to\_range(\[-1, 1\], n)
> y = to\_range(\[-1, 1\], n)
> z = mandel\_grid(x,y)
> data = heatmap(;x,y,z)
> p = plot(data, Layout(xaxis\_range = \[-1, 1\], yaxis = attr(;
> range = \[-1,1\],
> scaleanchor = "x",
> scaleratio = 1,
> )))
> add\_plotly\_listener!(p, "plotly\_relayout", htl\_js("async (e) =\> {
> let xrange = PLOT.\_fullLayout.xaxis.range
> let yrange = PLOT.\_fullLayout.yaxis.range
> if (PLOT.updated\_data == undefined) {return}
> console.log(PLOT.updated\_data)
> let update = await PLOT.updated\_data({x: xrange, y: yrange})
> Plotly.restyle(PLOT, update)
> }"))
> f(d) = let
> x = range(d\["x"\]..., n) |\> collect
> y = range(d\["y"\]..., n) |\> collect
> z = mandel\_grid(x,y) |\> PlutoPlotly.\_preprocess
> out = (;
> x = \[x\],
> y = \[y\],
> z = \[z\],
> )
> out
> end
> @htl("""
> $p
> \<script\>
> const plt = currentScript.closest('pluto-cell').querySelector('.js-plotly-plot')
> plt.updated\_data = $(AbstractPlutoDingetjes.Display.with\_js\_link(f))
> \</script\>
> """)
> end
> 
> \# ╔═╡ 00000000-0000-0000-0000-000000000001
> PLUTO\_PROJECT\_TOML\_CONTENTS = """
> \[deps\]
> AbstractPlutoDingetjes = "6e696c72-6542-2067-7265-42206c756150"
> HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
> PlutoPlotly = "8e989ff0-3d88-8e9f-f020-2b208a939ff0"
> 
> \[compat\]
> AbstractPlutoDingetjes = "~1.2.0"
> HypertextLiteral = "~0.9.5"
> PlutoPlotly = "~0.4.3"
> """
> 
> \# ╔═╡ 00000000-0000-0000-0000-000000000002
> PLUTO\_MANIFEST\_TOML\_CONTENTS = """
> \# This file is machine-generated - editing it directly is not advised
> 
> julia\_version = "1.10.0-beta3"
> manifest\_format = "2.0"
> project\_hash = "cc56535668b6e8901cb9ab7a99dbc6e210e21f3b"
> 
> \[\[deps.AbstractPlutoDingetjes\]\]
> deps = \["Pkg"\]
> git-tree-sha1 = "308ee5441d5a481d4ce0152d04f3ef411b05c2b4"
> repo-rev = "Display.with\_js\_link"
> repo-url = "https://github.com/JuliaPluto/AbstractPlutoDingetjes.jl.git"
> uuid = "6e696c72-6542-2067-7265-42206c756150"
> version = "1.2.0"
> 
> \[\[deps.ArgTools\]\]
> uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
> version = "1.1.1"
> 
> \[\[deps.Artifacts\]\]
> uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
> 
> \[\[deps.Base64\]\]
> uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
> 
> \[\[deps.BaseDirs\]\]
> git-tree-sha1 = "1c9b6f39f40dba0ef22244a175e2d4e42c8f6ee7"
> uuid = "18cc8868-cbac-4acf-b575-c8ff214dc66f"
> version = "1.2.0"
> 
> \[\[deps.ColorSchemes\]\]
> deps = \["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "PrecompileTools", "Random"\]
> git-tree-sha1 = "67c1f244b991cad9b0aa4b7540fb758c2488b129"
> uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
> version = "3.24.0"
> 
> \[\[deps.ColorTypes\]\]
> deps = \["FixedPointNumbers", "Random"\]
> git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4"
> uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
> version = "0.11.4"
> 
> \[\[deps.ColorVectorSpace\]\]
> deps = \["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"\]
> git-tree-sha1 = "a1f44953f2382ebb937d60dafbe2deea4bd23249"
> uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
> version = "0.10.0"
> 
> \[deps.ColorVectorSpace.extensions\]
> SpecialFunctionsExt = "SpecialFunctions"
> 
> \[deps.ColorVectorSpace.weakdeps\]
> SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
> 
> \[\[deps.Colors\]\]
> deps = \["ColorTypes", "FixedPointNumbers", "Reexport"\]
> git-tree-sha1 = "fc08e5930ee9a4e03f84bfb5211cb54e7769758a"
> uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
> version = "0.12.10"
> 
> \[\[deps.CompilerSupportLibraries\_jll\]\]
> deps = \["Artifacts", "Libdl"\]
> uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
> version = "1.0.5+1"
> 
> \[\[deps.Dates\]\]
> deps = \["Printf"\]
> uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
> 
> \[\[deps.DelimitedFiles\]\]
> deps = \["Mmap"\]
> git-tree-sha1 = "9e2f36d3c96a820c678f2f1f1782582fcf685bae"
> uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
> version = "1.9.1"
> 
> \[\[deps.DocStringExtensions\]\]
> deps = \["LibGit2"\]
> git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
> uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
> version = "0.9.3"
> 
> \[\[deps.Downloads\]\]
> deps = \["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"\]
> uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
> version = "1.6.0"
> 
> \[\[deps.FileWatching\]\]
> uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
> 
> \[\[deps.FixedPointNumbers\]\]
> deps = \["Statistics"\]
> git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
> uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
> version = "0.8.4"
> 
> \[\[deps.HypertextLiteral\]\]
> deps = \["Tricks"\]
> git-tree-sha1 = "7134810b1afce04bbc1045ca1985fbe81ce17653"
> uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
> version = "0.9.5"
> 
> \[\[deps.InteractiveUtils\]\]
> deps = \["Markdown"\]
> uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
> 
> \[\[deps.JSON\]\]
> deps = \["Dates", "Mmap", "Parsers", "Unicode"\]
> git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
> uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
> version = "0.21.4"
> 
> \[\[deps.LaTeXStrings\]\]
> git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec"
> uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
> version = "1.3.1"
> 
> \[\[deps.LibCURL\]\]
> deps = \["LibCURL\_jll", "MozillaCACerts\_jll"\]
> uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
> version = "0.6.4"
> 
> \[\[deps.LibCURL\_jll\]\]
> deps = \["Artifacts", "LibSSH2\_jll", "Libdl", "MbedTLS\_jll", "Zlib\_jll", "nghttp2\_jll"\]
> uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
> version = "8.0.1+1"
> 
> \[\[deps.LibGit2\]\]
> deps = \["Base64", "LibGit2\_jll", "NetworkOptions", "Printf", "SHA"\]
> uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
> 
> \[\[deps.LibGit2\_jll\]\]
> deps = \["Artifacts", "LibSSH2\_jll", "Libdl", "MbedTLS\_jll"\]
> uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
> version = "1.6.4+0"
> 
> \[\[deps.LibSSH2\_jll\]\]
> deps = \["Artifacts", "Libdl", "MbedTLS\_jll"\]
> uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
> version = "1.11.0+1"
> 
> \[\[deps.Libdl\]\]
> uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
> 
> \[\[deps.LinearAlgebra\]\]
> deps = \["Libdl", "OpenBLAS\_jll", "libblastrampoline\_jll"\]
> uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
> 
> \[\[deps.Logging\]\]
> uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
> 
> \[\[deps.Markdown\]\]
> deps = \["Base64"\]
> uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
> 
> \[\[deps.MbedTLS\_jll\]\]
> deps = \["Artifacts", "Libdl"\]
> uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
> version = "2.28.2+1"
> 
> \[\[deps.Mmap\]\]
> uuid = "a63ad114-7e13-5084-954f-fe012c677804"
> 
> \[\[deps.MozillaCACerts\_jll\]\]
> uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
> version = "2023.1.10"
> 
> \[\[deps.NetworkOptions\]\]
> uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
> version = "1.2.0"
> 
> \[\[deps.OpenBLAS\_jll\]\]
> deps = \["Artifacts", "CompilerSupportLibraries\_jll", "Libdl"\]
> uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
> version = "0.3.23+2"
> 
> \[\[deps.OrderedCollections\]\]
> git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3"
> uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
> version = "1.6.2"
> 
> \[\[deps.Parameters\]\]
> deps = \["OrderedCollections", "UnPack"\]
> git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe"
> uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
> version = "0.12.3"
> 
> \[\[deps.Parsers\]\]
> deps = \["Dates", "PrecompileTools", "UUIDs"\]
> git-tree-sha1 = "a935806434c9d4c506ba941871b327b96d41f2bf"
> uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
> version = "2.8.0"
> 
> \[\[deps.Pkg\]\]
> deps = \["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip\_jll"\]
> uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
> version = "1.10.0"
> 
> \[\[deps.PlotlyBase\]\]
> deps = \["ColorSchemes", "Dates", "DelimitedFiles", "DocStringExtensions", "JSON", "LaTeXStrings", "Logging", "Parameters", "Pkg", "REPL", "Requires", "Statistics", "UUIDs"\]
> git-tree-sha1 = "56baf69781fc5e61607c3e46227ab17f7040ffa2"
> uuid = "a03496cd-edff-5a9b-9e67-9cda94a718b5"
> version = "0.8.19"
> 
> \[\[deps.PlutoPlotly\]\]
> deps = \["AbstractPlutoDingetjes", "BaseDirs", "Colors", "Dates", "Downloads", "HypertextLiteral", "InteractiveUtils", "LaTeXStrings", "Markdown", "Pkg", "PlotlyBase", "Reexport", "TOML"\]
> git-tree-sha1 = "0b8880a45f96d8404ae1cf6e4d715e3a79369441"
> uuid = "8e989ff0-3d88-8e9f-f020-2b208a939ff0"
> version = "0.4.3"
> 
> \[deps.PlutoPlotly.extensions\]
> PlotlyKaleidoExt = "PlotlyKaleido"
> UnitfulExt = "Unitful"
> 
> \[deps.PlutoPlotly.weakdeps\]
> PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c"
> Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
> 
> \[\[deps.PrecompileTools\]\]
> deps = \["Preferences"\]
> git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f"
> uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
> version = "1.2.0"
> 
> \[\[deps.Preferences\]\]
> deps = \["TOML"\]
> git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e"
> uuid = "21216c6a-2e73-6563-6e65-726566657250"
> version = "1.4.1"
> 
> \[\[deps.Printf\]\]
> deps = \["Unicode"\]
> uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
> 
> \[\[deps.REPL\]\]
> deps = \["InteractiveUtils", "Markdown", "Sockets", "Unicode"\]
> uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
> 
> \[\[deps.Random\]\]
> deps = \["SHA"\]
> uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
> 
> \[\[deps.Reexport\]\]
> git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
> uuid = "189a3867-3050-52da-a836-e630ba90ab69"
> version = "1.2.2"
> 
> \[\[deps.Requires\]\]
> deps = \["UUIDs"\]
> git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
> uuid = "ae029012-a4dd-5104-9daa-d747884805df"
> version = "1.3.0"
> 
> \[\[deps.SHA\]\]
> uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
> version = "0.7.0"
> 
> \[\[deps.Serialization\]\]
> uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
> 
> \[\[deps.Sockets\]\]
> uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
> 
> \[\[deps.SparseArrays\]\]
> deps = \["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse\_jll"\]
> uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
> version = "1.10.0"
> 
> \[\[deps.Statistics\]\]
> deps = \["LinearAlgebra", "SparseArrays"\]
> uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
> version = "1.10.0"
> 
> \[\[deps.SuiteSparse\_jll\]\]
> deps = \["Artifacts", "Libdl", "Pkg", "libblastrampoline\_jll"\]
> uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
> version = "7.2.0+1"
> 
> \[\[deps.TOML\]\]
> deps = \["Dates"\]
> uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
> version = "1.0.3"
> 
> \[\[deps.Tar\]\]
> deps = \["ArgTools", "SHA"\]
> uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
> version = "1.10.0"
> 
> \[\[deps.TensorCore\]\]
> deps = \["LinearAlgebra"\]
> git-tree-sha1 = "1feb45f88d133a655e001435632f019a9a1bcdb6"
> uuid = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50"
> version = "0.1.1"
> 
> \[\[deps.Tricks\]\]
> git-tree-sha1 = "eae1bb484cd63b36999ee58be2de6c178105112f"
> uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
> version = "0.1.8"
> 
> \[\[deps.UUIDs\]\]
> deps = \["Random", "SHA"\]
> uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
> 
> \[\[deps.UnPack\]\]
> git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b"
> uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
> version = "1.0.2"
> 
> \[\[deps.Unicode\]\]
> uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
> 
> \[\[deps.Zlib\_jll\]\]
> deps = \["Libdl"\]
> uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
> version = "1.2.13+1"
> 
> \[\[deps.libblastrampoline\_jll\]\]
> deps = \["Artifacts", "Libdl"\]
> uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
> version = "5.8.0+1"
> 
> \[\[deps.nghttp2\_jll\]\]
> deps = \["Artifacts", "Libdl"\]
> uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
> version = "1.52.0+1"
> 
> \[\[deps.p7zip\_jll\]\]
> deps = \["Artifacts", "Libdl"\]
> uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
> version = "17.4.0+2"
> """
> 
> \# ╔═╡ Cell order:
> \# ╠═d6a4d6f0-8920-11ee-1360-dbb4ff626eb6
> \# ╠═b4655ee1-dfe3-47a4-8b19-48c9fb2b6349
> \# ╠═059bbb92-5a68-46d7-a210-69fc1ce91aff
> \# ╟─00000000-0000-0000-0000-000000000001
> \# ╟─00000000-0000-0000-0000-000000000002
> \`\`\`
> 
> \</details\>

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 14, 2024, 2:01pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/9 "2024-05-14T14:01:17Z")

</div>

Perhaps you could use Makie to graphically define an arbitrary polygon, then use this array of points and PolygonOps.jl function `inpolygon` to determine which points are inside it.

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [May 14, 2024, 2:07pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/10 "2024-05-14T14:07:06Z")

</div>

Thank you for your input @jd-foster!

It seems that what does the job in this example is the `add_plotly_listener!()` function. I assume there could be a chance of using something similar to obtain data from Plotly’s “lasso select”??

The syntax for the aforementioned function looks a bit arcane to me. Is it exclusively a Pluto thing, or could it also be implemented on vscode/repl?

Selecting some data from a plot shouldn’t be **that hard** , but it seems that there’s no obvious solution out there (using only Julia).

@rafael.guerra, I was actually looking for something like “inpolygon” as I had the same strategy in mind, thanks a lot for pointing it out!

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [May 15, 2024, 1:48pm UTC](https://discourse.julialang.org/t/is-it-possible-to-access-point-coordinates-from-plots-using-the-box-and-lasso-select-from-plotly-js/68776/11 "2024-05-15T13:48:00Z")

</div>

For anyone interested, here’s a rough example of something that does the job in Makie.

> **Click here for code**
>
> ```julia
> using PolygonOps
> using GLMakie
> 
> # Make a 2D gaussian distribution
> μ = [0.0, 0.0] # Mean
> Σ = [0.5 0.0; 0.0 0.2] # Covariance matrix
> x = range(-3, stop=3, length=100)
> y = range(-3, stop=3, length=100)
> z = [exp(-0.5 * ([i, j] .- μ)' * inv(Σ) * ([i, j] .- μ)) for i in x, j in y]
> 
> #Create a matrix for all the discrete points in the space
> points = [[i, j] for i in x, j in y]
> mask = Observable(zeros(size(points)))
> 
> # Number of selected points
> nsp = @lift(sum($mask))
> 
> GLMakie.activate!(float=true) # Keep plot window on top
> f = Figure()
> ax = Axis(f[1, 1], aspect=1)
> Makie.deactivate_interaction!(ax, :rectanglezoom) # Disable zoom
> 
> # Plot the gaussian as points
> a = scatter!(ax, Tuple.(vec(points)), color=vec(z), marker=:rect, colormap=:tempo, alpha=0.5)
> 
> # Initialise Selection vector
> selection = Observable(Point{2,Float32}[])
> polygon = Observable(Point{2,Float32}[])
> 
> # Plot the points in the selection vector
> sc = scatter!(ax, selection)
> li = lines!(ax, polygon)
> 
> # Pick points by clicking the plot
> spoint = select_point(ax.scene, marker=:circle)
> 
> # Update selection Observable by pushing the selected point to it
> on(spoint) do _
> push!(selection[], spoint[])
> selection[] = selection[] # Update explicitly so that the plots are updated automatically
>     
> if size(selection[], 1) > 2
> polygon[] = vcat(selection[], [selection[][1]])
> mask[] = [inpolygon(p, polygon[]; in=1, on=1, out=0) for p in points]
> display("You have selected $(nsp[]) points")
> end
> 
> end
> 
> # Reset Selection button
> resetb = Button(f[2, 1][1, 1]; label="Reset Selection", tellwidth=false)
> 
> on(resetb.clicks) do _
> # delete!(ax, lp)
> selection[] = Point{2,Float32}[]
> polygon[] = Point{2,Float32}[]
> end
> 
> f
> 
> ```

In this case, “mask” is a matrix with 1’s in the selected region and 0’s outside of it.

First time using Makie, so I’m sure there will be some other flaws as well, please do point them out.

Edit: Tweaked it a little bit to remove some errors.
