Need your help for Story telling Data Visualization project

Screen Link:

My Code:

import matplotlib.style as style
style.use('fivethirtyeight')

### create two plots 
fig,ax = plt.subplots(figsize=(8,3))
ax.plot(financial_crisis['Time'], 
              financial_crisis['rolling_mean'],
              lw=1, color='#1f11ac', alpha=0.5)

ax.plot(financial_crisis_07_08['Time'],
              financial_crisis_07_08['rolling_mean'],
              lw=3, color='#1f11ac')

## remove tick labels
ax.set_xticklabels([])
ax.set_yticklabels([])

## insert title
ax.text(35000,1.13,s='Euro-USD')

What I expected to happen:

What actually happened:

Text(35000, 1.13, 'Euro-USD')
---------------------------------------------------------------------------
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 303089x285 pixels is too large. It must be less than 2^16 in each direction.

<Figure size 800x300 with 1 Axes>

<!--Enter other details below: -->
I still don't get why it gives me this error message when I try to put a text in the graph. I tried every kind of possible combination between x and y axis and still don't understand.

Could you help me?
Feel like this thing is becoming a little bit to hard for a small brain like me...

Thank you!!!

Hey there, @giovanni.srg

Can you make some tweaks in your post to help us understand your problems?
The screen link is empty, and the last part of the question has been included as code.
Fixing that is going to give more details about the problem :smile:

But meanwhile, you can take a look at this post talking about this same problem.
This has nothing to do with brain size, hahaha. I got stuck for two days looking at a code just because of a “=” instead of a “==”.
I hope it helps!

3 Likes

@giovanni.srg I suggest that you take a look at the guidelines for asking technical questions. They’ll help you get your question answered quicker.

1 Like

Ok! I solved this one!

I will probably text again about this project for other inofrmations. Thank you!

@giovanni.srg I’m curious what you did to solve this problem…can you explain how you fixed it?

Well, I don’t really know if it’s a canonical solution but I first used the ax.get_xticks() function to see which were the values of the various axes and then adjusted them for the text with the good ol’ trial and error method.

It worked!!!