Skip to content Skip to sidebar Skip to footer

Image Size Of 1005x132589 Pixels Is Too Large. It Must Be Less Than 2^16 In Each Direction

I am using matplotlib.pyplot to plot a graph from a Dataframe. I want to show the height of the bar upon each rectangle and am using Text(). For normalising the y-axis, I have tak

Solution 1:

Check your location variables at plt.text line in autolabel definition. I had the same problem and I found that the y variable I gave to plt.text function was too large compared to the value of my dataset of plot.

This is also an issue with plt.annotate if the location is outside the figure.

Solution 2:

Your X axis might be string values and plt.text() only take scalar values to move on the axis. So that's why your range might be beyond the image size. Convert the x-axis to scalar values. I had same problem, I did the same.

Solution 3:

You can adujust pixels and update your update_datalim()

fig = plt.figure(1, figsize=(8, 14), frameon=False, dpi=100)
fig.add_axes([0, 0, 1, 1])
ax = plt.gca()

corners = ((x1, y1), (x2, y2))
ax.update_datalim(corners)

Solution 4:

Another possible explanation could be that one of your y-axis values is zero. Thus you could edit your autolabel function into something like this:

def autolabel(rects):
for rect in rects:
    height = rect.get_height()
    if (height != 0):
        ax.annotate('{}'.format(height),
                    xy=(rect.get_x() + rect.get_width() / 2, height),
                    xytext=(0, 3),  # 3 points vertical offset
                    textcoords="offset points",
                    ha='center', va='bottom')

Solution 5:

This happens because your x-axis contains dates and when you're adding text, you're passing scalar values.

To solve this, you should convert dates with matplotlib.mdates.date2num() Refer to this answer: Annotate Time Series plot in Matplotlib

Post a Comment for "Image Size Of 1005x132589 Pixels Is Too Large. It Must Be Less Than 2^16 In Each Direction"