1

Why the following snippet (using pyplot inside jupyter notebook):

plt.rcParams['figure.figsize'] = [10, 10]
plt.hist2d(np.random.randint(1e10, size=100000), 
           np.random.randint(1e10, size=100000)) 
plt.xlim(-1, 1)
plt.ylim(-1, 1)
plt.show()

gives this error:

ValueError: Image size of -1757369422x-759354895 pixels is too large. It must be less than 2^16 in each direction.

Without setting xlim and ylim runs fine. How to effectively set bounds of what is shown on that kind of plots?

xemlmrx
  • 65
  • 6
  • You generate random numbers between 0 and 10000000000. However you set the limits to -1 and 1. The odds that you would actually see something in that range are hence pretty low - even if the plot got produced correctly. Maybe you want to tell why you would like to create such plot at all, such that one is able to help you more. – ImportanceOfBeingErnest Sep 14 '18 at 16:46
  • Does this answer your question? [Image size of 1005x132589 pixels is too large. It must be less than 2^16 in each direction](https://stackoverflow.com/questions/51980366/image-size-of-1005x132589-pixels-is-too-large-it-must-be-less-than-216-in-each) – jtlz2 Jan 25 '21 at 11:18

1 Answers1

0

Seems it is a bug in matplotlib that has been reported.

U3.1415926
  • 812
  • 12
  • 30