Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 784715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:45:27+00:00 2026-05-14T20:45:27+00:00

I have been trying to put together something that allows me to extract points

  • 0

I have been trying to put together something that allows me to extract points from a ListPlot in order to use them in further computations. My current approach is to select points with a Locator[]. This works fine for displaying points, but I cannot figure out how to extract numerical values from a construct with head Dynamic[]. Below is a self-contained example. By dragging the gray locator, you should be able to select points (indicated by the pink locator and stored in q, a list of two elements). This is the second line below the plot. Now I would like to pass q[[2]] to a function, or perhaps simply display it. However, Mathematica treats q as a single entity with head Dynamic, and thus taking the second part is impossible (hence the error message). Can anyone shed light on how to convert q into a regular list?

EuclideanDistanceMod[p1_List, p2_List, fac_: {1, 1}] /; 
   Length[p1] == Length[p2] := 
  Plus @@ (fac.MapThread[Abs[#1 - #2]^2 &, {p1, p2}]) // Sqrt;
test1 = {{1.`, 6.340196001221532`}, {1.`, 
    13.78779876355869`}, {1.045`, 6.2634018978377295`}, {1.045`, 
    13.754947081416544`}, {1.09`, 6.178367702583522`}, {1.09`, 
    13.72055251752498`}, {1.135`, 1.8183153704413153`}, {1.135`, 
    6.082497198000075`}, {1.135`, 13.684582525399742`}, {1.18`, 
    1.6809452373465104`}, {1.18`, 5.971583107298081`}, {1.18`, 
    13.646996905469383`}, {1.225`, 1.9480537697339537`}, {1.225`, 
    5.838386922625636`}, {1.225`, 13.607746407088161`}, {1.27`, 
    2.1183174369679234`}, {1.27`, 5.669799095595362`}, {1.27`, 
    13.566771130126131`}, {1.315`, 2.2572975468163463`}, {1.315`, 
    5.444014254828522`}, {1.315`, 13.523998701347882`}, {1.36`, 
    2.380307009155079`}, {1.36`, 5.153024664297602`}, {1.36`, 
    13.479342200528283`}, {1.405`, 2.4941312539733285`}, {1.405`, 
    4.861423833512566`}, {1.405`, 13.432697814928654`}, {1.45`, 
    2.6028066447609426`}, {1.45`, 4.619367407525507`}, {1.45`, 
    13.383942212133244`}};
DynamicModule[{p = {1.2, 10}, q = {1.3, 11}},
 q := Dynamic@
   First@test1[[
     Ordering[{#, EuclideanDistanceMod[p, #, {1, .1}]} & /@ test1, 
      1, #1[[2]] < #2[[2]] &]]];
 Grid[{{Show[{ListPlot[test1, Frame -> True, ImageSize -> 300], 
      Graphics@Locator[Dynamic[p]], 
      Graphics@
       Locator[q, Appearance -> {Small}, 
        Background -> Pink]}]}, {Dynamic@p}, {q},{q[[2]]}}]]
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:45:28+00:00Added an answer on May 14, 2026 at 8:45 pm

    After a little more research, it appears that the answer revolves around the fact that Dynamic[] is a wrapper for updating and displaying the expression. Any computations that you want dynamically updated must be placed inside the wrapper: for instance, instead of doing something like q = Dynamic[p] + 1 one should use something like Dynamic[q = p + 1; q]}]. For my example, where I wanted to split q into two parts, here’s the updated code:

    DynamicModule[{p = {1.2, 10}, q = {1.3, 11}, qq, q1, q2}, 
     q := Dynamic[
       qq = First@
         test1[[Ordering[{#, EuclideanDistanceMod[p, #, {1, .1}]} & /@ 
             test1, 1, #1[[2]] < #2[[2]] &]]];
       {q1, q2} = qq;
       qq
       ];
     Grid[{{Show[{ListPlot[test1, Frame -> True, ImageSize -> 300], 
          Graphics@Locator[Dynamic[p]], 
          Graphics@
           Locator[q, Appearance -> {Small}, 
            Background -> Pink]}]}, {Dynamic@p}, {Dynamic@q}, {Dynamic@
         q1}}]]
    

    If I am still missing something, or if there’s a cleaner way to do this, I welcome any suggestions…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with the example code from the ExecutorCompletionService and put together
I've been trying to put together a gui in MATLAB and have had great
Have been trying to encrypt an xml file to a string so that I
I have been trying to serialize a list that contains arrays and lists. I
I am trying to understand the Python ctypes module. I have put together a
I am trying to learn or put together the bits and pieces that I
i'm trying to put together some Javascript form validation to check that all fields
I have been working on a contact form that allows multiple file attachments using
I'm just trying to put together a webpage for a client, and I have
Ok, so i have been trying to put everyone one of my classes in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.