首页 > 技术文章 > python绘图问题

chulin 2019-03-12 14:39 原文

论文绘图整理

# coding: utf-8

#来源:https://blog.csdn.net/A_Z666666/article/details/81165123


import matplotlib.pyplot as plt

# figsize = 11, 9
# figure, ax = plt.subplots(figsize = figsize)
x1 =[0,5000,10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000]
y1=[0, 223, 488, 673, 870, 1027, 1193, 1407, 1609, 1791, 2113, 2388]
x2 = [0, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000]
y2 = [0, 214, 445, 627, 800, 956, 1090, 1281, 1489, 1625, 1896, 2151]

# 设置输出的图片大小
figsize = 11, 9
figure, ax = plt.subplots(figsize=figsize)

# 在同一幅图片上画两条折线
A, = plt.plot(x1, y1, '-r', label='A', linewidth=5.0)
B, = plt.plot(x2, y2, 'b-.', label='B', linewidth=5.0)

# 设置图例并且设置图例的字体及大小
font1 = {'family': 'Times New Roman',
         'weight': 'normal',
         'size': 23,
         }
legend = plt.legend(handles=[A, B], prop=font1)

# 设置坐标刻度值的大小以及刻度值的字体
plt.tick_params(labelsize=23)
labels = ax.get_xticklabels() + ax.get_yticklabels()
# print labels
[label.set_fontname('Times New Roman') for label in labels]
# 设置横纵坐标的名称以及对应字体格式
font2 = {'family': 'Times New Roman',
         'weight': 'normal',
         'size': 30,
         }
plt.xlabel('round', font2)
plt.ylabel('value', font2)
plt.show()

 

 

、、、、、、、、、、、、、、、、、

关于图片的长宽比设定

plt.figure(figsize=[16,8])                                             #这个是图片的长宽比。

 

、、、、、、、、、、、、、、、、

 

关于坐标调整

 

 

、、、、、、、、、、、、、、、、

import matplotlib.pyplot as plt

x1 = [1, 2, 3]

y1 = [1, 4, 9]

x2 = [1, 2, 3]

y2 = [5, 6, 7]

plt.plot(x1, y1, label='y=x*x')

plt.plot(x2, y2, label='y=x+4')

plt.xlabel('input number')

plt.ylabel('ouput number')

plt.title('测试某些函数')

plt.legend()

plt.show()
---------------------
作者:xjl271314
来源:CSDN
原文:https://blog.csdn.net/xjl271314/article/details/80291284
版权声明:本文为博主原创文章,转载请附上博文链接!

 

 

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

关于图例的设置

https://blog.csdn.net/u012735708/article/details/82114565   里面有很好的信息。

plt.legend(bbox_to_anchor=(1., 1.02, 1., .102),ncol=6,loc=1,prop=font1)  # 让图例生效  【这个应当添加上内容才是,】ncol代表了图例的列数

https://blog.csdn.net/u010358304/article/details/78906768#在同一幅图片上画两条折线
A,=plt.plot(x1,y1,'-r',label='A',linewidth=5.0)
B,=plt.plot(x2,y2,'b-.',label='B',linewidth=5.0)
 
#设置图例并且设置图例的字体及大小
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 23,
}
legend = plt.legend(handles=[A,B],prop=font1)
---------------------
作者:CAM-TAY
来源:CSDN
原文:https://blog.csdn.net/u010358304/article/details/78906768
版权声明:本文为博主原创文章

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

http://www.cnblogs.com/awishfullyway/p/6124668.html  问题汇总

推荐阅读