本文整理汇总了Python中matplotlib.pyplot.box方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.box方法的具体用法?Python pyplot.box怎么用?Python pyplot.box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.box方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot1DGrid
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import box [as 别名]
def plot1DGrid(scores, paramsToPlot, scoreLabel, vrange):
"""
Makes a line plot of scores, over the parameter to plot
:param scores: A list of scores, estimated using scoreModels
:param paramsToPlot: The parameter to plot, chosen automatically by plotScores
:param scoreLabel: The specified score label (dependent on scoring metric used)
:param vrange: The yrange of the plot
"""
key = list(paramsToPlot.keys())
plt.figure(figsize=(int(round(len(paramsToPlot[key[0]]) / 1.33)), 6))
plt.plot(np.linspace(0, len(paramsToPlot[key[0]]), len(scores)), scores, "-or")
plt.xlabel(key[0])
plt.xticks(np.linspace(0, len(paramsToPlot[key[0]]), len(scores)), paramsToPlot[key[0]])
if scoreLabel is not None:
plt.ylabel(scoreLabel)
else:
plt.ylabel("Score")
if vrange is not None:
plt.ylim(vrange[0], vrange[1])
plt.box(on=False)
plt.show()
示例2: test_pyplot_box
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import box [as 别名]
def test_pyplot_box():
fig, ax = plt.subplots()
plt.box(False)
assert not ax.get_frame_on()
plt.box(True)
assert ax.get_frame_on()
plt.box()
assert not ax.get_frame_on()
plt.box()
assert ax.get_frame_on()
示例3: plot2DGrid
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import box [as 别名]
def plot2DGrid(scores, paramsToPlot, keysToPlot, scoreLabel, greater_is_better, vrange, cmap):
"""
Plots a heatmap of scores, over the paramsToPlot
:param scores: A list of scores, estimated using parallelizeScore
:param paramsToPlot: The parameters to plot, chosen automatically by plotScores
:param scoreLabel: The specified score label (dependent on scoring metric used)
:param greater_is_better: Choice between optimizing for greater scores or lesser scores
Used to make better scores darker on colormap
Default True means greater and False means lesser
:param vrange: The visible range of the heatmap (range you wish the heatmap to be specified over)
:param cmap: The chosen colormap for 2D and 3D plotting. Default is YlOrRd
"""
scoreGrid = np.reshape(scores, (len(paramsToPlot[keysToPlot[0]]), len(paramsToPlot[keysToPlot[1]])))
plt.figure(
figsize=(
int(round(len(paramsToPlot[keysToPlot[1]]) / 1.33)),
int(round(len(paramsToPlot[keysToPlot[0]]) / 1.33)),
)
)
if not greater_is_better:
if cmap.endswith("_r"):
cmap = cmap[:-2]
else:
cmap = cmap + "_r"
if vrange is not None:
plt.imshow(scoreGrid, cmap=cmap, vmin=vrange[0], vmax=vrange[1])
else:
plt.imshow(scoreGrid, cmap=cmap)
plt.xlabel(keysToPlot[1])
plt.xticks(np.arange(len(paramsToPlot[keysToPlot[1]])), paramsToPlot[keysToPlot[1]])
plt.ylabel(keysToPlot[0])
plt.yticks(np.arange(len(paramsToPlot[keysToPlot[0]])), paramsToPlot[keysToPlot[0]])
if scoreLabel is not None:
plt.title(scoreLabel)
else:
plt.title("Score")
plt.colorbar()
plt.box(on=False)
plt.show()