forked from luigifreda/pyslam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mplot_figure.py
48 lines (42 loc) · 1.7 KB
/
mplot_figure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
* This file is part of PYSLAM
*
* Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com>
*
* PYSLAM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PYSLAM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PYSLAM. If not, see <http://www.gnu.org/licenses/>.
"""
import time
import numpy as np
import math
import matplotlib.pyplot as plt
# refer to https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure
class MPlotFigure:
def __init__(self, img, title=None, scale=1, dpi=100):
self.dpi = dpi
self.width = round(img.shape[0]*scale/dpi)
self.height = round(img.shape[1]*scale/dpi)
#self.fig = plt.figure(dpi=self.dpi, figsize=(self.height,self.width), tight_layout=True, frameon=False)
self.fig = plt.figure(dpi=self.dpi, tight_layout=True, frameon=False)
if title is not None:
self.fig.suptitle(title)
plt.imshow(img)
plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis
# actually show the figures
@staticmethod
def show():
plt.show()
# make it full screen
def full_screen(self):
figManager = plt.get_current_fig_manager()
figManager.full_screen_toggle()