Skip to content

SVG files saved with vector-effect:non-scaling-stroke XML option #1539

@eshort0401

Description

@eshort0401

When SVG figure files are saved using plotly.offline, the SVG image's XML code uses the style option vector-effect:non-scaling-stroke for lines associated with scatter traces, but not for graph axes or other lines. When importing these SVG files into vector graphic software packages like Inkscape, this option results in trace lines remaining the same width regardless of the level of zoom, making it difficult to ensure lines are of the desired width. Below is a command line MWE, and some images showing how the generated SVG behaves in Inkscape.

import numpy as np
import plotly
from plotly.offline import iplot
plotly.offline.init_notebook_mode()

trace = {
                'x' : np.arange(0,10),
                'y' : np.arange(0,10),
                'type' : 'scatter',
                'mode' : 'lines+markers',
                'marker' : {'size': 4,  'symbol' : 0},
                'name' : 'Minimal Working Example',
                'line' : {'width' : 1.5,},
         }

fig = {'data': [trace]}

plotly.offline.plot(
        fig,  filename = 'mwe.html', image='svg', output_type='file',
        image_filename = 'mwe', auto_open = False
    )

Screen Shot 2019-04-30 at 1 19 43 pm
Screen Shot 2019-04-30 at 1 20 37 pm

In Inkscape, the vector-effect:non-scaling-stroke option also prevents you from editing the widths of lines. One solution is to manually change the XML code to vector-effect:none to stop this behaviour, although this is extremely tedious for figures with many traces.

I suspect the overwhelming majority of users would prefer vector-effect:none for their SVG images. If not, perhaps an option could be created so that the user could choose. I've had a brief look at the plotly source and suspect this needs to be implemented in Orca. If this sounds like a good idea, I would love to attempt the change myself, but will probably need some guidance as to where to look in the Orca code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions