ValueError: Image size of 1910824x860 pixels is too large. It must be less than 2^16 in each direction

I tried to imitate what the “Financial Crisis Example” did and change the x/y tick labels, but it tells me that the image size is too large. I want to know how to adjust the size of the graph so that it fit the size?

Ideas for how to visualize the data

Changes of euro to USD exchange rates in the year of 20220

Here are few major events that happened during this time

March: WHO announced coronavirus as a global pandemic

May: George Floyd’s death and following BLM movement

July: Chinese consulate in Houston will close

September: Trump and Biden Have the First Debate

November: Joe Biden win the presidential election

euro_to_dollar = euro_to_dollar[euro_to_dollar[‘Time’].dt.year == 2020]
euro_to_dollar_Mar = euro_to_dollar.copy()[euro_to_dollar[‘Time’].dt.month == 3]
euro_to_dollar_May = euro_to_dollar.copy()[euro_to_dollar[‘Time’].dt.month == 5]
euro_to_dollar_Jul = euro_to_dollar.copy()[euro_to_dollar[‘Time’].dt.month == 7]
euro_to_dollar_Sept = euro_to_dollar.copy()[euro_to_dollar[‘Time’].dt.month == 9]
euro_to_dollar_Nov = euro_to_dollar.copy()[euro_to_dollar[‘Time’].dt.month == 11]
import as style

fig,ax = plt.subplots(figsize = (12,4))

linewidth=2, color=’#D3D3D3’)

linewidth=4, color=’#A6D785’)

linewidth=4, color=’#e23d28’)

linewidth=4, color=’#e23d28’)

linewidth=4, color=’#A6D785’)

linewidth=4, color=’#e23d28’)


x = 13110
for month in [‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’, ‘May’, ‘Jun’,‘Jul’,‘Aug’,‘Sept’,‘Oct’,‘Nov’,‘Dec’]:
ax.text(x, 1.13, month, fontsize=10)
x += 12

y = 1.193
for rate in [‘1.2’, ‘1.3’, ‘1.4’, ‘1.5’]:
ax.text(13020, y, rate, fontsize=10)
y += 0.1


ValueError Traceback (most recent call last)
/dataquest/system/env/python3/lib/python3.8/site-packages/IPython/core/ in call(self, obj)
339 pass
340 else:
→ 341 return printer(obj)
342 # Finally look for special method names
343 method = get_real_method(obj, self.print_method)

/dataquest/system/env/python3/lib/python3.8/site-packages/IPython/core/ in (fig)
247 if ‘png’ in formats:
→ 248 png_formatter.for_type(Figure, lambda fig: print_figure(fig, ‘png’, **kwargs))
249 if ‘retina’ in formats or ‘png2x’ in formats:
250 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/dataquest/system/env/python3/lib/python3.8/site-packages/IPython/core/ in print_figure(fig, fmt, bbox_inches, **kwargs)
130 FigureCanvasBase(fig)
→ 132 fig.canvas.print_figure(bytes_io, **kw)
133 data = bytes_io.getvalue()
134 if fmt == ‘svg’:

/dataquest/system/env/python3/lib/python3.8/site-packages/matplotlib/ in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs)
2118 try:
→ 2119 result = print_method(
2120 filename,
2121 dpi=dpi,

/dataquest/system/env/python3/lib/python3.8/site-packages/matplotlib/backends/ in print_png(self, filename_or_obj, metadata, pil_kwargs, *args, **kwargs)
512 }
→ 514 FigureCanvasAgg.draw(self)
515 if pil_kwargs is not None:
516 from PIL import Image

/dataquest/system/env/python3/lib/python3.8/site-packages/matplotlib/backends/ in draw(self)
386 Draw the figure using the renderer.
387 “”"
→ 388 self.renderer = self.get_renderer(cleared=True)
389 # Acquire a lock on the shared font cache.
390 with RendererAgg.lock, \

/dataquest/system/env/python3/lib/python3.8/site-packages/matplotlib/backends/ in get_renderer(self, cleared)
402 and getattr(self, “_lastKey”, None) == key)
403 if not reuse_renderer:
→ 404 self.renderer = RendererAgg(w, h, self.figure.dpi)
405 self._lastKey = key
406 elif cleared:

/dataquest/system/env/python3/lib/python3.8/site-packages/matplotlib/backends/ in init(self, width, height, dpi)
90 self.width = width
91 self.height = height
—> 92 self._renderer = _RendererAgg(int(width), int(height), dpi)
93 self._filter_renderers =

ValueError: Image size of 1910824x860 pixels is too large. It must be less than 2^16 in each direction.

Hi @zhouhuilingsybil and welcome back to the community!

I believe the reason you’re getting this error is due to your x and y coordinates for ax.text(). I’ve seen this error talked about before and the solution is to use ax.get_xticks() and ax.get_yticks() to first find out the coordinates and then go from there.

For more details, check out this post and this one too.