I have code that I use to draw mechanical parts in which x & y axis must be the same scale and close cropped.
So I set the a.data_bounds, then set f.axes_size so the x:y ratio is the same as a.data_bounds.
The following function doesn’t work unless I set the f.axes_size twice. When I put this code directly in the calling code the results were the same.
What am I missing?
function tight_crop(f, x, y)
//[xmin,xmax,ymin,ymax]
f.children.data_bounds = [x, y];
dxy = round(diff(x) / diff(y) * f.axes_size(2));
//why does this double command work??????
f.axes_size(1) = dxy;
f.axes_size(1) = dxy;
endfunction
Thanks mottelet,
That does scale axes.data_bounds appropriately, but leaves the figure outline where it was.
I need to tight crop the figure around the object…
Afterwards I use xs2svg(f, ‘name.svg’), and then remove the white background of the svg file. That leaves just polylines and line segments with no background, which I can use in LibraOffice Draw combined with whatever is drawn in Draw