本文整理匯總了Python中matplotlib.pyplot.get_backend方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.get_backend方法的具體用法?Python pyplot.get_backend怎麽用?Python pyplot.get_backend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.get_backend方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_revert
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def test_revert():
with patch('matplotlib.rcParams.update') as mock_update, \
patch('matplotlib.pyplot.switch_backend') as mock_switch:
lp.latexify()
lp.revert()
mock_update.assert_called_with(dict(plt.rcParams))
mock_switch.assert_called_with(plt.get_backend())
示例2: find_gui
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def find_gui():
""" Quick fix to check if matplotlib is running in a GUI environment.
Returns
-------
bool: Boolean
True if it's a GUI environment, False if not.
"""
try:
import matplotlib.pyplot as plt
except:
return False
if plt.get_backend() == 'Agg':
return False
return True
示例3: __init__
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def __init__(self, xdata = [0], ydata = [0], zdata = [0], smoothness = 0.1):
"""
Inits CurveXtractor with xdata, ydata, zdata and smoothness of the splines.
Args:
xdata: xaxis data
ydata: yaxis data
zdata: 2d matix of zdata
smoothness: smoothness of the spline (can also be changed later on in the procedure).
"""
if plt.get_backend().find("nbagg") == -1:
print("Module requires using the widget backend for matplotlib.\nActivate with %matplotlib widget.")
return
self.xvals = 0
self.yvals = 0
self.zvals = 0
self._smoothness = smoothness
self._status = True
self._infotxt = 0
self._points_x = []
self._points_y = []
self._curve_x = []
self._curve_y = []
self._x_results = []
self._y_results = []
self._col = ["w", "C1", "C3", "C6", "C8"]
self._pointplots = [[]]
self._curveplots = []
self._result_plots = []
self._xlim = (min(xdata), max(xdata))
self._ylim = (min(ydata), max(ydata))
self._splines = []
示例4: plot_alignment_errors
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def plot_alignment_errors(errors_position, rmse_pose, errors_orientation,
rmse_orientation, blocking=True):
assert np.array_equal(errors_position.shape, errors_orientation.shape)
num_error_values = errors_position.shape[0]
title_position = 1.05
fig = plt.figure()
a1 = fig.add_subplot(2, 1, 1)
fig.suptitle("Alignment Evaluation", fontsize='24')
a1.set_title(
"Red = Position Error Norm [m] - Black = RMSE", y=title_position)
plt.plot(errors_position, c='r')
plt.plot(rmse_pose * np.ones((num_error_values, 1)), c='k')
a2 = fig.add_subplot(2, 1, 2)
a2.set_title(
"Red = Absolute Orientation Error [Degrees] - Black = RMSE", y=title_position)
plt.plot(errors_orientation, c='r')
plt.plot(rmse_orientation * np.ones((num_error_values, 1)), c='k')
if plt.get_backend() == 'TkAgg':
mng = plt.get_current_fig_manager()
max_size = mng.window.maxsize()
max_size = (max_size[0], max_size[1] * 0.45)
mng.resize(*max_size)
fig.tight_layout()
plt.subplots_adjust(left=0.025, right=0.975, top=0.8, bottom=0.05)
plt.show(block=blocking)
示例5: start_jobs
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def start_jobs():
"""
Restores the plots if requested and if the persistent files exist and
starts the qt timer of the 1st plot.
"""
for plot in _plots:
if plot.persistentName:
plot.restore_plots()
plot.fig.canvas.set_window_title(plot.title)
runCardVals.iteration = np.long(0)
noTimer = len(_plots) == 0 or\
(plt.get_backend().lower() in (x.lower() for x in
mpl.rcsetup.non_interactive_bk))
if noTimer:
print("The job is running... ")
while True:
msg = '{0} of {1}'.format(
runCardVals.iteration+1, runCardVals.repeats)
if os.name == 'posix':
sys.stdout.write("\r\x1b[K " + msg)
else:
sys.stdout.write("\r ")
print(msg+' ')
sys.stdout.flush()
res = dispatch_jobs()
if res:
return
else:
plot = _plots[0]
plot.areProcessAlreadyRunning = False
plot.timer = plot.fig.canvas.new_timer()
plot.timer.add_callback(plot.timer_callback)
plot.timer.start()
示例6: load_nb
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def load_nb(cls, inline=True):
"""
Initialize matplotlib backend
"""
import matplotlib.pyplot as plt
backend = plt.get_backend()
if backend not in ['agg', 'module://ipykernel.pylab.backend_inline']:
plt.switch_backend('agg')
示例7: test_pyplot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def test_pyplot():
backend = plt.get_backend()
plt.switch_backend("agg")
x = y = [0, 1, 2]
plt.plot(x, y)
plt.switch_backend(backend)
img = imgviz.io.pyplot_to_numpy()
assert isinstance(img, np.ndarray)
assert img.ndim == 3
示例8: plot_trajectory
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import get_backend [as 別名]
def plot_trajectory(
transforms, is_relative=False, mode="xz", style="b.", axis=True,
):
"""Plot the trajectory using transform matrices
Parameters
----------
transforms: numpy.ndarray
transform matrices with the shape of [N, 4, 4]
where N is the # of poses.
is_relative: bool
True for relative poses. default: False.
mode: str
x and y axis of trajectory. default: 'xz' following kitti format.
style: str
style of ploting, default: 'b.'
axis: bool
False to disable axis.
Returns
-------
dst: numpy.ndarray
trajectory
"""
import matplotlib.pyplot as plt
if is_relative:
for i in range(1, len(transforms)):
transforms[i] = transforms[i - 1].dot(transforms[i])
if len(mode) != 2 and all(x in "xyz" for x in mode):
raise ValueError("Unsupported mode: {}".format(mode))
x = []
y = []
index_x = "xyz".index(mode[0])
index_y = "xyz".index(mode[1])
for T in transforms:
translate = tf.translation_from_matrix(T)
x.append(translate[index_x])
y.append(translate[index_y])
# swith backend to agg for supporting no display mode
backend = plt.get_backend()
plt.switch_backend("agg")
plt.plot(x, y, style)
if not axis:
plt.axis("off")
dst = pyplot_to_numpy()
plt.close()
# switch back backend
plt.switch_backend(backend)
return dst