获取手动绘制点的坐标
我有一个执行 ListPlot[]
函数的结果图。 我可以通过将点移动到不同的位置来手动编辑此图 并使用绘图工具添加新点。
如何从编辑后的图形中获取新点和更改点的坐标?
I have a graph as a result of executing ListPlot[]
function.
I can manually edit this graph by moving points to a different location
and also adding new points using the Drawing Tools.
How do I get the coordinates of new and changed points from the edited graphics?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定以下是否是您想要的,但是:
如果我使用
ListPlot
如下:通过双击其中一个红点两次将选择范围设置为然后,我可以移动各个点,例如,使这些点位于曲线(而不是直线)上。我现在想要提取这些点(并说在新的
ListPlot
中使用它们)[参见下面的图]如果我单击绘图图形的括号并使用“显示表达式”(命令 Shift E 上Mac),我可以“看到”修改点的坐标,然后可以提取这些坐标。例如:
修改 Yaroslav Bulatov 最初建议的非常有用的方法,可以在 此处
编辑
正如belisarius所指出的,希望能够提取“手动”添加的点(可以使用绘图工具选项板中的“点”将其添加到生成的图中)。更好的提取方法(在“显示表达式”之后...)可能如下:
当然,“显示表达式”不是唯一的方法。
InputForm
是另一种可能性。例如,“ListPlotGraphic”是修改后的图形(通过“复制和粘贴”插入),也将起作用。
示例图
附录
上述内容可以通过一些笔记本编程实现自动化:
运行上述内容,移动最后两个原始内容 (红色)点并使用绘图工具添加几个蓝色的额外点,然后按按钮产生
您可以看到原始数据有一个
PointBox
,每个添加的点都有一个新的PointBox
。当然,通过修改上面的代码,你可以做的不仅仅是简单地打印出原始点坐标。I'm not sure if the following is anything like what you want,but nevertheless:
If I use
ListPlot
as follows:By double clicking on one of the red points twice to get the selection to the level of the points, I can then move the individual points, e.g., to make the points lie on a curve (rather than a straight line). I now want to extract these points (and say use them in a new
ListPlot
) [see plots below]If I click on the bracket of the plot graphic and use "Show Expression" (Command Shift E on a Mac), I can 'see' the coordinates of the modified points which may then be extracted. For example:
Modifying a very useful approach originally suggested by Yaroslav Bulatov, which may be found here
EDIT
As pointed out by belisarius, it is desirable to be able to extract 'manually' added points (which may be added to the generated plot using 'point' from the Drawing Tools palette). A better way of extracting (after 'Show Expression' ...) is probably the following:
Of course, 'Show Expression' is not the only approach.
InputForm
is another possibility. For example,where "ListPlotGraphic" is the modified graphic (inserted by 'copy and paste'), will also work.
Example plots
Addendum
The above can be automated with a little notebook programming:
Running the above, moving the last two original (red) points and adding a couple of extra points in blue with the drawing tools then pressing the button yields
You can see that there is a single
PointBox
for the original data and a newPointBox
for each of the added points. Of course, by modifying the above code, you can do more than simply print out the raw point coordinates.这种方法使每个数据点都成为可以移动的定位器。可以根据需要添加新定位器并删除旧定位器。每次更改后都会更新最佳拟合和方差。
这是一些指数增长的数据,有一些错误,并且缺少一个数据点
一些格式化命令:
最后,这是制作可操作图形的代码。 使用
Alt-Click 添加新定位器/数据点
code>(或 Linux 上的
Ctrl-Alt-Click
)。如果单击左侧的点列表,则会打开一个新窗口,其中包含输入表单中的点。在上面,我使用定位器纠正了几个异常值并恢复了丢失的数据点。
This approach makes every data point a locator that can be moved. New locators can be added and old ones deleted as appropriate. The best fit and variance are updated after every change.
Here's some data of some exponential growth with some errors and a data point missing
A little formatting command:
Finally, here's the code to make the manipulable graphics. New locators/data points are added using
Alt-Click
(orCtrl-Alt-Click
on linux). If you click on the list of points on the left, then a new window is opened containing the points in input form.In the above I've used the locators to correct a couple of outliers and restored the missing data point.
最简单的选择是使用“获取坐标”菜单选项。如果右键单击图形,在弹出菜单中您将看到“获取坐标”,它允许您将鼠标悬停在某个点上并查看该点的坐标。当然,这不会很准确……但是您编辑图形的方式也不是很准确。
您可以使用
InputForm
(或FullForm
)函数,但我不确定它的效果如何......您会注意到有一个
Point 表达式在那里。
我猜第三个选项是以某种方式使用
Locator
。The easy option is to use the "Get Coordinates" menu option. If you right click on the graphic, in the pop-up menu you'll see "Get Coordinates" which allows you to mouse-over a point and see that point's coordinates. Of course this isn't going to be accurate... but the way you're editing the graphic isn't very accurate either.
You could use the
InputForm
(orFullForm
) function, but I am not sure how well this works...You'll notice that there's a
Point
expression in there.The third option would be to use
Locator
in some way I guess.