在svgwrite中保存SVG时,确保整个绘图区域可见

时间:2014-11-28 13:34:14

标签: python svg

我正在构建一个图表,我必须将svg文本放在图表的左侧。我把它放在我希望它以图表结尾的位置:

text_element = svgwrite.text.Text(
    "Label", 
    x=pos_x,
    y=pos_y, 
    fill=text_color)
text_element["text-anchor"] = "end"
dwg.add(text_element)

但是我最终只能在svg中使用一部分文本渲染,而其余部分则被剪切掉了。我可以使用inkscape将区域设置回图形区域。

svgwrite是否有方法确保整个绘图区域可见?

有这个问题的示例svg是:

Preview:

<?xml version="1.0" encoding="utf-8" ?>
    <svg baseProfile="tiny" version="1.2" width="500" height="290" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(46, -20)">
      <text fill="red" text-anchor="middle" x="14" y="70">9</text>
      <line stroke="rgb(10%,10%,16%)" x1="14" x2="14" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="47.1856" x2="47.1856" y1="74" y2="245.0" />
      <line stroke="rgb(10%,10%,16%)" x1="14" x2="47.1856" y1="245.0" y2="245.0" />
      <text fill="red" text-anchor="end" x="14" y="245.0">CLR</text>
      <text fill="red" text-anchor="middle" x="35" y="70">8</text>
      <line stroke="rgb(10%,10%,16%)" x1="35" x2="35" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="59.6288" x2="59.6288" y1="74" y2="213.5" />
      <line stroke="rgb(10%,10%,16%)" x1="14" x2="59.6288" y1="213.5" y2="213.5" />
      <text fill="red" text-anchor="end" x="14" y="213.5">RAKEL1</text>
      <text fill="red" text-anchor="middle" x="56" y="70">7</text>
      <line stroke="rgb(10%,10%,16%)" x1="56" x2="56" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="70.0" x2="70.0" y1="74" y2="182.0" />
      <line stroke="rgb(10%,10%,16%)" x1="14" x2="70.0" y1="182.0" y2="182.0" />
      <text fill="red" text-anchor="end" x="14" y="182.0">BPMLL</text>
      <text fill="red" text-anchor="middle" x="77" y="70">6</text>
      <line stroke="rgb(10%,10%,16%)" x1="77" x2="77" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="88.6666666667" x2="88.6666666667" y1="74" y2="150.5" />
      <line stroke="rgb(10%,10%,16%)" x1="14" x2="88.6666666667" y1="150.5" y2="150.5" />
      <text fill="red" text-anchor="end" x="14" y="150.5">MLkNN</text>
      <text fill="red" text-anchor="middle" x="98" y="70">5</text>
      <line stroke="rgb(10%,10%,16%)" x1="98" x2="98" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="123.926133333" x2="123.926133333" y1="74" y2="276.5" />
      <line stroke="rgb(10%,10%,16%)" x1="182.0" x2="123.926133333" y1="276.5" y2="276.5" />
      <text fill="red" text-anchor="start" x="182.0" y="276.5">RAKEL2</text>
      <text fill="red" text-anchor="middle" x="119" y="70">4</text>
      <line stroke="rgb(10%,10%,16%)" x1="119" x2="119" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="128.073866667" x2="128.073866667" y1="74" y2="245.0" />
      <line stroke="rgb(10%,10%,16%)" x1="182.0" x2="128.073866667" y1="245.0" y2="245.0" />
      <text fill="red" text-anchor="start" x="182.0" y="245.0">LP</text>
      <text fill="red" text-anchor="middle" x="140" y="70">3</text>
      <line stroke="rgb(10%,10%,16%)" x1="140" x2="140" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="140.518933333" x2="140.518933333" y1="74" y2="213.5" />
      <line stroke="rgb(10%,10%,16%)" x1="182.0" x2="140.518933333" y1="213.5" y2="213.5" />
      <text fill="red" text-anchor="start" x="182.0" y="213.5">BR</text>
      <text fill="red" text-anchor="middle" x="161" y="70">2</text>
      <line stroke="rgb(10%,10%,16%)" x1="161" x2="161" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="144.666666667" x2="144.666666667" y1="74" y2="182.0" />
      <line stroke="rgb(10%,10%,16%)" x1="182.0" x2="144.666666667" y1="182.0" y2="182.0" />
      <text fill="red" text-anchor="start" x="182.0" y="182.0">mlg-lp-unweighted</text>
      <text fill="red" text-anchor="middle" x="182" y="70">1</text>
      <line stroke="rgb(10%,10%,16%)" x1="182" x2="182" y1="74" y2="79.12" />
      <line stroke="rgb(10%,10%,16%)" x1="163.333333333" x2="163.333333333" y1="74" y2="150.5" />
      <line stroke="rgb(10%,10%,16%)" x1="182.0" x2="163.333333333" y1="150.5" y2="150.5" />
      <text fill="red" text-anchor="start" x="182.0" y="150.5">mlg-lp</text>
      <line stroke="orange" x1="163.333333333" x2="128.073866667" y1="83.87" y2="83.87" />
      <line stroke="orange" x1="163.333333333" x2="163.333333333" y1="81.245" y2="86.495" />
      <line stroke="orange" x1="128.073866667" x2="128.073866667" y1="81.245" y2="86.495" />
      <line stroke="orange" x1="144.666666667" x2="123.926133333" y1="94.37" y2="94.37" />
      <line stroke="orange" x1="144.666666667" x2="144.666666667" y1="91.745" y2="96.995" />
      <line stroke="orange" x1="123.926133333" x2="123.926133333" y1="91.745" y2="96.995" />
      <line stroke="orange" x1="140.518933333" x2="70.0" y1="104.87" y2="104.87" />
      <line stroke="orange" x1="140.518933333" x2="140.518933333" y1="102.245" y2="107.495" />
      <line stroke="orange" x1="70.0" x2="70.0" y1="102.245" y2="107.495" />
      <text fill="orange" x="14" y="35.0">Critical distance 0.38272</text>
      <line stroke="orange" x1="14" x2="78.2973333333" y1="42" y2="42" />
      <line stroke="orange" x1="14" x2="14" y1="38.5" y2="45.5" />
      <line stroke="orange" x1="78.2973333333" x2="78.2973333333" y1="38.5" y2="45.5" />
      <line stroke="rgb(10%,10%,16%)" x1="14" x2="182.0" y1="78.62" y2="78.62" />
    </svg>

编辑:似乎inkscape没有修复,问题,但问题仍然有效,我可以使整个绘图区域可见吗?

0 个答案:

没有答案