2

I am trying to get a graph in which the square dots touch each other without overlapping. For that, I need a defined graph size so I can adapt my squares' size.

The problem is that I found a lot of ways to control the figure( graph + axes, labels and title) size, but not the graph size itself.

Just so you know, my graph represents dots in some defined position that colors depends on the corresponding value in the matrix (I wish I could send an example, but I do not have enough reputation it seems...)

Thank you,

1 Answer 1

2

You can control the axes size within the figure using add_axes:

import matplotlib.pyplot as plt

fig = plt.figure()
fig.add_axes([0.1,0.1,0.5,0.5])
plt.show()

Where the argument to add_axes is rect = l,b,w,h and the units are the fraction of the figure size.

However, if you're trying to get squares that touch but don't overlap, you may want to use imshow:

z = [[5,2,7],[8,1,5],[3,4,10]]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.imshow(z,extent=[3,6,6,9],interpolation='none')

plt.show()

squares plotted with imsho

Sign up to request clarification or add additional context in comments.

Comments

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.