How to draw line 'y=x' using PolarPlot in mathematica?

夙愿已清 提交于 2020-01-05 07:44:29

问题


Because PolarPlot should type r=... type of command.

But y=x will cause r to disappear.

How to draw that line with PolarPlot?


回答1:


I suggest you use a new function for things like this.

PolarParametricPlot[
  {rT : {_, _} ..} | rT : {_, _},
  uv : {_, _, _} ..,
  opts : OptionsPattern[]
] := 
  ParametricPlot[
    Evaluate[# {Cos@#2, Sin@#2} & @@@ {rT}],
    uv, 
    opts
  ]

Usage:

PolarParametricPlot[{t, 45 Degree}, {t, -10, 10}]




回答2:


First, consider Plot[] which "generates a plot of f as a function of x from xmin to xmax" (I'm quoting the Mathematica documentation). You can't use it to plot a vertical line satisfying the equation x = x0, because the latter is not a function of x: instead of being single-valued, it has infinitely many values at x0.

Similarly, PolarPlot[] cannot be used to draw a straight line that passes through the origin, because its equation is not a function of θ: it has infinitely many values at a particular θ (equal to Pi/4 in the case requested), but none at all elsewhere. (Well, one could also allow the complementary angle 3Pi/4 as well.)

So I maintain it can't be done using the tools specified, short of the cheat

PolarPlot[0, {\[Theta], 0, 1}, 
   Epilog -> Line[{Scaled[{1, 1}], Scaled[{0, 0}]}]]



回答3:


Here is the general polar form for a line of the form y = m x + b:

In[155]:= r /. 
 Solve[Eliminate[{x == r Cos[t], y == r Sin[t], y == m x + b}, {x, 
    y}], r]

Out[155]= {-(b/(m Cos[t] - Sin[t]))}

The solution vanishes when the y-intercept b is zero. This makes sense, since such lines are drawn at a constant angle, which is problematic since PolarPlot works by varying the angle.

You could approximate such a line by using a very small value for b, but there are probably better approaches.




回答4:


You could draw the line using ListPolatPlot:

ListPolarPlot[{{Pi/4, 5}, {5 Pi/4, 5}}, Joined -> True]


来源:https://stackoverflow.com/questions/8514937/how-to-draw-line-y-x-using-polarplot-in-mathematica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!