[Python] modify the code so that your own name can be included in the last Pasadena plot's...

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    Getting an error when trying to modify the title not sure what the issue is...

    # formatted string literal: will insert values of variable in braces
    f'{station}, {year}: average temperature = {avg:.2f} C', 'created'

    ('PASADENA, 2018: average temperature = 19.46 C', 'created')

    # show normals, records, and current year bands together

    pp.figure(figsize=(15,4.5))

    pp.fill_between(days, tmin_record, tmax_record, color=(0.92,0.92,0.89), step='mid')
    pp.fill_between(days, tmin_normal, tmax_normal, color=(0.78,0.72,0.72))

    pp.fill_between(days, thisyear['TMIN'], thisyear['TMAX'],
    color=(0.73,0.21,0.41), alpha=0.6, step='mid')

    pp.axis(xmin=1, xmax=365, ymin=-15, ymax=50)

    pp.title(f'{station}, {year}: average temperature = {avg:.2f} C', 'created');

    AttributeError Traceback (most recent call last)
    <ipython-input-91-1e0a70458093> in <module>

    pp.axis(xmin=1, xmax=365, ymin=-15, ymax=50)


    ---> pp.title(f'{station}, {year}: average temperature = {avg:.2f} C', 'created');

    ~\anaconda3\lib\site-packages\matplotlib\pyplot.py in title(label, fontdict, loc, pad, **kwargs)

    @docstring.copy(Axes.set_title)

    def title(label, fontdict=None, loc=None, pad=None, **kwargs):
    -> return gca().set_title(

    label, fontdict=fontdict, loc=loc, pad=pad, **kwargs)


    ~\anaconda3\lib\site-packages\matplotlib\axes\_axes.py in set_title(self, label,
    fontdict, loc, pad, **kwargs)

    211 title.update(default)

    212 if fontdict is not None:`

    --> `enter code here` title.update(fontdict)

    title.update(kwargs)

    return title

    ~\anaconda3\lib\site-packages\matplotlib\text.py in update(self, kwargs)

    # Update bbox last, as it depends on font properties.

    sentinel = object() # bbox can be None, so use another sentinel.

    --> bbox = kwargs.pop("bbox", sentinel)

    super().update(kwargs)

    if bbox is not sentinel:

    AttributeError: 'str' object has no attribute 'pop'

    Continue reading...

Compartilhe esta Página