我需要用matplotlib绘制一张似乎没有这样功能的穿孔卡.所以我编写了以下代码:
import matplotlib.pyplot as plt
import numpy as np
def draw_punchcard(infos,
ax1=range(7),
ax2=range(24),
ax1_ticks=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
ax2_ticks=range(24),
ax1_label='Day',
ax2_label='Hour'):
"""Construct a punchcard.
Quick'n dirty way.
Parameters
==========
- infos: Dictionary of quantities to display.
They are indexed by key of type (val1,val2) with
val1 included in ax1 and val2 included in ax2.
- ax1: list
Possible values for first axe (if different than days)
- ax2: list
Possible values for second axe (if different than hours) …Run Code Online (Sandbox Code Playgroud)