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]
(* ==> "plot.svg" *)
Create a HTML
file that embeds the SVG
as shown:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SVG scaling</title>
</head>
<body>
<h1>SVG scaling</h1>
<object style="width:400px;height:400px;" data="plot.svg" type="image/svg+xml"></object>
</body>
</html>
The page displays as follows in a browser:

The scaling is completely determined by the width
and height
values in the <object>
tag. If you leave out the AspectRatio
option in svgExport
, the overall scaling still works based on the <object>
settings, but the aspect ratio of the graphics is always preserved so that there will be additional white space.
height:100%; width:100%
. $\endgroup$