Mathematica:how to plot a maximum point in a graph

In summary: If you need the point at its original position then just add the x coordinate to every x point in the dataset.
  • #1
shafieza_garl
20
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
 
Physics news on Phys.org
  • #2
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.
 
  • #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]
 
  • #4
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.
 
  • #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]
 

FAQ: Mathematica:how to plot a maximum point in a graph

1. How do I plot a maximum point in a graph using Mathematica?

To plot a maximum point in a graph using Mathematica, you can use the "Maximize" function. This function takes in an expression and variables, and returns the maximum value of the expression and the corresponding values of the variables. You can then use this information to plot the maximum point on the graph.

2. Can I plot multiple maximum points on a single graph using Mathematica?

Yes, you can plot multiple maximum points on a single graph using Mathematica. You can use the "Maximize" function for each point and then plot all the points on the same graph. Alternatively, you can use the "MaxValue" function to find the maximum value for a specific variable and plot its corresponding point.

3. How can I customize the appearance of the maximum point on the graph?

To customize the appearance of the maximum point on the graph, you can use the "Epilog" option in the plot function. This option allows you to add additional elements to the graph, such as points or lines. You can use the "Point" function to specify the coordinates of the maximum point and customize its appearance using options such as "PointSize" and "PointStyle".

4. Is it possible to find the maximum point of a specific function using Mathematica?

Yes, it is possible to find the maximum point of a specific function using Mathematica. You can use the "Maximize" function as mentioned earlier, or you can use the "FindMaximum" function. This function takes in an expression, variables, and starting values for the variables, and returns the maximum value and corresponding values of the variables.

5. Can I plot the maximum point on a 3D graph using Mathematica?

Yes, you can plot the maximum point on a 3D graph using Mathematica. You can use the "Maximize" function to find the maximum value of a function in three variables, and then plot the point on the 3D graph using the "Graphics3D" function. You can also use the "FindMaximum" function for a specific variable and plot its corresponding point on the 3D graph.

Similar threads

Replies
2
Views
548
Replies
1
Views
637
Replies
1
Views
1K
Replies
1
Views
2K
Replies
1
Views
968
Replies
1
Views
881
Replies
4
Views
451
Back
Top