本文整理匯總了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()