'''
Created on 2023年4月9日
@author: admin
'''
import numpy as np
import matplotlib.pyplot as plt
n = 20
X = np.ones(n)
X[-1] *= 2
plt.pie(X, explode=X*.05, colors = ['%f' % (i/float(n)) for i in range(n)])
fig = plt.gcf()
w, h = fig.get_figwidth(), fig.get_figheight()
r = h / float(w)
plt.xlim(-1.5, 1.5)
plt.ylim(-1.5 * r, 1.5 * r)
plt.xticks([])
plt.yticks([])
from matplotlib.patches import FancyBboxPatch
ax = plt.gca()
ax.add_patch(FancyBboxPatch((-0.05, .87),
width=.66, height=.165, clip_on=False,
boxstyle="square,pad=0", zorder=3,
facecolor='white', alpha=1.0,
transform=plt.gca().transAxes))
FancyBboxPatch主要是实现一个框形区域,后面专门讲这个例子
FancyBboxPatch 类似于 Rectangle ,但它在矩形周围画了一个漂亮的方框。矩形框到花式框的转换委托给中定义的样式类 BoxStyle .
参数: | xy浮起,浮起 框的左下角。 width浮动 盒子的宽度。 height浮动 盒子的高度。 箱型 STR或 matplotlib.patches.BoxStylestr或
mutation_scale浮点,默认值:1 应用于填充样式的缩放因子。 mutation_aspect可选浮动 在变异之前,矩形的高度将被该值压缩,并且变异的长方体将被它的倒数拉伸。例如,这允许不同的水平和垂直填充。 |
plt.text(-0.05, 1.02, " Pie Chart: plt.pie(...)
",
horizontalalignment='left',
verticalalignment='top',
size='xx-large',
transform=plt.gca().transAxes)
plt.text(-0.05, 1.01, "
Make a pie chart of an array ",
horizontalalignment='left',
verticalalignment='top',
size='large',
transform=plt.gca().transAxes)
'''
Created on 2023年4月9日
@author: admin
'''
import numpy as np
import matplotlib.pyplot as plt
n = 20
X = np.ones(n)
X[-1] *= 2
plt.pie(X, explode=X*.05, colors = ['%f' % (i/float(n)) for i in range(n)])
fig = plt.gcf()
w, h = fig.get_figwidth(), fig.get_figheight()
r = h / float(w)
plt.xlim(-1.5, 1.5)
plt.ylim(-1.5 * r, 1.5 * r)
plt.xticks([])
plt.yticks([])
# Add a title and a box around it
from matplotlib.patches import FancyBboxPatch
ax = plt.gca()
ax.add_patch(FancyBboxPatch((-0.05, .87),
width=.66, height=.165, clip_on=False,
boxstyle="square,pad=0", zorder=3,
facecolor='white', alpha=1.0,
transform=plt.gca().transAxes))
#
plt.text(-0.05, 1.02, " Pie Chart: plt.pie(...)
",
horizontalalignment='left',
verticalalignment='top',
size='xx-large',
transform=plt.gca().transAxes)
plt.text(-0.05, 1.01, "
Make a pie chart of an array ",
horizontalalignment='left',
verticalalignment='top',
size='large',
transform=plt.gca().transAxes)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
n = 20
X = np.ones(n)
X[-1] *= 2
plt.pie(X, explode=X*.05, colors = ['%f' % (i/float(n)) for i in range(n)])
fig = plt.gcf()
w, h = fig.get_figwidth(), fig.get_figheight()
r = h / float(w)
plt.xlim(-1.5, 1.5)
plt.ylim(-1.5 * r, 1.5 * r)
plt.xticks([])
plt.yticks([])
# Add a title and a box around it
from matplotlib.patches import FancyBboxPatch
ax = plt.gca()
ax.add_patch(FancyBboxPatch((-0.05, .87),
width=.66, height=.165, clip_on=False,
boxstyle="square,pad=0", zorder=3,
facecolor='white', alpha=1.0,
transform=plt.gca().transAxes))
plt.text(-0.05, 1.02, " Pie Chart: plt.pie(...)
",
horizontalalignment='left',
verticalalignment='top',
size='xx-large',
transform=plt.gca().transAxes)
plt.text(-0.05, 1.01, "
Make a pie chart of an array ",
horizontalalignment='left',
verticalalignment='top',
size='large',
transform=plt.gca().transAxes)
plt.show()
页面更新:2024-03-12
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号