##################### Plot time series data ##################### This page introduces a program that creates plots of time series data. Description of data structure and variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Information is `here `__. (1) Time series plot -------------------- Read one variable ================= You need to read the dataset (5-minutes in row and hourly in columns) and create one time series data. .. literalinclude:: SRC/programs/plots.py :language: python :lines: 62-73 'var' is the variable name, for example, 'TAIR1(1)'. .. literalinclude:: SRC/programs/plots.py :language: python :lines: 10-20 This subroutine is to read 12 peices of data (data every 5 minutes) and generate a series of data. Create a plot ============= Using a set of variable data and timestamps, let's plot one-dimensional time series data. .. literalinclude:: SRC/programs/plots.py :language: python :lines: 78-100 :emphasize-lines: 12 You can change the x-axis and y-axis tick intervals depending on the duration of the data. This program uses annual major ticks and monthly minor ticks. .. image:: SRC/beaver.png :height: 300 Sample program for plots ======================== The program reads a file at each station, generate a series of a variable, and plots one-dimensional time series data. Source file: :download:`plots.py ` (2) How to make a plot with two different Y-axis ------------------------------------------------ In some cases, you may want to create a single plot that compares two variables with different scales. For example, compare precipitation and wetness data to ensure that these two changes are consistent. In that case, we make a single plot with two different y-axis on the left and right. Set 'ax2' to make another plot using the Y-axis scale on the right. .. literalinclude:: SRC/programs/plot.Prec_Wet.py :language: python :lines: 38-46 .. literalinclude:: SRC/programs/plot.Prec_Wet.py :language: python :lines: 69-78 :emphasize-lines: 3 The plot shows precipitation (contour lines) and wetness (lightblue shaded). When the sensor gets wet, the wetness data shows that it is close to zero. Therefore, the plot shows the data in the opposite (y-axis) direction. .. image:: SRC/VWPCP.Wet.png :height: 300 Sample program for plots ======================== Source file: :download:`plot.Prec_Wet.py `