Mathematica:how to plot a maximum point in a graph

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 7K views
shafieza_garl
Messages
20
Reaction score
0
anyone can help me to plot a point.

Code:
 r = Plot[Sin[j], {j, 0, Pi}];
what i am doing is i use FindMaximum first to know the point of maximum.
Code:
FindMaximum[Sin[j], {j, Pi}]

then i manually key in the x,y coordinate from the search.

Code:
onedot = ListPlot[{{1.5707963267948966, 1}}, 
   PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]

is there any way i can plot the maximum point without key-in manually using the findmaximum point.
thanks
 
on Phys.org
shafieza_garl said:
anyone can help me to plot a point.

Code:
 r = Plot[Sin[j], {j, 0, Pi}];
what i am doing is i use FindMaximum first to know the point of maximum.
Code:
FindMaximum[Sin[j], {j, Pi}]

then i manually key in the x,y coordinate from the search.

Code:
onedot = ListPlot[{{1.5707963267948966, 1}}, 
   PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]

is there any way i can plot the maximum point without key-in manually using the findmaximum point.
thanks

One suggestion I have is to create a test function with {-1,0} {0,maxpoint} and {+1,0) and then plot that data like any other data. If you need to adjust scaling or if Mathematica produces a very narrow graph then make the non-max points larger in the respective directions.

If you need the point at its original position then just add the x coordinate to every x point in the dataset.
 
r = Plot[Sin[j], {j, 0, Pi}];
onedot = ListPlot[{j, 1} /. Rest[FindMaximum[Sin[j], {j, Pi}]], PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]
 
Bill Simpson said:
r = Plot[Sin[j], {j, 0, Pi}];
onedot = ListPlot[{j, 1} /. Rest[FindMaximum[Sin[j], {j, Pi}]], PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]

thanx 4 ur reply.1 more question. if i don't want to put value 1 by myself and i want the same as finding the j-value(using findmaximum).
Code:
onedot = ListPlot[{j, k} /. Rest[FindMaximum[Sin[j], {j, Pi}]],  PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
is this possible to do?
thanks again.
 
r = Plot[Sin[j], {j, 0, Pi}];
onedot = ListPlot[{j, Sin[j]} /. Rest[FindMaximum[Sin[j], {j, Pi}]], \
PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]