diff --git a/curlyBrace.py b/curlyBrace.py index 6ccf04e..8eb31b6 100644 --- a/curlyBrace.py +++ b/curlyBrace.py @@ -478,7 +478,8 @@ def curlyBrace(fig, ax, p1, p2, k_r=0.1, bool_auto=True, str_text='', int_line_n pass # plot arcs - ax.plot(arc1x, arc1y, **kwargs) + l, = ax.plot(arc1x, arc1y, **kwargs) + kwargs["color"] = l.get_color() ax.plot(arc2x, arc2y, **kwargs) ax.plot(arc3x, arc3y, **kwargs) ax.plot(arc4x, arc4y, **kwargs) diff --git a/exp_color.py b/exp_color.py new file mode 100644 index 0000000..cf83ed8 --- /dev/null +++ b/exp_color.py @@ -0,0 +1,27 @@ +"""Simple example of curlyBrace with automatic colors. + +Author: Markus Reinert +Last Modified: 2022-03-23 +""" + +import matplotlib.pyplot as plt + +from curlyBrace import curlyBrace + + +save_figure = False + + +fig, ax = plt.subplots() +ax.set_ylim(2, 12) +ax.set_xlim(-1, 1) +for i in range(12): + # The color of the curlyBrace is not given explicitly, + # but determined automatically by matplotlib's color rotation + curlyBrace(fig, ax, (-1, i), (1, i)) + +if save_figure: + import os + fig.savefig(os.path.basename(__file__).replace(".py", ".png")) + +plt.show()