The default for drawing markers is to use the stroke width of the calling element, but you can explicitly specify that markers be drawn using the unit system for the element the marker is being applied to by specifying markerUnits="userSpaceOnUse"
. Markers are drawn into a 3x3 markerUnits box (3 strokewidths if markerUnits are not specified). But the width and height of the box can be explicitly specified with markerHeight
and markerWidth
. See below for the effects of various combinations of markerUnits
, markerHeight
and markerWidth
.
<svg width="800px" height="600px">
<defs>
<marker id="marker1"
viewBox="0 0 10 10" refX="0" refY="5" orient="auto" markerUnits="strokeWidth" markerWidth="1" markerHeight="1">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
<marker id="marker2"
viewBox="0 0 10 10" refX="0" refY="5" orient="auto" markerUnits="strokeWidth" markerWidth="4" markerHeight="4">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
<marker id="marker3"
viewBox="0 0 10 10" refX="0" refY="5" orient="auto" markerUnits="userSpaceOnUse" markerWidth="15" markerHeight="15">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
<marker id="marker4"
viewBox="0 0 10 10" refX="0" refY="5" orient="auto" markerUnits="userSpaceOnUse" markerWidth="30" markerHeight="30">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
</defs>
<line x1="20" y1="20" x2="100" y2="100" stroke-width="8" stroke="blue" marker-end="url(#marker1)" />
<text x="20" y="150"> markerUnits = strokeWidth </text>
<text x="20" y="170"> markerWidth|Height = 1 </text>
<line x1="220" y1="20" x2="300" y2="100" stroke-width="8" stroke="blue" marker-end="url(#marker2)" />
<text x="250" y="150"> markerUnits = strokeWidth </text>
<text x="250" y="170"> markerWidth|Height = 4 </text>
<line x1="20" y1="220" x2="100" y2="300" stroke-width="8" stroke="blue" marker-end="url(#marker3)" />
<text x="20" y="390"> markerUnits = userSpaceOnUse </text>
<text x="20" y="410"> markerWidth|Height = 15 </text>
<line x1="220" y1="220" x2="300" y2="300" stroke-width="8" stroke="blue" marker-end="url(#marker4)" />
<text x="250" y="390"> markerUnits = userSpaceOnUse </text>
<text x="250" y="410"> markerWidth|Height = 30 </text>
</svg>