Mathematica Asked on December 7, 2021
Please run this in the Cloud:
StringJoin[
ExportString[{},"SVG"]
, "<br>"
, ExportString[Plot[Sin[x],{x,0,6}],"SVG"]
]//EmbeddedHTML
Notice that x-axis 1 and 2 ticks were replaced with {}.
That is because they they are referenced within svg with e.g.:
<use xlink:href="#glyph0-2" x="130.22449" y="118.975691"></use>
and this glyph0-2
id is defined in <defs>
for both svgs. Since ids are supposed to be unique only the very first one found is used in both images.
How to deal with this?
Do not know how general it is but works for me atm:
UniqueSVGExport[expr_]:= Module[{uniqueRef}
, uniqueRef[s_String]:=uniqueRef[s] = CreateUUID[s]
; ExportString[expr, "SVG"] //
StringReplace[
g : ("glyph" ~~ DigitCharacter .. ~~ "-" ~~ DigitCharacter ..) :> uniqueRef@g
]
]
Answered by Kuba on December 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP