MortCanty
MortCanty

Reputation: 417

How can one change the size of SVGFIG plots

I'm using the Python SVG wrapper SVGFIG. Here's a code snippet:

dots = zip(x,y)
dots = svgfig.Dots(dots,0.4,0.4)  
line = svgfig.Line(0,cs[i,1],250,cs[i,1]+cs[i,0]*250,stroke_width="0.25pt")   
text = svgfig.Text(200,20,'Band'+str(i+1))       
sp = svgfig.Plot(0,250,0,250,dots,line,text,x=15,y=10)  

The default canvas size for 2-D graphics is 400x400 pixels. The reference page indicates that I can change this with, for example:

svgfig.canvas_defaults["width"] = "300px"

but the Python interpreter tells me that the canvas_defaults property doesn't exist.

Upvotes: 0

Views: 548

Answers (1)

DSM
DSM

Reputation: 353449

It looks like it's _canvas_defaults, not canvas_defaults:

>>> svgfig._canvas_defaults

{'font-family': ['Helvetica',
                 'Arial',
                 'FreeSans',
                 'Sans',
                 'sans',
                 'sans-serif'],
 'height': '400px',
 'style': {'fill': 'none',
           'stroke': 'black',
           'stroke-linejoin': 'round',
           'stroke-width': '0.5pt',
           'text-anchor': 'middle'},
 'version': '1.1',
 'viewBox': '0 0 100 100',
 'width': '400px',
 'xmlns': 'http://www.w3.org/2000/svg',
 'xmlns:xlink': 'http://www.w3.org/1999/xlink'}

(Showing my work: I downloaded and installed svgfig, looked at the source for svgfig.canvas using ipython's "svgfig.canvas??" syntax and saw the line attributes = dict(_canvas_defaults).)

Upvotes: 3

Related Questions