Message Boards Message Boards

1
|
5304 Views
|
6 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Picking off the coordinates from a point in Graphics?

Posted 8 years ago

Why is it that when I try to copy off the coordinates from a point in Graphics it gives me the result as Strings instead of numbers?

I use the following procedure:

1) With the pointer in an existing 2D Graphics I use right-click and Get Coordinates. This gives me the crosshairs.

2) I move the pointer to the point from which I want the coordinates and click once, which makes a point on the graphic.

3) I use Ctrl+C to copy the coordinates, which I usually want to paste into a Text statement.

And when pasted the result is this:

{{"-7.212","1.673"}}

which is not very useful without further processing, such as:

ToExpression /@ First[{{"-7.212", "1.673"}}]

Am I missing something here? And also, if one only clicks a single point why isn't GetCoordinates smart enough to return the result in only a single set of braces? That is what one would usually want to paste into commands.

6 Replies

Thanks all for the responses. At least I know now that this is another good feature gone bad.

In doing custom graphics and dynamics I like to work with an explicit written specification, which I edit and reevaluate as I develop the presentation. With the graphics part I try to deal directly with the graphics primitives. I almost always use a DynamicModule rather than Manipulate. I find this much easier and more flexible than using features such as Drawing Tools. (But to each his own.) GetCoordinates is the one feature that is useful for positioning Text annotations within a graphic.

As for returning the coordinates of a single point, I recognize Sander's comparison with the output of the various Solve routines. But with a copy and paste operation I think the context is different and I really think it would be nice not to have to edit the paste.

The following palette contains a button that will, if you're fortunate enought to get a pasted result, fix it to give the proper expression for a single coordinate.

CreatePalette[
  Button["FixCoordinatePaste",
   Module[{nb, work, newExpression},
    nb = InputNotebook[];
    work = ToExpression[NotebookRead[nb]];
    newExpression = ToExpression /@ Flatten[work];
    NotebookWrite[nb, ToBoxes@newExpression];
    ]
   ],
  WindowTitle -> "Paste Edit", 
  WindowMargins -> {{Automatic, Automatic}, {Automatic, Automatic}},
  Saveable -> False];

That promises to be useful. But something I always forget how to do:

Once I evaluate the CreatePalette command, how do I save the palette (so I don't have to recreate it each time I need it)? If I use the menu item Palettes > Install Palette, in the resulting pop-up window there seems to be no option for the Source field to select that currently-open palette.

POSTED BY: Murray Eisenberg

Lucky you - you at least get anything! In my case (10.4.1 for Linux x86 (64-bit) (April 11, 2016)) this nice feature stopped working completely after v10.1 (as far as I can tell).

POSTED BY: Henrik Schachner

I must admit, I rarely use it. But sometimes can be handy indeed. Maybe you can make something with a Manipulate and Locator?

POSTED BY: Sander Huisman

Why it is a bunch of string? no idea, seems to be an error. Why it returns a list of lists is quite logical. The reason is that you will always get a list of lists of numbers, so whatever you do after with it, you don't have to make constructs like this all the time:

If[Depth[list]==2, ......... , If[Depth[list]==3, ....] ]

It is the same for Solve: it will always give back a list of lists. Such that you don't have to check for the Depth all the time so that everything works coherently together...

POSTED BY: Sander Huisman

You might check out the little video clip under "get coordinates" in the Wolfram Language Search.

POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract