0

Is there an easy way in python using pyplot (matplotlib) to create a rectangular grid (like this, but perhaps gridded) like this: enter image description here

I am pretty new to python, and there may be a simple solution to this, but I have been unable to find it.

Thanks in advance.

1 Answer 1

2

It's not clear exactly which details you're going for but here's a start...

enter image description here

import matplotlib.pyplot as plt

ax = plt.subplot(1, 1, 1)
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_xticks(range(-5, 6))
ax.set_yticks(range(-5, 6))
ax.set_xlim((-5.5, 5.5))
ax.set_ylim((-5.5, 5.5))
ax.grid()

plt.show()
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, that's great. I just needed an example to point me in the right direction. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.