MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _bcast_lwls

Method _bcast_lwls

lib/matplotlib/collections.py:766–801  ·  view source on GitHub ↗

Internal helper function to broadcast + scale ls/lw In the collection drawing code, the linewidth and linestyle are cycled through as circular buffers (via ``v[i % len(v)]``). Thus, if we are going to scale the dash pattern at set time (not draw time) we need to

(linewidths, dashes)

Source from the content-addressed store, hash-verified

764
765 @staticmethod
766 def _bcast_lwls(linewidths, dashes):
767 """
768 Internal helper function to broadcast + scale ls/lw
769
770 In the collection drawing code, the linewidth and linestyle are cycled
771 through as circular buffers (via ``v[i % len(v)]``). Thus, if we are
772 going to scale the dash pattern at set time (not draw time) we need to
773 do the broadcasting now and expand both lists to be the same length.
774
775 Parameters
776 ----------
777 linewidths : list
778 line widths of collection
779 dashes : list
780 dash specification (offset, (dash pattern tuple))
781
782 Returns
783 -------
784 linewidths, dashes : list
785 Will be the same length, dashes are scaled by paired linewidth
786 """
787 if mpl.rcParams['_internal.classic_mode']:
788 return linewidths, dashes
789 # make sure they are the same length so we can zip them
790 if len(dashes) != len(linewidths):
791 l_dashes = len(dashes)
792 l_lw = len(linewidths)
793 gcd = math.gcd(l_dashes, l_lw)
794 dashes = list(dashes) * (l_lw // gcd)
795 linewidths = list(linewidths) * (l_dashes // gcd)
796
797 # scale the dash patterns
798 dashes = [mlines._scale_dashes(o, d, lw)
799 for (o, d), lw in zip(dashes, linewidths)]
800
801 return linewidths, dashes
802
803 def get_antialiased(self):
804 """

Callers 2

set_linewidthMethod · 0.95
set_linestyleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected