custom axis range

Hello,

I have a question regarding setting a custom axis range. Here's a basic
example:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([1,2,3])
ax.axis([xmin,xmax,ymin,ymax])
plt.show()

Now the question that I'm having is the following. The way I understand it
now, I either have to live with the default axis ranges which matplotlib
gives me, or I need to change all four values xmin, xmax, ymin, ymax using
the ax.axis command. Say that I'm happy with xmin, ymin and ymax, and I only
want to set xmax to a value slightly larger than the default. Is there a way
to specify just that and to be able to keep the other three? The command
which I'm looking for would be something like:

ax.axis([keep default, xmax, keep default, keep default])

If someone has a suggestion, I would be very grateful.

Thanks in advance!

···

--
View this message in context: http://old.nabble.com/custom-axis-range-tp32655869p32655869.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Use ax.set_xlim() and it’s y-axis equivalent. You can even use kwargs to those functions to manually set only one of the two limits.

Ben Root

···

On Friday, October 14, 2011, jopeto <g_nikiforov@…32…> wrote:

Hello,

I have a question regarding setting a custom axis range. Here’s a basic

example:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([1,2,3])
ax.axis([xmin,xmax,ymin,ymax])
plt.show()

Now the question that I’m having is the following. The way I understand it
now, I either have to live with the default axis ranges which matplotlib
gives me, or I need to change all four values xmin, xmax, ymin, ymax using

the ax.axis command. Say that I’m happy with xmin, ymin and ymax, and I only
want to set xmax to a value slightly larger than the default. Is there a way
to specify just that and to be able to keep the other three? The command

which I’m looking for would be something like:

ax.axis([keep default, xmax, keep default, keep default])

If someone has a suggestion, I would be very grateful.