Message Boards Message Boards

Get 2D plot using Show and Point to "stay still"

Posted 4 years ago

I'd just like to figure out how to have a fixed set of axes, but they keep getting adjusted. Tried all the options I could think of.

enter image description here

Still feel that Mathematica could do a lot better allowing standard matrix and vector notation throughout, not demanding lists in many plotting situations. At least for those interested in the usual linear algebra applications, it's pretty off-putting.

Attachments:
11 Replies

A variation:

Manipulate[
 Graphics[{PointSize[Large], Red, Point[AngleVector[\[Theta]]]},
  PlotRange -> 1.1, Axes -> True, Frame -> True],
 {\[Theta], 0, 2 Pi, Animator}]
POSTED BY: Gianluca Gorni

Thanks, that's definitely a concise way to do this. I just could also use a more flexible set-up that would allow me to have large plots, maybe even spread over multiple files, all controlled by sliders which set global variables. It's a lot of work to provide a lot of new controls to customize layout options. Hoping that Mathematica will be able to do this. I keep re-reading everything I can find on using Dynamic, and I've got to say, a lot of it looks like a quirky and unpredictable add-on, when what was probably needed was a bottom-up rewrite of Mathematica. Not that I don't love Mathematica! Just wish that the learning curve was less of a cliff!

Posted 4 years ago

I am not sure that the following is really what you are looking for. But anyway.

Two notebooks in the same kernel session:

  • One global variable, defined in notebook A
  • One dynamic slider, also in notebookA
  • Plots in two notebooks, A and B

Both plots will respond to slider movement

A

plotLimit = 0.5;
Dynamic@Plot[Sin[x], {x, 0, plotLimit}, PlotRange -> {{0, 2 \[Pi]}, {-1.1, 1.1}}]
Slider[Dynamic[plotLimit], {0.1, 2 \[Pi]}]

B

Dynamic@Plot[Cos[x], {x, 0, plotLimit}, PlotRange -> {{0, 2 \[Pi]}, {-1.1, 1.1}}]
POSTED BY: Hans Milton

Yes, thanks very much, this is what I want. It's great when it works out, but as soon as start doing something more complicated, the dynamic operations seem to get much more undpredictable, and also where to put the Dynamic[ ] commands. But this is a big help.

Is it simply this you want?

Manipulate[
 Graphics[{Blue, Line[{{0, 0}, {Cos[\[Theta]], Sin[\[Theta]]}}], Red, 
   PointSize[Large], Point[{Cos[\[Theta]], Sin[\[Theta]]}]}, 
  Axes -> True, Frame -> True, 
  PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}], {\[Theta], 0, 2 Pi}]
POSTED BY: Henrik Schachner

Thanks, but in this case I'd prefer not to use Manipulate. I want to have the flexibility to move procedures around and have many separate routines that I try out. Why the heck can't Mathematica manage to do what the $90 Graphing Calculator program from Pacific Tech does effortlessly?

Thanks. It's good to know that this will work, but I was hoping that Mathematica would allow me to control global variables via sliders without the need to package my routines in a Manipulate or similar function. It really would make for a lot more flexibility.

..., but I was hoping that Mathematica would allow me to control global variables via sliders without the need to package my routines in a Manipulate ...

But Mathematica does allow that:

\[DoubleStruckCapitalR][\[CurlyTheta]_] := ( {{Cos[\[CurlyTheta]], -Sin[\[CurlyTheta]]}, {Sin[\[CurlyTheta]], Cos[\[CurlyTheta]]} } );
p1 = Flatten[\[DoubleStruckCapitalR][Dynamic[\[CurlyTheta]] \[Degree]].( {{1}, {0}} )];
Show[
 Graphics[{PointSize[Large], Red, Point[p1]}],
 PlotRange -> {{-1, 1}, {-1, 1}},
 Axes -> True,
 Frame -> True
 ]
Slider[Dynamic @ \[CurlyTheta], {0, 360, 15}]
POSTED BY: Henrik Schachner

Thanks very much, that works. I though I had tried specifying the plot range for both axes that way, but maybe not.

I got the plot to stay still by adding a ParametricPlot of the circle to it. But isn't there a way to have the coordinate axes stop resizing even if I'm just plotting a moving point?

enter image description here

Attachments:

One more related question: Why can't I get a line segment to my moving point using ParametricPlot the way I'm doing here?

enter image description here

Attachments:
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