The Stack Overflow podcast is back! Listen to an interview with our new CEO.
22

Animations as interactive visualizations The simplest form of interactive graphics is an animation in which the play head can be moved by the user. That doesn't sound very interactive, but in terms of functionality the play head is nothing but a type of Slider. With this simple interpretation of interactivity, any movie format supported by Export would be ...


15

Yes, you can indeed convert the output to a graphics object before exporting it. I wrote a function for that in this answer, and it works with SVG too: outlinedExport[name_, gr_, opts : OptionsPattern[]] := Export[name, First@ImportString[ExportString[gr, "PDF"], "PDF", "TextMode" -> "Outlines"], opts] res = Solve[x^2 + a x + 1 == 0, x] $\...


8

The short answer is no, there is no straightforward (built-in) way to convert Mathematica's dynamic objects to non-proprietary HTML+SVG/JS. To see why, consider how you might try ti represent the following very simple example in HMTL/SVG? Manipulate[With[{pts = {#, Sin[a*#]} & /@ (x /. Quiet[Solve[Sin[a*x] == b*AiryAi[-x] && 0 < x < 10, ...


8

This is the reply from Wolfram Research Technical Support [CASE:631799]: After consultation with a developer, there is nothing really that can be done with the Export function directly in terms of simplifying the group structure of SVG files. You may be able to develop some system by programmatically parsing the file down, but this would likely not ...


8

In principle, this all is not difficult but there are some obstacles in the way that will make life hard: In a 2d projection of a 3d polygon graphics, many of the polygons are not visible since they are optically behind others. In the general case, it is at least a partially complex task to remove those that are completely hidden. If you leave all polygons ...


7

Under Windows, this can be done with NETLink by modifying code published here. Needs["NETLink`"] WriteToClipboardSVG[g_] := Module[{png, strm, dataObject}, InstallNET[]; png = ExportString[g, "SVG"]; NETBlock[ strm = NETNew["System.IO.MemoryStream", ToCharacterCode[png]]; dataObject = NETNew["System.Windows.Forms.DataObject"]; dataObject@...


7

This problem is known and I had a lengthy discussion with one of the developers of Inkscape about this some years ago. Basically, it is a problem of the renderer (aka your browser) and is connected to alpha-blending that happens when you have polygons that share an edge. Additionally, this problem was described in several other posts. See here and here for ...


6

After some experimentation, I discovered that the issue preventing svgExport from working was that string replacements which add attributes caused multiple copies of the width and height attributes to be inserted. To avoid that, I rewrote it to use rule replacements on the symbolic representation of the XML instead of string replacement. The result is rather ...


6

For the benefit of those who come across this old question, I have recently written a small open-source library called MathCell that replicates the behavior of Mathematica's Manipulate using pure JavaScript. Documentation is available here. The library is not for converting Mathematica code, but is meant as a replacement for people who want to embed ...


6

Although I do see a difference between the contents of bad.svg when I export with version 8.0.4 and 9.0.1, the svg is displayed in exactly the same way by Google Chrome. The display does indeed show a white background in Safari, though, when exported from Mathematica 8.0.4 on OS X. So we could now argue whether this is the fault of the browser, or the fault ...


5

Here is another hack that I learned from this answer (this means, go and vote for it!). We can use a different rendering for different parts of SVG. To include this in into the SVG created by Mathematica, we need to improvise and this should probably be done on the XML structure and not by replacing strings. For my answer, I won't go through this. What we ...


5

First, let me tell you that following your code my output is quite different. g=Graphics[{Disk[{-1,0},1/2],Rectangle[]}]; ExportString[g,"SVG"] Output <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="361pt" height="223pt" viewBox="0 0 361 223" version="1.1"> <g ...


5

Same problem for me (mma v11.2.0, OSX). Here is a workaround which seems to work for me: ExportString[YOURARRAY, "SVG"] // StringReplace[#, {"stroke-width:0.03" -> "stroke-width:0."}] & // Export["reparray.svg", #, "Text"] & After investigating a little bit, it seems that mma produces by default an extra mesh, different from the one you would ...


4

You can remove the numbers using FrameTicks -> None g = StreamPlot[{-x, y}, {x, -3, 3}, {y, -3, 3}, FrameTicks -> None] Export["stream.svg", g] But your problem seems to be that the numbers are oversized. UPDATE The question was edited. Unfortunately I can't reproduce the problem in Mathematica 11.1.1. I suggest you have a play with the fonts. g ...


3

I just answered a related question where I posted an SVG export function that fixes the scaling problems. At least that's what I conclude from the following tests: First load the definitions for svgExport from the answer linked here. Create a plot and export it like this: p = Plot[Sin[x], {x, 0, 2 Pi}]; svgExport["plot.svg", p, AspectRatio -> Full] ...


2

This is not supposed to happen, but indeed the SVG output is rasterized. It happens when you use DensityPlot, but not with ContourPlot (in version 8 at least). So I think this is a bug. To keep the axes as vector graphics, I would suggest my answer here as a work-around.


2

(Outputs here are for Mathematica 11.1.0.) You are exporting a circular object with equal width and height but specify larger width than the height via the ImageSize -> {200, 100} option. Hence some margins are added from the left and the right, but the height is kept as you specified (height="99pt" corresponds to the height 100 pts). With automatic ...


2

Mathematica does not put information about width and height into <svg> tag, but the first group contains a filled rectangle (<rect fill ...>) that does have width and height. You may extract width and height attributes from that <rect> and assign them to the root <svg> element.


2

This can be a starting point: vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 1}, {1, 0, 1}, {1,...


1

From the documentation page onSVG: Note that the last bullet point says the format is intended two-dimensional graphics.


1

We're getting closer. In Mathematica 12, there are now more filling rules available. The documentation of the new function WindingPolygon lists the following: The first star in the question (the one with the minimum number of edges), can now be shown without holes using WindingPolygon: Graphics[{Thickness[ 0.001388888888888889], {EdgeForm[{Blue, Opacity[...


Only top voted, non community-wiki answers of a minimum length are eligible