Place each cause to a position relative to the problems annotations. Parameters ---------- data : indexable object The input data. IndexError is raised if more than six arguments are passed. cause_x, cause_y : float The `X` and `Y` position of the ca
(data: list,
cause_x: float, cause_y: float,
cause_xytext=(-9, -0.3), top: bool = True)
| 58 | |
| 59 | |
| 60 | def causes(data: list, |
| 61 | cause_x: float, cause_y: float, |
| 62 | cause_xytext=(-9, -0.3), top: bool = True): |
| 63 | """ |
| 64 | Place each cause to a position relative to the problems |
| 65 | annotations. |
| 66 | |
| 67 | Parameters |
| 68 | ---------- |
| 69 | data : indexable object |
| 70 | The input data. IndexError is |
| 71 | raised if more than six arguments are passed. |
| 72 | cause_x, cause_y : float |
| 73 | The `X` and `Y` position of the cause annotations. |
| 74 | cause_xytext : tuple, optional |
| 75 | Adjust to set the distance of the cause text from the problem |
| 76 | arrow in fontsize units. |
| 77 | top : bool, default: True |
| 78 | Determines whether the next cause annotation will be |
| 79 | plotted above or below the previous one. |
| 80 | |
| 81 | Returns |
| 82 | ------- |
| 83 | None. |
| 84 | |
| 85 | """ |
| 86 | for index, cause in enumerate(data): |
| 87 | # [<x pos>, <y pos>] |
| 88 | coords = [[0.02, 0], |
| 89 | [0.23, 0.5], |
| 90 | [-0.46, -1], |
| 91 | [0.69, 1.5], |
| 92 | [-0.92, -2], |
| 93 | [1.15, 2.5]] |
| 94 | |
| 95 | # First 'cause' annotation is placed in the middle of the 'problems' arrow |
| 96 | # and each subsequent cause is plotted above or below it in succession. |
| 97 | cause_x -= coords[index][0] |
| 98 | cause_y += coords[index][1] if top else -coords[index][1] |
| 99 | |
| 100 | ax.annotate(cause, xy=(cause_x, cause_y), |
| 101 | horizontalalignment='center', |
| 102 | xytext=cause_xytext, |
| 103 | fontsize=9, |
| 104 | xycoords='data', |
| 105 | textcoords='offset fontsize', |
| 106 | arrowprops=dict(arrowstyle="->", |
| 107 | facecolor='black')) |
| 108 | |
| 109 | |
| 110 | def draw_body(data: dict): |