Esempio n. 1
0
import matplotlib.pyplot as plt
from w_helpers import load_data, aggregate_by_month
plt.ion()

temperature = load_data('central_park')
temperature_monthly = aggregate_by_month(temperature)

fig, ax = plt.subplots()


def plot_aggregated_errorbar(ax, gb, label, picker=None, **kwargs):
    kwargs.setdefault('capsize', 3)
    kwargs.setdefault('markersize', 5)
    kwargs.setdefault('marker', 'o')
    eb = ax.errorbar(gb.index,
                     'mean',
                     yerr='std',
                     data=gb,
                     label=label,
                     picker=picker,
                     **kwargs)
    fill = ax.fill_between(gb.index,
                           'min',
                           'max',
                           alpha=.5,
                           data=gb,
                           color=eb[0].get_color())
    ax.legend()
    ax.figure.canvas.draw_idle()
    return eb, fill
import matplotlib.pyplot as plt
from w_helpers import load_data, aggregate_by_month
plt.ion()

temperature = load_data('mdw')
temperature_monthly = aggregate_by_month(temperature)

fig, ax = plt.subplots()


def plot_aggregated_errorbar(ax, gb, label, picker=None, **kwargs):
    kwargs.setdefault('capsize', 3)
    kwargs.setdefault('markersize', 5)
    kwargs.setdefault('marker', 'o')
    eb = ax.errorbar(gb.index,
                     'mean',
                     yerr='std',
                     data=gb,
                     label=label,
                     picker=picker,
                     **kwargs)
    fill = ax.fill_between(gb.index,
                           'min',
                           'max',
                           alpha=.5,
                           data=gb,
                           color=eb[0].get_color())
    ax.legend()
    ax.figure.canvas.draw_idle()
    return eb, fill
Esempio n. 3
0
import matplotlib.pyplot as plt
from w_helpers import load_data, aggregate_by_day, extract_day_of_hourly, label_date

import uuid

datasource = 'central_park'

temperature = load_data(datasource)
temperature = temperature[temperature['year'] >= 2017]
temperature_daily = aggregate_by_day(temperature)


class RowPrinter:
    def __init__(self, ln, df, picker=10):
        ln.set_picker(picker)
        # we can use this to ID our line!
        self.uid = str(uuid.uuid4())
        ln.set_gid(self.uid)
        self.ln = ln
        self.df = df
        self.cid = None
        self.connect()

    def connect(self):
        self.remove()
        self.cid = ln.figure.canvas.mpl_connect('pick_event', self)

    def __call__(self, event):
        # ignore picks on not-our-artist
        if event.artist is not self.ln:
            return