Home > other >  Inquire, python matplotlib drawing x coordinates cannot display all of the data
Inquire, python matplotlib drawing x coordinates cannot display all of the data

Time:10-03

Learning python primer, encountered a problem in learning to use matplotlib
Shows the x coordinate in the book date is complete, I refer to a CSV file, date data is complete
But when I run x coordinate according to not complete,
Give the greatly to solving ~ thank you
 

The import CSV
The from datetime import datetime
The from matplotlib import pyplot as PLT

Filename=r 'death_valley_2014. CSV'
With the open (filename) as f:
Reader=CSV. Reader (f)
Header_row=next (reader)
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 [3])
Except, ValueError:
Print (current_date, 'the missing data)
The else:
Dates. Append (current_date)
Highs. Append (high)
Lows. Append (low)

FIG.=PLT figure (dpi=128, figsize=(10, 6))
PLT. The plot (dates, highs, c='red', alpha=0.5) # arguments specified alpha color transparency
PLT. The plot (dates, lows, c='blue', alpha=0.5)
PLT. Fill_between (dates, highs, lows, facecolor='blue', alpha=0.1) face color # arguments to specify the color of the filled areas
Title="Daily high and low temperatures - 2014 \ nDeath Valley, CA"
PLT. Title (the title, fontsize=20)
PLT. Xlabel (" ', fontsize=10)
FIG. Autofmt_xdate () # call FIG. Autofmt_xdate () to draw oblique date label, lest they overlap each other
PLT. Ylabel (' Temperature (F) ', fontsize=10)
='both' PLT. Tick_params (axis, which='major', labelsize=10)
PLT. The show ()




It is stupid, please grant instruction

CodePudding user response:

Date data is too dense, want to show that can't finish the show,
You try to look at the effect of the data only take 7 days,

CodePudding user response:

reference 1st floor seakingx response:
date data is too dense, want to show that can't finish the show,
You try to take 7 days to look at the effect of the data,

Just show in ah, that is to say 12 scale is enough
  • Related