python画图,x和y轴取对数之后的散点图:
import numpy as np import matplotlib.pyplot as plt XY = [[9950,1360,504,1,145,102,75,56,38,26,21,24,24,15,12,8,11,8,13,4,7,5,7,8,3,1,2,5,4,2,1,2,2,3,4,3,1,3,1,3,1,1,2,1,1,1,1,1,2,1,1,1,4,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,211,2,1,1,1,2,1,1,1,9,1,1,2,3,1,1,1,1,1,1,1], [0,1,2,299,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,281,26,27,28,29,30,31,33,34,35,37,38,39,40,41,42,43,45,46,47,48,49,50,52,56,61,62,63,64,65,66,68,70,71,73,588,77,79,82,85,86,87,88,92,95,3,98,111,376,377,123,380,137,144,25,152,165,177,196,76,204,717,293,3552,483,746], [9082,1655,691,1,208,144,86,81,57,39,46,27,27,26,16,3,15,12,13,12,12,8,6,12,9,5,5,3,5,6,2,3,2,4,2,5,1,5,5,3,1,1,2,4,2,1,1,1,1,3,1,1,2,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,13,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,4,1,316,1,1,1], [0,1,2,259,4,5,6,7,8,9,10,11,12,13,14,45,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,292,37,38,39,40,41,42,43,44,434,46,47,48,51,52,53,54,55,56,58,59,64,65,68,69,71,75,76,82,227,85,86,87,90,15,93,96,97,98,101,103,107,374,376,121,122,380,126,132,133,143,178,286,190,200,716,36,224,3,483,228,83]] fig=plt.figure(figsize=(8, 3.2)) plt.subplot(1, 2, 1) ax = plt.gca() plt.loglog(XY[1], XY[0],linestyle='None',marker='.',markersize=8,c='b') plt.grid(linestyle='-.', linewidth=0.75, which='major',axis='both') # plt.title('loglog base 2 on x', fontsize=14) #Toy anomaly detection dataset plt.xlabel('Occurrences of A Word as Start Word',fontsize=14) plt.ylabel('Number of Words',fontsize=14) plt.xticks(fontsize=14) plt.yticks(fontsize=14) plt.subplot(1, 2, 2) plt.loglog(XY[3], XY[2],linestyle='None',marker='.',markersize=8,c='b') plt.grid(linestyle='-.', linewidth=0.75, which='major',axis='both') # plt.title('loglog base 2 on x', fontsize=14) #Toy anomaly detection dataset plt.xlabel('Occurrences of A Word as End Word',fontsize=14) plt.ylabel('Number of Words',fontsize=14) plt.xticks(fontsize=14) plt.yticks(fontsize=14) fig.tight_layout() plt.show() fig.savefig('power_law_distribution_ace2004.pdf', bbox_inches='tight')
画图结果: