Allow setting margins individually in set_margins()
This commit is contained in:
parent
81ba2604ac
commit
a8e2ec73a5
16
lib/plot.py
16
lib/plot.py
|
@ -16,8 +16,8 @@ class Paper:
|
||||||
}
|
}
|
||||||
self.set_margins(margins)
|
self.set_margins(margins)
|
||||||
|
|
||||||
|
def set_margins(self, margins=None, top=None, right=None, bottom=None,
|
||||||
def set_margins(self, margins):
|
left=None):
|
||||||
if isinstance(margins, int) or isinstance(margins, float):
|
if isinstance(margins, int) or isinstance(margins, float):
|
||||||
self.margins['top'] = margins
|
self.margins['top'] = margins
|
||||||
self.margins['right'] = margins
|
self.margins['right'] = margins
|
||||||
|
@ -40,9 +40,18 @@ class Paper:
|
||||||
self.margins['right'] = margins[1]
|
self.margins['right'] = margins[1]
|
||||||
self.margins['bottom'] = margins[2]
|
self.margins['bottom'] = margins[2]
|
||||||
self.margins['left'] = margins[3]
|
self.margins['left'] = margins[3]
|
||||||
else:
|
elif margins is not None:
|
||||||
self.margins = margins
|
self.margins = margins
|
||||||
|
|
||||||
|
if top is not None:
|
||||||
|
self.margins['top'] = top
|
||||||
|
if right is not None:
|
||||||
|
self.margins['right'] = right
|
||||||
|
if bottom is not None:
|
||||||
|
self.margins['bottom'] = bottom
|
||||||
|
if left is not None:
|
||||||
|
self.margins['left'] = left
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def content_width(self):
|
def content_width(self):
|
||||||
return self.width - self.margins['left'] - self.margins['right']
|
return self.width - self.margins['left'] - self.margins['right']
|
||||||
|
@ -126,7 +135,6 @@ A6_PORTRAIT = Paper(105, 148, 8)
|
||||||
A6_LANDSCAPE = Paper(148, 105, 8)
|
A6_LANDSCAPE = Paper(148, 105, 8)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Plotter:
|
class Plotter:
|
||||||
|
|
||||||
def __init__(self, paper, line_width=0, colour=[0, 0, 0, 1]):
|
def __init__(self, paper, line_width=0, colour=[0, 0, 0, 1]):
|
||||||
|
|
Loading…
Reference in a new issue