Guided project: European exchange rate- image size too large

Screen Link:Learn data science with Python and R projects

My Code:

import matplotlib.style as style
style.use('fivethirtyeight')
fig, ax= plt.subplots(figsize=(8,3))
ax.plot(euro_to_dollar_2020['Time'],euro_to_dollar_2020['rolling_mean_30'],
        linewidth=1)
ax.plot(euro_to_dollar_2016_2019['Time'],euro_to_dollar_2016_2019['rolling_mean_30'],
        linewidth=1)
for location in ['left','right','top','bottom']:
    ax.spines[location].set_visible(False)
    
ax.set_xticklabels([])
ax.set_yticklabels([])

x = 13200
for year in ['2016','2017','2018','2019','2020']:
    ax.text(x, 1.13, year, alpha=0.5, fontsize=11)
    x+=365
    
y = 1.193
for rate in ['1.2','1.3','1.4','1.5']:
    ax.text(13020,y, rate, alpha=0.5, fontsize=11)
    y += 0.1
    
ax.text(13020,1.67,'EURO-USD rate comparison: 2020 vs 2016-2019', weight='bold')

ax.text(13020, 1.07,'@Dataquest' + ' ' *80 + 'Source:European Central Bank',size=10)

plt.show()

What I expected to happen:
no error

What actually happened:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/dataquest/system/env/python3/lib/python3.8/site-packages/IPython/core/formatters.py 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/pylabtools.py in <lambda>(fig)
    246 
    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/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
    130         FigureCanvasBase(fig)
    131 
--> 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/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs)
   2117 
   2118             try:
-> 2119                 result = print_method(
   2120                     filename,
   2121                     dpi=dpi,

/dataquest/system/env/python3/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, metadata, pil_kwargs, *args, **kwargs)
    512         }
    513 
--> 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/backend_agg.py 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/backend_agg.py 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/backend_agg.py 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 = []
     94 

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

<Figure size 800x300 with 1 Axes>

Comments:
I change the x, y amount and text sentences and added transform=ax.transAxes and it still doesn’t work. :frowning_face: