How to center axes intersecting at (0,0)

Hi,

I'm new to matplotlib. I would like to do something very simple. In the
figure created by the following code, I would like the axes to be centered
in the figure and intersecting at point (0,0):

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,-4,9,-16], 'ro')
plt.axis([-6, 6, -20, 20])
plt.title('Title')
plt.show()

Can you please give me the simplest lines of code to achieve this? (the
hints to solutions that I have seen over the internet are amazingly complex
for such a simple task)

Many thanks

saikari

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/How-to-center-axes-intersecting-at-0-0-tp46427.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

This is actually the subject of Nicolas Rougier's great tutorial here:
http://www.labri.fr/perso/nrougier/teaching/matplotlib/

Mike

···

On Fri, Nov 13, 2015 at 9:01 AM, sh77 via Matplotlib-users < matplotlib-users at python.org> wrote:

Hi,

I'm new to matplotlib. I would like to do something very simple. In the
figure created by the following code, I would like the axes to be centered
in the figure and intersecting at point (0,0):

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,-4,9,-16], 'ro')
plt.axis([-6, 6, -20, 20])
plt.title('Title')
plt.show()

Can you please give me the simplest lines of code to achieve this? (the
hints to solutions that I have seen over the internet are amazingly complex
for such a simple task)

Many thanks

saikari

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/How-to-center-axes-intersecting-at-0-0-tp46427.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151201/97e34252/attachment.html>

Just for completeness for the thread, the proper term for what you want to
modify is "spines". Some documentation is here:
http://matplotlib.org/api/spines_api.html#matplotlib.spines

Cheers!
Ben Root

···

On Tue, Dec 1, 2015 at 8:21 AM, Michael Droettboom <mdroettboom at continuum.io > wrote:

This is actually the subject of Nicolas Rougier's great tutorial here:
http://www.labri.fr/perso/nrougier/teaching/matplotlib/

Mike

On Fri, Nov 13, 2015 at 9:01 AM, sh77 via Matplotlib-users < > matplotlib-users at python.org> wrote:

Hi,

I'm new to matplotlib. I would like to do something very simple. In the
figure created by the following code, I would like the axes to be centered
in the figure and intersecting at point (0,0):

import matplotlib.pyplot as plt
plt.plot([1,2,3,4], [1,-4,9,-16], 'ro')
plt.axis([-6, 6, -20, 20])
plt.title('Title')
plt.show()

Can you please give me the simplest lines of code to achieve this? (the
hints to solutions that I have seen over the internet are amazingly
complex
for such a simple task)

Many thanks

saikari

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/How-to-center-axes-intersecting-at-0-0-tp46427.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151201/f1899c2c/attachment.html>