Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica:how to plot a maximum point in a graph

  1. Mar 29, 2012 #1
    anyone can help me to plot a point.

    Code (Text):
     r = Plot[Sin[j], {j, 0, Pi}];
    what i am doing is i use FindMaximum first to know the point of maximum.
    Code (Text):
    FindMaximum[Sin[j], {j, Pi}]
    then i manually key in the x,y coordinate from the search.

    Code (Text):
    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
     
  2. jcsd
  3. Mar 29, 2012 #2

    chiro

    User Avatar
    Science Advisor

    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.
     
  4. Mar 29, 2012 #3
    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]
     
  5. Mar 30, 2012 #4
    thanx 4 ur reply.1 more question. if i dont want to put value 1 by myself and i want the same as finding the j-value(using findmaximum).
    Code (Text):

    onedot = ListPlot[{j, k} /. Rest[FindMaximum[Sin[j], {j, Pi}]],  PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
    is this possible to do?
    thanks again.
     
  6. Mar 30, 2012 #5
    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]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica:how to plot a maximum point in a graph
Loading...