马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#practice 绘制折线图,分析从11-30岁,每年交男女朋友的数量走势,a=[1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
from matplotlib import pyplot as plt
from matplotlib import font_manager
import random
my_font=font_manager.FontProperties(fname="C:/WINDOWS/fonts/simhei.ttf")
x=range(11,31)
y=[1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
fig=plt.figure(figsize=(10,4),dpi=80)
plt.plot(x,y)
#想给x轴的刻度都写成**岁,尝试未果
_xtick_labels=["{}岁".format(list(x))]
plt.xticks(_xtick_labels,rotation=45,fontproperties=my_font)
plt.show()
道阻且长,打扰各位大佬了
# practice 绘制折线图,分析从11-30岁,每年交男女朋友的数量走势,a=[1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
from matplotlib import pyplot as plt
from matplotlib import font_manager
import random
my_font = font_manager.FontProperties(fname="C:/WINDOWS/fonts/simhei.ttf")
x = range(11, 31)
y = [1, 0, 1, 1, 2, 4, 3, 2, 3, 4, 4, 5, 6, 5, 4, 3, 3, 1, 1, 1]
fig = plt.figure(figsize=(10, 4), dpi=80)
plt.plot(x, y)
_xtick_labels = (f"{i}岁" for i in x)
plt.xticks(x, _xtick_labels, rotation=45, fontproperties=my_font)
plt.show()
|