定位器超出图形区域
当我运行以下代码
pMin = {-3, -3};
pMax = {3, 3};
range = {pMin, pMax};
Manipulate[
GraphicsGrid[
{
{Graphics[Locator[p], PlotRange -> range]},
{Graphics[Line[{{0, 0}, p}]]}
}, Frame -> All
],
{{p, {1, 1}}, Locator}
]
我希望定位器控件位于第一个图形的范围内,但相反可以在整个 GraphicsGrid 区域中移动。我的代码有错误吗?
我也尝试
{{p, {1, 1}}, pMin, pMax, Locator}
过
{{p, {1, 1}}, Locator}
但它的行为完全错误。
更新
感谢大家,这是我的最终解决方案:
Manipulate[
distr1 = BinormalDistribution[p1, {1, 1}, \[Rho]1];
distr2 = BinormalDistribution[p2, {1, 1}, \[Rho]2];
Grid[
{
{Graphics[{Locator[p1], Locator[p2]},
PlotRange -> {{-5, 5}, {-5, 5}}]},
{Plot3D[{PDF[distr1, {x, y}], PDF[distr2, {x, y}]}, {x, -5, 5}, {y, -5, 5}, PlotRange -> All]}
}],
{{\[Rho]1, 0}, -0.9, 0.9}, {{\[Rho]2, 0}, -0.9, 0.9},
{{p1, {1, 1}}, Locator},
{{p2, {1, 1}}, Locator}
]
更新
现在的问题是我无法调整和旋转下部 3d 图形的 。有谁知道如何解决这个问题? 我回到了带有两个 Slider2D 对象的解决方案。
When I run the following code
pMin = {-3, -3};
pMax = {3, 3};
range = {pMin, pMax};
Manipulate[
GraphicsGrid[
{
{Graphics[Locator[p], PlotRange -> range]},
{Graphics[Line[{{0, 0}, p}]]}
}, Frame -> All
],
{{p, {1, 1}}, Locator}
]
I expect the Locator control to be within the bounds of the first Graph, but instead it can be moved around the whole GraphicsGrid region. Is there an error in my code?
I also tried
{{p, {1, 1}}, pMin, pMax, Locator}
instead of
{{p, {1, 1}}, Locator}
But it behaves completely wrong.
UPDATE
Thanks to everyone, this is my final solution:
Manipulate[
distr1 = BinormalDistribution[p1, {1, 1}, \[Rho]1];
distr2 = BinormalDistribution[p2, {1, 1}, \[Rho]2];
Grid[
{
{Graphics[{Locator[p1], Locator[p2]},
PlotRange -> {{-5, 5}, {-5, 5}}]},
{Plot3D[{PDF[distr1, {x, y}], PDF[distr2, {x, y}]}, {x, -5, 5}, {y, -5, 5}, PlotRange -> All]}
}],
{{\[Rho]1, 0}, -0.9, 0.9}, {{\[Rho]2, 0}, -0.9, 0.9},
{{p1, {1, 1}}, Locator},
{{p2, {1, 1}}, Locator}
]
UPDATE
Now the problem is that I cannot resize and rotate the lower 3d graph. Does anyone know how to fix that?
I'm back to the solution with two Slider2D objects.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您检查 InputForm,您会发现 GraphicsGrid 返回一个 Graphics 对象。因此,定位器确实在整个图像中移动。
如果您只是将 GraphicsGrid 更改为 Grid,定位器将被限制在第一部分,但结果看起来仍然有点奇怪。你的 PlotRange 规范有点奇怪;它似乎不符合文档中心指定的任何格式。也许你想要类似下面的东西。
If you examine the InputForm you'll find that GraphicsGrid returns a Graphics object. Thus, the Locator indeed moves throughout the whole image.
If you just change the GraphicsGrid to a Grid, the locator will be restricted to the first part but the result still looks a bit odd. Your PlotRange specification is a bit strange; it doesn't seem to correspond to any format specified in the Documentation center. Perhaps you want something like the following.
LocatorPane[]
在将定位器限制在某个区域方面做得很好。这是巫师先生使用的方法的一种变体。
我假设您希望定位器与其控制的线路共享空间。其实就是“附”在一线。事实证明,这更容易实现。
LocatorPane[]
does a nice job of confining the locator to a region.This is a variation on the method used by Mr. Wizard.
I would have assumed that you'd want the locator to share the space with the line it controls. In fact, to be "attached" to the line. This turns out to be even easier to implement.
我不确定你想实现什么目标。我看到了很多问题,但我不知道要解决什么。也许您只想要一个简单的
Slider2D
构造?这是对有关 3D 图形旋转的更新问题的答复。
我相信 David 建议的 LocatorPane 是解决此问题的好方法。我只是输入了一个通用函数,因为您的示例无法在 Mathematica 7 上运行。
I am not sure what you are trying to achieve. There are a number of problems I see, but I don't know what to address. Perhaps you just want a simple
Slider2D
construction?This is a reply to the updated question about 3D graphic rotation.
I believe that LocatorPane as suggested by David is a good way to approach this. I just put in a generic function since your example would not run on Mathematica 7.