ƵµÀÀ¸Ä¿
Ê×Ò³ > ÍøÂç > ÔÆ¼ÆËã > ÕýÎÄ

pythonµÄmatplotlib¿â¸öÈË×ܽá

2019-12-15 11:18:36           
Êղؠ  ÎÒҪͶ¸å

1¡¢x=np.linspace(0,10,100) Éú³Éarray([0,10,20,30...,110])(°üº¬³õʼֵºÍ½áÊøÖµ)

2¡¢¼òµ¥µÄÀý×Ó

°Ñ»æÍ¼´°¿Ú·Ö³ÉÁ½ÐÐÁ½ÁÐËÄ¿éÇøÓò£¬È»ºóÔÚÿ¸öÇøÓò·Ö±ð×÷ͼ£¬»ù±¾²½Ö裺

subplot(2,2,1); % 2¡¢2¡¢1Ö®¼äûÓжººÅÒ²¿ÉÒÔ

ÔÚµÚÒ»¿é»æÍ¼

subplot(2,2,2);

ÔÚµÚ¶þ¿é»æÍ¼

subplot(2,2,3);

ÔÚµÚÈý¿é»æÍ¼

subplot(2,2,4);

ÔÚµÚËÄ¿é»æÍ¼

3¡¢ctrl+shift+F10 ¿ìËÙÔËÐе±Ç°½Å±¾

4¡¢¶Ôº¯ÊýÓë×ø±êÖáÖ®¼äµÄÇøÓò½øÐÐÌî³ä£¬Ê¹ÓÃfillº¯Êý

Ìî³äÁ½¸öº¯ÊýÖ®¼äµÄÇøÓò£¬Ê¹ÓÃfill_betweenº¯Êý

 

5¡¢Çø±ð¡£»­Ò»¸öͼºÍ»­Á½¸öͼ֮¼äº¯ÊýµÄ²î±ð¡£

plt.xlabel() ax.set_xlabel()

plt.ylabel() ax.set_ylabel()

plt.xlim() ax.set_xlim()

plt.ylim() ax.set_ylim()

plt.title() ax.set_title()

ax.set(xlim=(0,10),ylim=(),xlabel=,title=)

6¡¢

rng=numpy.random.RandomState(23355)

arrayA=rng.uniform(0,1,(2,3))

¡¡

¸Ã¶Î´úÂëµÄÄ¿µÄÊDzúÉúÒ»¸ö2ÐÐ3ÁеÄassarray£¬ÆäÖеÄÿ¸öÔªËØ¶¼ÊÇ[0,1]Çø¼äµÄ¾ùÔÈ·Ö²¼µÄËæ»úÊý

ÕâÀï¿´ÒÔ¿´µ½£¬ÓÐÒ»¸ö23355Õâ¸öÊý×Ö£¬Æäʵ£¬ËüÊÇÎ±Ëæ»úÊý²úÉúÆ÷µÄÖÖ×Ó£¬Ò²¾ÍÊÇ“the starting point for a sequence of pseudorandom number”

¶ÔÓÚijһ¸öÎ±Ëæ»úÊý·¢ÉúÆ÷£¬Ö»Òª¸ÃÖÖ×Ó£¨seed£©Ïàͬ£¬²úÉúµÄËæ»úÊýÐòÁоÍÊÇÏàͬµÄ

rng=numpy.random.RandomState(0)

rng.rand(5)

Ëæ»ú²úÉú5¸ö0,1Ö®¼äµÄ¾ùÔÈ·Ö²¼µÄËæ»úÊý¡£

7¡¢ÉÙÓÃsubplots,ÓÃsubplot,ÏñMATLABÄÇÑùÈ¥±à³Ì¡£

8¡¢

for marker in ['o','.',',','x','+','v','^','<','>','s','d']:

plt.plot(rng.rand(5),rng.rand(5),marker, label="marker={0}".format(marker),markersize=15,

markerfacecolor='white',markeredgewidth=2,

markeredgecolor=(0,0,0.4,0.1))

plt.legend(numpoints=1)

plt.xlim(0,1.8)

format(marker)ÀïÃæµÄmarkerÖ¸µÄÊDZäÁ¿marker!!!

9¡¢cyanÊÇÇàÉ«µÄÒâ˼

‘--c’»æÖÆÇàÉ«ÏßÌõ¡£

10¡¢

ͨ¹ý iterable ¶ÔÏóÀ´µü´ú

 

for i in range(1000): pass

»áµ¼ÖÂÉú³ÉÒ»¸ö 1000 ¸öÔªËØµÄ List£¬¶ø´úÂ룺

 

for i in xrange(1000): pass

 

 

11¡¢

ÈçºÎÊä³öºÏ²¢µ¥Ôª¸ñµÄÄÚÈÝ

>>> merge = []

>>> for (rlow,rhigh,clow,chigh) in sheet2.merged_cells:

... merge.append([rlow,clow])

...>>> merge

[[1, 4], [3, 4], [5, 1]]

>>> for index in merge:

... print sheet2.cell_value(index[0],index[1])

...

friend

friend2

None

12¡¢

from matplotlib.font_manager import *
myfont =

FontProperties(fname='D:\Python\Lib\site-packages\matplotlib\mpl-data/fonts/ttf/arcdps_font.ttf')
mpl.rcParams['axes.unicode_minus']=False

plt.xlabel('Äê·Ý',fontproperties=myfont)
plt.ylabel('µÍ±£Êý¶î£¨Ôª£©',fontproperties=myfont)

plt.legend(prop =myfont)

½â¾ö×ÖÌåÎÊÌâ

13¡¢

print(df.sum(axis=1))£¬Êý×éÄÚ²¿Ïà¼Ó£¬×ܸöÊýΪÊý×é¸öÊý¡£

print(df.sum(axis=0))£¬Êý×é¶ÔӦλÖÃÊý×ÖÏà¼Ó£¬×ܸöÊýΪµ¥¸öÊý×éÖÐÊý×ֵĸöÊý¡£

14¡¢

matplotlib.rcParams['font.sans-serif'] = ['SimHei']

matplotlib.rcParams['axes.unicode_minus'] = False

ÉÏһƪ£ºSpark¹¤¾ß°ü¹¦ÄܽéÉÜ
ÏÂһƪ£ºMapReduce¼ÆÊýÆ÷Ô­Àí
Ïà¹ØÎÄÕÂ
ͼÎÄÍÆ¼ö

¹ØÓÚÎÒÃÇ | ÁªÏµÎÒÃÇ | ¹ã¸æ·þÎñ | Ͷ×ʺÏ×÷ | °æÈ¨ÉêÃ÷ | ÔÚÏß°ïÖú | ÍøÕ¾µØÍ¼ | ×÷Æ··¢²¼ | Vip¼¼ÊõÅàѵ | ¾Ù±¨ÖÐÐÄ

°æÈ¨ËùÓÐ: È«·å°²È«ÁªÃË--ÖÂÁ¦ÓÚ×öʵÓõÄIT¼¼ÊõÑ§Ï°ÍøÕ¾