Adjusting gridlines and ticks in matplotlib imshow

Code for solution as suggested by Serenity: plt.figure() im = plt.imshow(np.reshape(np.random.rand(100), newshape=(10,10)), interpolation=’none’, vmin=0, vmax=1, aspect=”equal”) ax = plt.gca(); # Major ticks ax.set_xticks(np.arange(0, 10, 1)) ax.set_yticks(np.arange(0, 10, 1)) # Labels for major ticks ax.set_xticklabels(np.arange(1, 11, 1)) ax.set_yticklabels(np.arange(1, 11, 1)) # Minor ticks ax.set_xticks(np.arange(-.5, 10, 1), minor=True) ax.set_yticks(np.arange(-.5, 10, 1), minor=True) # Gridlines based on minor … Read more

Imshow: extent and aspect

You can do it by setting the aspect of the image manually (or by letting it auto-scale to fill up the extent of the figure). By default, imshow sets the aspect of the plot to 1, as this is often what people want for image data. In your case, you can do something like: import … Read more

Removing white space around a saved image

You can remove the white space padding by setting bbox_inches=”tight” in savefig: plt.savefig(“test.png”,bbox_inches=”tight”) You’ll have to put the argument to bbox_inches as a string, perhaps this is why it didn’t work earlier for you. Possible duplicates: Matplotlib plots: removing axis, legends and white spaces How to set the margins for a matplotlib figure? Reduce left … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)