1
$\begingroup$

How can I plot the vertical asymptote x=3 for this function: f(x)=Log2(x-3)

This is what I have tried so far:

Plot[Log[2, (x - 3)], {x, -10, 10}, PlotRange -> {-10, 10}]
$\endgroup$
  • $\begingroup$ I suggest the following: 1) As you receive help, try to give it too, by answering questions. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the check mark sign! $\endgroup$ – ercegovac Oct 13 '17 at 8:39
  • 1
    $\begingroup$ Look up InfiniteLine[]. $\endgroup$ – J. M.'s technical difficulties Oct 13 '17 at 9:24
1
$\begingroup$

ParametricPlot

ParametricPlot[{{x, Log[2, (x - 3)]}, {3, Rescale[x, {-10, 10}, {-5, 3}]}}, {x, -10, 10}, 
 PlotRange -> {{0, 10}, {-5, 3}}]

enter image description here

GridLines

Plot[Log[2, x - 3], {x, -10, 10}, PlotRange -> {{0, 10}, {-5, 3}}, 
 GridLines -> {{{3, Directive[Thick, Red]}}, None}]

enter image description here

If your plot has horizontal GridLines (say, Range[10]), re-style the horizontal grid line at 3 using

 GridLines -> {Range[10] /. 3 -> {3, Directive[Thick, Red]},  Automatic}]

to get

enter image description here

| improve this answer | |
$\endgroup$
1
$\begingroup$

A first thing that comes to mind

Plot[{Log[2, (x - 3)]}, {x, -10, 10}, 
 PlotRange -> {{0, 10}, Automatic}, Epilog -> Line[{{3, -3}, {3, 3}}]]

which gives

enter image description here

Edit

As suggested by @J.M., infinite line is better option because it scales with the plot.

Plot[{Log[2, (x - 3)]}, {x, -10, 10}, 
 PlotRange -> {{0, 10}, Automatic}, 
 Epilog -> InfiniteLine[{{3, -3}, {3, 3}}], GridLines -> Automatic]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thankyou so much but could you please explain what this computation means? PlotRange -> {{0, 10}, Automatic}, Epilog -> Line[{{3, -3}, {3, 3}}]] $\endgroup$ – Sath Oct 13 '17 at 8:23
  • $\begingroup$ Please first read the links in the comment I have left to your original answer. Familiarize yourself with Mathematica help. I know it can be very difficult to find a function that does something, but once someone shows you that it should be very easy to read help, particularly as in this case, Epilog is built-in Option. There are great resources on this site for beginners. You can start with discussion on this thread $\endgroup$ – ercegovac Oct 13 '17 at 8:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.