-1
$\begingroup$

If I were to plot ListPlot[{{5, 7}, {-2, 2}}], then mathematica automatically sets the x-axis range which is from -2 to 5 in this case. I want to set this manually, such as from -5 to 5, regardless of the x range of the list (I can do this for y-axis by adding PlotRange->{-5,5}). How do I do this?

$\endgroup$

closed as off-topic by corey979, m_goldberg, Carl Lange, Bob Hanlon, Bill Watts Jan 28 at 5:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – corey979, m_goldberg, Carl Lange, Bob Hanlon, Bill Watts
If this question can be reworded to fit the rules in the help center, please edit the question.

2
$\begingroup$

Welcome to the Mathematica Stack Exchange!

You almost had it yourself - PlotRange is the key here.

ListPlot[{{5, 7}, {-2, 2}}, PlotRange -> {{-5, 5}, Automatic}]

enter image description here

This behaviour is described under the details in the PlotRange documentation, specifically:

enter image description here

We are using the form that is second-from-the-bottom, but setting Automatic for the y axis.

$\endgroup$
  • $\begingroup$ If I use this, it changes the range of y axis. I want to manually set both x and y ranges. $\endgroup$ – user62606 Jan 27 at 11:06
  • $\begingroup$ @user62606 That is unclear from the wording of your question. PlotRange->{{-5,5}, {-5, 5}} will do what you're looking for, and if you look at the documentation for PlotRange as I linked in the answer, there are lots of examples of how to do more with it. $\endgroup$ – Carl Lange Jan 27 at 15:11

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