matplotlib中文乱码解决
2017-12-12 14:02
204 查看
下列程序在Python3.6下运行通过。
# -*- coding=utf-8 -*-
from matplotlib import font_manager
import matplotlib.pyplot as plt;
if __name__ == '__main__':
thread_num = [1, 3, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
throughput1 = [574.8695765, 878.0209408, 890.9727752, 892.219843, 890.1647918, 886.6329007, 884.769794, 882.6222708,
880.9602467, 877.2218384, 875.8964252, 875.2639468, 874.2978296]
throughput2 = [18.22837677, 52.29950462, 88.11752763, 161.328, 235.0830, 233.0830, 231.0830, 229.0830, 227.0830,
225.0830, 223.0830, 221.0830, 219.0830062]
# 指定字体为微软雅黑
zh_font = font_manager.FontProperties(fname=r'c:\windows\fonts\msyh.ttc', size=11)
# Plot the figure.
line, = plt.plot(thread_num, throughput1, color='cornflowerblue', linestyle='-', linewidth=3, marker='o', markersize=8,
label='大对象')
plt.plot(thread_num, throughput2, color='darkred', linestyle='-', marker='s', markersize=8, linewidth=3,
label='小对象')
plt.ylim(ymin=0)
plt.ylabel('平均吞吐率(Mbit/s)', fontproperties=zh_font)
plt.legend(loc=(0.78, 0.8), prop=zh_font)
plt.xlabel('线程数', fontproperties=zh_font)
plt.savefig('TestConcurrentPut10Mand10K.png')
plt.show()
# -*- coding=utf-8 -*-
from matplotlib import font_manager
import matplotlib.pyplot as plt;
if __name__ == '__main__':
thread_num = [1, 3, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
throughput1 = [574.8695765, 878.0209408, 890.9727752, 892.219843, 890.1647918, 886.6329007, 884.769794, 882.6222708,
880.9602467, 877.2218384, 875.8964252, 875.2639468, 874.2978296]
throughput2 = [18.22837677, 52.29950462, 88.11752763, 161.328, 235.0830, 233.0830, 231.0830, 229.0830, 227.0830,
225.0830, 223.0830, 221.0830, 219.0830062]
# 指定字体为微软雅黑
zh_font = font_manager.FontProperties(fname=r'c:\windows\fonts\msyh.ttc', size=11)
# Plot the figure.
line, = plt.plot(thread_num, throughput1, color='cornflowerblue', linestyle='-', linewidth=3, marker='o', markersize=8,
label='大对象')
plt.plot(thread_num, throughput2, color='darkred', linestyle='-', marker='s', markersize=8, linewidth=3,
label='小对象')
plt.ylim(ymin=0)
plt.ylabel('平均吞吐率(Mbit/s)', fontproperties=zh_font)
plt.legend(loc=(0.78, 0.8), prop=zh_font)
plt.xlabel('线程数', fontproperties=zh_font)
plt.savefig('TestConcurrentPut10Mand10K.png')
plt.show()
相关文章推荐
- matplotlib中文乱码解决方法
- 西瓜书 习题4.3 编程实现信息熵决策树、绘制决策树、解决matplotlib中文乱码问题
- matplotlib 与 seaborn 中出现中文乱码的解决方法
- 解决matplotlib绘图中显示中文乱码的问题
- 解决matplotlib中文乱码问题(Windows)
- Matplotlib中文乱码解决办法
- matplotlib画图中文乱码的解决办法
- matplotlib解决中文乱码问题
- 解决matplotlib中文乱码问题
- Python 3下Matplotlib画图中文显示乱码的解决方法
- 解决matplotlib中文乱码问题
- 解决matplotlib中文乱码问题
- python matplotlib中文显示乱码解决
- 彻底解决matplotlib中文乱码问题
- 彻底解决matplotlib中文乱码问题(转)
- Mac系统彻底解决matplotlib中文显示乱码的问题
- 彻底解决matplotlib中文乱码问题
- matplotlib解决中文乱码问题
- 解决matplotlib中文乱码问题(Ubuntu16.04)
- 在matplotlib中,解决中文乱码问题