Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
Summary
The typing makes it clear that both are used.
density
ofPath.hatch
is typed asfloat
. This is then passed tohatch.get_path
, where it is typed asint
and then does:
matplotlib/lib/matplotlib/hatch.py
Lines 205 to 208 in8d56b9c
density=int(density) | |
patterns= [hatch_type(hatchpattern,density) | |
forhatch_typein_hatch_types] |
hatch_type
is one of the hatch methods and typically has a line like:
matplotlib/lib/matplotlib/hatch.py
Line 16 in8d56b9c
self.num_lines=int((hatch.count('-')+hatch.count('+'))*density) |
As seen it is possible to pass a float until here.
Proposed fix
I see two solutions:
- Type
density
ofPath.hatch
asint
. This makes it consistent and there are no consequences. - Type
density
elsewhere asfloat
and remove theint(density)
inget_path
. This will work properly from a typing pespective, but change the appearance. For example, usingPath.hatch("/xX/xX", 1.9)
will changenum_lines
ofNorthEastHatch
from6*int(1.9) = 6
toint(6*1.9) = 11
. However, it will also allow a more detailed control of the density in a more natural way.