I have a simple function that I want to plot. I am using Mathematica 8 on a windows machine.

I type the following code:


And the resulting graph only goes to 25 on the y not 100 like it should. Should I be telling Mathematica to do so?

  • 3
    $\begingroup$ have you looked at PlotRange in the documentation? $\endgroup$ – rm -rf Jul 17 '12 at 2:16
  • $\begingroup$ I have not, I will do so. Thank you! $\endgroup$ – MCP_infiltrator Jul 17 '12 at 2:50

First the reason: Mathematica has to try to display the interesting part of the function for you. Since the function is on a long range very small, it assumes you maybe want a smaller range. Such an approach works most of the times very well but not always.

You have the chance to adjust the range of the plotting by using the PlotRange option:

Plot[100*0.5^n, {n, 0, 20}, PlotRange -> All]
| improve this answer | |
  • $\begingroup$ Thank you much, I had an inkling that Mathematica was trying to show me what it thought I wanted, y I no let program tell me what's best? $\endgroup$ – MCP_infiltrator Jul 17 '12 at 2:53

Like halirutan says you can use PlotRange -> All to see the full graph over the given input range. Note that yo can also use PlotRange to select part of the output range:

Plot[100*0.5^n, {n, 0, 20}, PlotRange -> {0, 10}]

If you use PlotRange with two ranges the first one is the range on your x-axis, and overrides the range you chose for the Plot:

Plot[100*0.5^n, {n, 0, 20}, PlotRange -> {{5, 10}, {0, 10}}]
| improve this answer | |
  • $\begingroup$ That makes for an interesting use of PlotRange now I know specifically how to zoom in on parts of the Range that I might desire. $\endgroup$ – MCP_infiltrator Jul 17 '12 at 13:50
  • $\begingroup$ @MCP_infiltrator - yes, that was the point of my answer. Enjoy :-) $\endgroup$ – stevenvh Jul 17 '12 at 13:58

Another possibility is to plot the Log of your function; this will show the interesting feature :

LogPlot[100*0.5^n, {n, 0, 20}]


| improve this answer | |
  • $\begingroup$ This does indeed show an interesting feature, I did not even think to plot the log of it. $\endgroup$ – MCP_infiltrator Jul 17 '12 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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