Scaling SVG files


Consult the reference manual and tutorials for more details and worked examples.
W.G.Bardsley, University of Manchester, U.K.

Aspect Ratios

The aspect ratio of a rectangular graph is the dimensionless ratio of the lengths of the adjacent sides. This can be discussed as either a x:y or a y:x aspect ratio. Most scientific graphs are either landscape (y:x = 3:4), portrait (y:x = 4:3), or square (y:x) = 1), and Simfit uses landscape as the default, but also supports portrait and square as well as flat (y:x = 1:2) or vertical (y:x = 2:1). Hardcopy is usually in one of these formats or a similar aspect ratio when it is intended for inclusion in documents, but in the situation of graphs prepared for presentation or the internet much greater flexibility is possible and often desirable.

For instance, increasing the physical length of the X-axis is often useful with dendrograms or bar charts where text added to label the items has become crushed or is even overlapping, or with the sort of ribbon graphs that are used to illustrate time series such as climate-change results. Again, increasing the length of the Y-axis can be beneficial when creating forest plots or similar tower plots to display meta-analysis findings where providing increased vertical spacing allows clearer presentation of results.

It might be thought that this operation is easy to perform with standard software that mostly allows users to specify precise dimensions or aspect ratios, but this is mistaken. To see this, consider the effect of such re-scaling on bitmaps and vector graphs.

Re-scaling bitmaps

Raw bitmaps available either as computer screen dumps or from digital cameras are simply rectangular arrays of pixel instructions concerning colour and brightness. They are invaluable for graphs with dense information such as gradations in skin tone. However, although they can be cropped to any aspect ratio, they are of little use for scientific purposes as they are very large and cannot be expanded or reduced without loss of information. If they are re-scaled to alternative aspect ratios this leads to deformed characters or plotting symbols and there is the additional problem that the anti-aliasing that has been embedded in the bitmap to smooth out curves causes fuzzy graphs when they are either compressed or expanded. The same criticism applies to bitmaps that have been compressed into *.JPG or *.PNG format. Consequently Simfit provides no facilities to change the aspect ratio of such files.

Re-scaling vector graphs

The vector graph files in *.EPS or *.SVG format created by Simfit only contain the information needed to display lines, curves, symbols, or text strings. In addition they contain no anti-aliasing information as that is added by the engine that rasterises them for printing or visual display. Accordingly they are truly device-independent and can thererfore be displayed at any resolution with no loss of information. Furthermore, they can be re-scaled by Simfit in such a way as to merely increase the white space between symbols and text strings without distortion.

Re-scaling SVG graphs

Simfit provides the functionality to create SVG hardcopy with the same aspect ratio as displayed on the monitor or to experiment with various X-scaling or Y-scaling transformations to stretch the graph horizontally or vertically to any aspect ratio. This procedure is not available in simple or 3D graphics but only from the advanced graphics interface by pressing the [SVG] button.

There are two scaling factors that are intially set to the default values of 1, i.e., no re-scaling. However there four things that must be kept in mind when using the SVG re-scaling procedure.

  1. There are only two scaling factors (X_SVG and Y_SVG) where these can be varied either singly or both at the same time. However, the default value is 1, and the factors cannot be made smaller than 1. Normally only values in the range say 1 to 3 are required, and scaling to much larger values can alter the relative positions of some graphical objects, such as text strings in titles, legends, or labels.
    As SVG files can be displayed or printed at any size or resolution this imposes no retriction on the final aspect rato required after re-scaling.

  2. On entry to advanced graphics both X_SVG and Y_SVG will be set to default values of 1, and on exit from advanced graphics both X_SVG and Y_SVG will be restored to default values of 1.
    This means that if re-scaling is to be done interactively to obtain the desired effect, you will have to remember the new values in order to leave advanced graphics and resume editing.

  3. If it is intended to resume editing after exiting advanced graphics, you can archive the displayed un-scaled graph as a Simfit metafile so you can resume editing by reading in the metafile instead of the original data for plotting.

  4. The program DisplaySvg that is used to allow viewing of the re-scaled SVG graphs can also create *.PNG hardcopy on request.

How to re-scale SVG graphs

This requires four steps.

  1. Compose the graph in 2D advanced graphics

  2. Press [SVG] and view the current graph as SVG

  3. Change the value of X_SVG and/or Y_SVG and view again

  4. When a satisfactory re-scaling has been achieved save the graph as a *.SVG file

On returning to normal 2D advanced graphics the plot will be displayed in the unscaled form, as the scaling is only done for SVG formatting. SVG files created in this way can be viewed directly in your browser by input of the file name instead of a URL.

Back to Help Menu or End Help