예제 #1
0
                       unit=UNIT,
                       width=10000,
                       plot_kwargs={
                           'linewidth': 0.3,
                           'color': 'grey',
                           'label': 'Mains (active power)'
                       })

# Prettify
ax.grid(False)
ax.set_ylim([0, 4])
ax.set_xlabel('Time (hour of day)')
ax.xaxis.set_major_formatter(DateFormatter("%H", tz=TZ))
ax.xaxis.set_major_locator(HourLocator(interval=6, tz=TZ))
for text in ax.get_xticklabels():
    text.set_rotation(0)
    text.set_ha('center')
sns.despine(ax=ax)
legend = ax.legend(loc='upper left')
for line in legend.get_lines():
    line.set_linewidth(4)

plot_config.format_axes(ax)
plt.tight_layout()

plt.draw()

plt.savefig(join(plot_config.FIG_DIR, '02_area_plot.eps'),
            bbox_inches='tight',
            dpi=plt.gcf().dpi)
    'range': [(2, 275), (2200, 2460), (1480, 1650), (400, 2200), (80, 140),
              (None, 60), (2, 65), (30, 85), (35, 290)]
}

axes = elec.plot_multiple(axes,
                          meter_keys,
                          'plot_power_histogram',
                          kwargs_per_meter,
                          plot_kwargs={'color': plot_config.BLUE})

# Formatting
for i, ax in enumerate(axes):
    ax.grid(False)
    ax.set_yticks([])
    ax.set_ylabel('')
    plot_config.format_axes(ax, tick_size=2)
    ax.xaxis.set_ticks_position('bottom')
    ax.xaxis.set_major_locator(MaxNLocator(4))
    for spine in ax.spines.values():
        spine.set_visible(False)
    if i == 7:
        ax.set_xlabel('Power (watts)')
    else:
        ax.set_xlabel('')

    title = ax.get_title()
    if title in plot_config.new_names:
        title = plot_config.new_names[title]
    ax.set_title(title, y=0.95)

plt.tight_layout()
예제 #3
0
elec = dataset.buildings[1].elec

N = 9
fig, axes = plt.subplots(N, 1)
meter_keys = ['boiler', 'kettle', 'toaster', 'oven',
              'vacuum cleaner', 'television', 
              'laptop computer', 'computer monitor', ('light', 1)]

axes = elec.plot_multiple(axes, meter_keys, 'plot_activity_histogram')

# Formatting
for i, ax in enumerate(axes):
    ax.grid(False)
    ax.set_yticks([])
    ax.set_ylabel('')
    plot_config.format_axes(ax, tick_size=2)
    ax.xaxis.set_ticks_position('bottom')
    ax.xaxis.set_major_locator(MultipleLocator(6))
    ax.spines['bottom'].set_linewidth(0.2)
    for spine in ['right', 'top', 'left']:
        ax.spines[spine].set_visible(False)
    if i == N-1:
        ax.set_xlabel('Hour of day')
    else:
        ax.set_xlabel('')
        ax.set_xticklabels([])
    title = ax.get_title()
    if title in plot_config.new_names:
        title = plot_config.new_names[title]
    ax.set_title(title, y=0.95)
예제 #4
0
# in output.  Looks bad in plt.show() though!
ax, df = selected_meters.plot(kind='area', unit=UNIT, width=4000, threshold=5,
                              plot_kwargs={'linewidth': 0})

# Plot mains
ax = elec.mains().plot(ax=ax, unit=UNIT, width=10000,
                       plot_kwargs={'linewidth': 0.3, 'color': 'grey',
                                    'label': 'Mains (active power)'})

# Prettify
ax.grid(False)
ax.set_ylim([0, 4])
ax.set_xlabel('Time (hour of day)')
ax.xaxis.set_major_formatter(DateFormatter("%H", tz=TZ))
ax.xaxis.set_major_locator(HourLocator(interval=6, tz=TZ))
for text in ax.get_xticklabels():
    text.set_rotation(0)
    text.set_ha('center')
sns.despine(ax=ax)
legend = ax.legend(loc='upper left')
for line in legend.get_lines():
    line.set_linewidth(4)

plot_config.format_axes(ax)
plt.tight_layout()

plt.draw()

plt.savefig(join(plot_config.FIG_DIR, '02_area_plot.eps'),
            bbox_inches='tight', dpi=plt.gcf().dpi)