amep.plot.draw_box#
- amep.plot.draw_box(fig: Figure, box_extent: ndarray | list | tuple, text: str | None = None, edgecolor: str = 'k', facecolor: str = 'w', linestyle: str = '--', linewidth: float = 1.0, edgealpha: float = 1.0, facealpha: float = 0.0, boxstyle: str = 'square', pad: float = 0.0, dxtext: float = 0.0, dytext: float = 0.0, ha='center', va='bottom', **kwargs)#
Draws a box.
- Parameters:
fig (plt.Figure) – Figure to which the box is added.
box_extent (np.ndarray | list | tuple) –
relative (to the figure) coordinates of the area to be enlarged inside the initial plot starting from the lower left corner: [x_0, y_0, d_x, d_y]
- x_0float
x coordinate of the lower left corner of the inset figure.
- y_0float
y coordinate of the lower left corner of the inset figure.
- d_xfloat
Width of the inset figure.
- d_yfloat
Height of the inset figure.
text (str, optional) – Text to be written above the drawn box. The location of the box can be changed with dxtext, dytext and the arguments forwarded to fig.txt().
edgecolor (str|None, optional) – Color of the box boundary. The default is None.
facecolor (str|None, optional) – Filling color of the box. The default is None.
linestyle (str, optional) – Style of the box boundary. Possible linestyles are ‘-’, ‘:’, ‘–’, ‘-.’. See also amep.plot.linestyles(). The default is ‘–‘.
linewidth (float, optional) – Width of the box boundary. The default is 1.0.
edgealpha (float, optional) – Transarency of the box boundary. The default is 1.0.
facealpha (float, optional) – Transparency of the box filling. The default is 1.0.
boxstyle (str, optional) – Style of the box. Possible styles are ‘circle’, ‘darrow’, ‘larrow’, ‘rarrow’, ‘round’, ‘round4’, ‘roundtooth’, ‘sawtooth’, ‘square’ (see also https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.FancyBboxPatch.html). The default is ‘square’.
pad (float, optional) – The amount of padding around the original box.. The default is 0.0.
dxtext (float, optional) – x-offset of the text from the centre above the box. Relative to the box coordinates. The default is 0.
dytext (float, optional) – y-offset of the text from the centre above the box. Relative to the box coordinates. The default is 0.
ha (str, optional) – keyword argument passed to fig.text(). horizontal alignment.
va (str, optional) – keyword argument passed to fig.text(). vertical alignment.
**kwargs – keyword arguments passed to fig.text() such as fontsize, color/c, …
- Return type:
None.
Examples
>>> import amep >>> fig, axs=amep.plot.new() >>> axs.plot([0,1,2,3], [0,2,1,1]) >>> amep.plot.draw_box( ... fig, box_extent=[0, 0, 0.45, 1.01], ... text="inside box1", fontsize=15, c="r", ... facecolor="tab:orange", facealpha=0.2, ... dxtext=.12, dytext=-.15, ha="right" ... ) >>> amep.plot.draw_box( ... fig, box_extent=[0.5, 0, 0.5, 1.01], ... text="box2", facecolor="tab:blue", facealpha=0.2, ... edgecolor="tab:green", linestyle=":" ... ) >>> fig.savefig('./figures/plot/plot-draw_box.png') >>>