Пример #1
0
    def _plot_T_by_hour(self, year, month, day):
        ''' Plots the daily plot '''
        # get the hourly data for a single day
        df = extract_day_of_hourly(self.data_by_hour, year, month, day)
        # format the label
        label = '{:s}: {:04d}-{:02d}-{:02d}'.format(self.label, year, month, day)
        # A 'simple' plot
        self.daily_ax.plot('T', '-', picker=10, label=label, data=df,
                           **next(self.style_cycle))

        # Advances a day
        now = '{:04d}-{:02d}-{:02d}'.format(year, month, day)
        next_day = dt.datetime.strptime(now, '%Y-%m-%d') + dt.timedelta(days=1)
        df = extract_day_of_hourly(self.data_by_hour, next_day.year, next_day.month,
                                   next_day.day)
        label = next_day.strftime('{}: %Y-%m-%d'.format(self.label))
        self.daily_ax.plot('T', '-', picker=10, label=label, data=df,
                           **next(self.style_cycle))
 
        # Moves back a day
        now = '{:04d}-{:02d}-{:02d}'.format(year, month, day)
        next_day = dt.datetime.strptime(now, '%Y-%m-%d') - dt.timedelta(days=1)
        df = extract_day_of_hourly(self.data_by_hour, next_day.year, next_day.month,
                                   next_day.day)
        label = next_day.strftime('{}: %Y-%m-%d'.format(self.label))
        self.daily_ax.plot('T', '-', picker=10, label=label, data=df,
                           **next(self.style_cycle))
      
        # update the legend
        self.daily_ax.legend()
        # ask the GUI to redraw the next time it can
        self.daily_ax.figure.canvas.draw_idle()
 def _plot_T_by_hour(self, year, month, day):
     # get the hourly data for a single day
     df = extract_day_of_hourly(self.data_by_hour, year, month, day)
     # format the label
     label = '{:s}: {:04d}-{:02d}-{:02d}'.format(self.label, year, month,
                                                 day)
     # A 'simple' plot
     self.daily_ax.plot('T',
                        '-',
                        picker=10,
                        label=label,
                        data=df,
                        **next(self.style_cycle))
     # update the legend
     self.daily_ax.legend()
     # ask the GUI to redraw the next time it can
     self.daily_ax.figure.canvas.draw_idle()
Пример #3
0
        # for each hit index, print out the row
        for i in event.ind:
            print(self.df.iloc[i])

    def remove(self):
        if self.cid is not None:
            self.ln.figure.canvas.mpl_disconnect(self.cid)
            self.cid = None


fig, ax = plt.subplots()
ln, = ax.plot('mean', '-o', data=temperature_daily)
ax.set_xlabel('Date [UTC]')
ax.set_ylabel('Air Temperature [℃]')
ax.set_title(f'{datasource} temperature')

rp = RowPrinter(ln, temperature_daily)

one_day = extract_day_of_hourly(temperature, 2017, 10, 27)
plt.show()

# EXERCISE
# - make the print out nicer looking

# - open a new window with plot of day temperature
#   - fig, ax = plt.subplots()
#   - one_day = extract_day_of_hourly(temperature, 2015, 10, 18)
# - make picking add a label with `label_data`

# - use `get_gid` to filter artists instead of `is not`
Пример #4
0
        # ignore picks on not-our-artist
        if event.artist is not self.ln:
            return
        # for each hit index, print out the row
        for i in event.ind:
            print(self.df.iloc[i])

    def remove(self):
        if self.cid is not None:
            self.ln.figure.canvas.mpl_disconnect(self.cid)
            self.cid = None


fig, ax = plt.subplots()
ln, = ax.plot('mean', '-o', data=ornl_daily)
ax.set_xlabel('Date [UTC]')
ax.set_ylabel('Air Temperature [℃]')
ax.set_title('ORNL')
rp = RowPrinter(ln, ornl_daily)

one_day = extract_day_of_hourly(ornl, 2015, 10, 18)
plt.show()

# EXERCISE
# - make the print out nicer looking
# - make picking add a label with `label_data`
# - use `get_gid` to filter instead of `is not`
# - open a new window with plot of day temperature
#   - fig, ax = plt.subplots()
#   - one_day = extract_day_of_hourly(bwi, 2015, 10, 18)