Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.4K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How could I plot lines for the x axis as well?

Posted 2 years ago

Hello,

f[x_] := x^2
Plot[{f[x], f[1], f[2]}, {x, 0, 3}, PlotRange -> {{0, 5}}, 
 PlotLegends -> "Expressions"]

enter image description here

How could I plot lines on the x-axis at the points x=1 and x=2 (the points of the function f[1] and f[2])?

Something like that:

enter image description here

or

enter image description here

or

enter image description here

or

enter image description here

or

enter image description here

Thank you.

POSTED BY: Cornel B.
2 Replies
Posted 2 years ago
POSTED BY: Cornel B.

One possibility is to use the option GridLines:

Plot[{f[x], f[1], f[2]}, {x, 0, 3}, PlotRange -> {{0, 5}}, 
 PlotLegends -> "Expressions", GridLines -> {{1, 2}, None}]

or simply:

Plot[f[x], {x, 0, 3}, PlotRange -> {{0, 5}}, GridLines -> Transpose[{#, f[#]} & /@ {1, 2}]]
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard