Latitude out of chart area

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} ] 

Mathematica graphics

I expect the Locator control to be within the boundaries of the first graph, but instead, it can move across the entire GraphicsGrid. Is there an error in my code?

I also tried

 {{p, {1, 1}}, pMin, pMax, Locator} 

instead

 {{p, {1, 1}}, Locator} 

But this behaves completely wrong.

UPDATE

Thanks to everyone, this is my final decision:

 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} ] 

Mathematica graphics

UPDATE

Now the problem is that I cannot resize and rotate the bottom three-dimensional graph. Does anyone know how to fix this? I will return to the solution with two Slider2D objects.

+6
wolfram-mathematica
source share
3 answers

I'm not sure what you are trying to achieve. There are a number of problems that I see, but I do not know what to turn to. Maybe you just need a simple Slider2D design?

 DynamicModule[{p = {1, 1}}, Column@ {Slider2D[Dynamic[p], {{-3, -3}, {3, 3}}, ImageSize -> {200, 200}], Graphics[Line[{{0, 0}, Dynamic[p]}], PlotRange -> {{-3, 3}, {-3, 3}}, ImageSize -> {200, 200}]}] 

This is the answer to the updated question about 3D graphic rotation.

I believe the LocatorPane proposed by David is a good way to get closer to this. I just added a universal function, since your example will not run on Mathematica 7.

 DynamicModule[{pt = {{-1, 3}, {1, 1}}}, Column[{ LocatorPane[Dynamic[pt], Framed@Graphics [{}, PlotRange -> {{-5, 5}, {-5, 5}}]], Dynamic@ Plot3D[{x^2 pt[[1, 1]] + y^2 pt[[1, 2]], -x^2 pt[[2, 1]] - y^2 pt[[2, 1]]}, {x, -5, 5}, {y, -5, 5}] }] ] 
+5
source share

If you study InputForm, you will find that GraphicsGrid returns a Graphics object. Thus, the locator really moves throughout the image.

 GraphicsGrid[{{Graphics[Circle[]]}, {Graphics[Disk[]]}}] // InputForm 

If you just change GraphicsGrid to Grid, the locator will be limited to the first part, but the result still looks a little strange. The PlotRange specification is a little weird; it does not seem to match the format specified in the documentation center. Maybe you need something like the following.

 Manipulate[ Grid[{ {Graphics[Locator[p], Axes -> True, PlotRange -> {{-3, 3}, {-3, 3}}]}, {Graphics[Line[{{0, 0}, p}], Axes -> True, PlotRange -> {{-3, 3}, {-3, 3}}]}}, Frame -> All], {{p, {1, 1}}, Locator}] 
+7
source share

LocatorPane[] does a good job of limiting the locator to an area.

This is a variation of the method used by Mr. Master.

 Column[{ LocatorPane[Dynamic[pt3], Framed@Graphics [{}, ImageSize -> 150, PlotRange -> 3]], Framed@Graphics [{Line[{{-1, 0}, Dynamic@pt3 }]}, ImageSize -> {150, 150}, PlotRange -> 3]}] 

locator confined

I would suggest that you want the locator to share space with the line it controls. In fact, be β€œattached” to the line. It turned out to be even easier to implement.

 Column[{LocatorPane[Dynamic[pt3], Framed@Graphics [{Line[{{-1, 0}, Dynamic@pt3 }]}, ImageSize -> 150, PlotRange -> 3]]}] 

locator on the line

+6
source share

All Articles