Home > other >  This set the y axis error range TypeError: 'the tuple object is not callable
This set the y axis error range TypeError: 'the tuple object is not callable

Time:11-05

This is the book "Python programming: from entry to practice" in chapter 16 exercises 16-2; Change is shown in the chart of y Settings,
I use the PLT. Ylim () command,

The following is the code:
 
The import CSV
The from datetime import datetime
The from matplotlib import pyplot as PLT

# to open the file
Filename='death_valley_2014. CSV'
With the open (filename) as f:
Reader=CSV. Reader (f)
Header_row=next (reader)

# read date, the maximum temperature and minimum temperature
Dates, highs, lows=[], [], []
For the row in reader:
Try:
Current_date=datetime. Strptime (row [0], "Y - m - % d % %")
High=int (row [1])
Low=int (row [2])
Except, ValueError:
Print (current_date, 'the missing data)
The else:
Dates. Append (current_date)
Highs. Append (high)
Lows. Append (low)


# plot
FIG.=PLT figure (dpi=128, figsize=(1, 6))
PLT. The plot (dates, highs, c='red')
PLT. The plot (dates, lows, c='blue')
PLT. Fill_between (dates, highs, lows, facecolor='blue', alpha=0.33)

# set the graphics format
PLT. Title (" the Daily high and low temperatures - 2014 \ nDeath Valley, CA ", fontsize=20)
PLT. Xlabel (" ', fontsize=16)
FIG. Autofmt_xdate ()
PLT. Ylabel (" Temperature (F) ", fontsize=16)
='both' PLT. Tick_params (axis, which='major', labelsize=16)
PLT. Ylim (10120)

PLT. The show ()


PLT. Ylim (10120) wants to set the axis range between 10 to 120, but after running the error message:

2014-02-16 00:00:00 missing data
Traceback (the most recent call last) :

The File "C: \ Users \ \. XXX spyder - py3 \ learn \ deathvally_highs_lows_2014 py", line 44, in & lt; module>
PLT. Ylim (10120)

TypeError: 'the tuple object is not callable


Chart for coordinate setting is not correct, not according to the desired setting,

Pray god to answer why such mistake?

CodePudding user response:

After I shut down, reboot, this problem was done not have,
  • Related