musical score layout hooks#1869
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the musical score layout logic by introducing the _MusicalScoreLayoutBuilder class to handle horizontal and vertical layouts, and the BinstLabeller class to customize labels and symbols. It also introduces custom pentagon box styles for matplotlib, updates various wire symbols (such as TextBox and ModPlus), and allows draw_musical_score to accept an external matplotlib axis. Additionally, _soq_to_symb is moved to qpic_diagram.py. A critical issue was identified in ModPlus.draw where plt.Line2D is used, which will raise an AttributeError at runtime since Line2D resides in matplotlib.lines rather than matplotlib.pyplot.
| line1 = plt.Line2D([-radius_px, radius_px], [0, 0], color='k', lw=lw, transform=xform) | ||
| line2 = plt.Line2D([0, 0], [-radius_px, radius_px], color='k', lw=lw, transform=xform) |
There was a problem hiding this comment.
Using plt.Line2D will raise an AttributeError at runtime because matplotlib.pyplot (imported as plt) does not expose the Line2D class. Line2D is located in the matplotlib.lines module. Please import and use matplotlib.lines.Line2D instead.
| line1 = plt.Line2D([-radius_px, radius_px], [0, 0], color='k', lw=lw, transform=xform) | |
| line2 = plt.Line2D([0, 0], [-radius_px, radius_px], color='k', lw=lw, transform=xform) | |
| import matplotlib.lines as mlines | |
| line1 = mlines.Line2D([-radius_px, radius_px], [0, 0], color='k', lw=lw, transform=xform) | |
| line2 = mlines.Line2D([0, 0], [-radius_px, radius_px], color='k', lw=lw, transform=xform) |
pltand accept optionalaxparameter