1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      這篇文章將為大家詳細(xì)講解有關(guān)如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

      專業(yè)領(lǐng)域包括成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、成都外貿(mào)網(wǎng)站建設(shè)成都做商城網(wǎng)站、微信營銷、系統(tǒng)平臺(tái)開發(fā), 與其他網(wǎng)站設(shè)計(jì)及系統(tǒng)開發(fā)公司不同,創(chuàng)新互聯(lián)公司的整合解決方案結(jié)合了幫做網(wǎng)絡(luò)品牌建設(shè)經(jīng)驗(yàn)和互聯(lián)網(wǎng)整合營銷的理念,并將策略和執(zhí)行緊密結(jié)合,為客戶提供全網(wǎng)互聯(lián)網(wǎng)整合方案。

      import matplotlib.pyplot as plt
      import numpy as np
      import numpy.random as randn
      import pandas as pd
      from pandas import Series,DataFrame
      from pylab import mpl
      mpl.rcParams['axes.unicode_minus'] = False # 我自己配置的問題
      plt.rc('figure', figsize=(10, 6)) # 設(shè)置圖像大小
      
      %matplotlib inline

      1. figure對(duì)象

      Matplotlib的圖像均位于figure對(duì)象中。

      • 創(chuàng)建figure: plt.figure()

      fig = plt.figure()

      2. subplot子圖

      • add_subplot:向figure對(duì)象中添加子圖。

      • add_subplot(a, b, c):a,b 表示講fig分割成axb的區(qū)域,c 表示當(dāng)前選中要操作的區(qū)域(c從1開始)。
        add_subplot返回的是AxesSubplot對(duì)象,plot 繪圖的區(qū)域是最后一次指定subplot的位置

      ax1 = fig.add_subplot(2,2,1)
      ax2 = fig.add_subplot(2,2,2)
      ax3 = fig.add_subplot(2,2,3)
      ax4 = fig.add_subplot(2,2,4)
      random_arr = randn.rand(50)
      # 默認(rèn)是在最后一次使用subplot的位置上作圖
      plt.plot(random_arr,'ro--') # r:表示顏色為紅色,o:表示數(shù)據(jù)用o標(biāo)記 ,--:表示虛線
      # 等價(jià)于:
      # plt.plot(random_arr,linestyle='--',color='r',marker='o')
      plt.show()

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      # hist:直方圖:統(tǒng)計(jì)分布情況
      plt.hist(np.random.rand(8), bins=6, color='b', alpha=0.3) 
      # bins:數(shù)據(jù)箱子個(gè)數(shù)
      (array([ 3.,  0.,  0.,  0.,  2.,  3.]),
       array([ 0.10261627,  0.19557319,  0.28853011,  0.38148703,  0.47444396,
               0.56740088,  0.6603578 ]),
       )

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      # 散點(diǎn)圖
      plt.scatter(np.arange(30), np.arange(30) + 3 * randn.randn(30))

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      • subplots :生成子圖/子圖數(shù)組

      # 柱狀圖
      fig, ax = plt.subplots()
      x = np.arange(5)
      y1, y2 = np.random.randint(1, 25, size=(2, 5))
      width = 0.25
      ax.bar(x, y1, width, color='r') 
      # 畫柱子ax.bar(x+width, y2, width, color='g') 
      # 畫柱子ax.set_xticks(x+width)
      ax.set_xticklabels(['a', 'b', 'c', 'd', 'e']) # 下標(biāo)注明

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      fig, axes = plt.subplots(2, 2, sharex=True, sharey=True) # 共享軸坐標(biāo)

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      • subplots_adjust:調(diào)整subplots的間距

      plt.subplots_adjust(left=0.5,top=0.5)
      fig, axes = plt.subplots(2, 2)

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      random_arr = randn.randn(8)
      fig, axes = plt.subplots(2, 2)
      axes[0, 0].hist(random_arr, bins=16, color='k', alpha=0.5)
      axes[0, 1].plot(random_arr,'ko--')
      x = np.arange(8)
      y = x + 5 * np.random.rand(8)
      axes[1,0].scatter(x, y)
      x = np.arange(5)
      y1, y2 = np.random.randint(1, 25, size=(2, 5))
      width = 0.25axes[1,1].bar(x, y1, width, color='r') # 畫柱子
      axes[1,1].bar(x+width, y2, width, color='g') # 畫柱子
      axes[1,1].set_xticks(x+width)
      axes[1,1].set_xticklabels(['a', 'b', 'c', 'd', 'e']) # 下標(biāo)注明

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      • 重疊繪制

      • legend:顯示圖例

      random_arr1 = randn.randn(8)
      random_arr2 = randn.randn(8)
      fig, ax = plt.subplots()
      ax.plot(random_arr1,'ko--',label='A')
      ax.plot(random_arr2,'b^--',label='B')
      plt.legend(loc='best') # 自動(dòng)選擇放置圖例的最佳位置

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      • 設(shè)置刻度范圍:set_xlim、set_ylim

      • 設(shè)置顯示的刻度:set_xticks、set_yticks

      • 刻度標(biāo)簽:set_xticklabels、set_yticklabels

      • 坐標(biāo)軸標(biāo)簽:set_xlabel、set_ylabe

      • l圖像標(biāo)題:set_title

      fig, ax = plt.subplots(1)
      ax.plot(np.random.randn(380).cumsum())
      
      # 設(shè)置刻度范圍a
      x.set_xlim([0, 500])
      
      # 設(shè)置顯示的刻度(記號(hào))
      ax.set_xticks(range(0,500,100))
      
      # 設(shè)置刻度標(biāo)簽
      ax.set_xticklabels(['one', 'two', 'three', 'four', 'five'],
      rotation=30, fontsize='small')
      
      # 設(shè)置坐標(biāo)軸標(biāo)簽ax.set_xlabel('X:...')
      ax.set_ylabel('Y:...')
      
      # 設(shè)置標(biāo)題
      ax.set_title('Example')

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      3. Plotting functions in pandas

      plt.close('all')
      s = Series(np.random.randn(10).cumsum(), index=np.arange(0, 100, 10))
      s
      fig,ax = plt.subplots(1)
      s.plot(ax=ax,style='ko--')

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      fig, axes = plt.subplots(2, 1)
      data = Series(np.random.rand(16), index=list('abcdefghijklmnop'))
      data.plot(kind='bar', ax=axes[0], color='k', alpha=0.7)
      data.plot(kind='barh', ax=axes[1], color='k', alpha=0.7)

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      df = DataFrame(np.random.randn(10, 4).cumsum(0),
                     columns=['A', 'B', 'C', 'D'],
                     index=np.arange(0, 100, 10))
      df
      ABCD
      0-0.5238221.061179-0.882215-0.267718
      10-0.178175-0.367573-1.465189-1.095390
      200.2761660.816511-0.3445571.297281
      300.5294000.159374-2.7651681.784692
      40-1.129003-1.665272-2.7465123.140976
      500.265113-1.821224-5.1408502.377449
      60-2.699879-3.895255-5.0115611.715174
      70-2.384257-3.480928-4.5191312.805369
      80-2.525243-3.031608-4.8401251.106624
      90-2.020589-3.519473-4.8232920.522323
      df.plot() # 列索引為圖例,行索引為橫坐標(biāo),值為縱坐標(biāo)

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      df = DataFrame(np.random.randint(0,2,(10, 2)),
                     columns=['A', 'B'],
                     index=np.arange(0, 10, 1))
      df
      AB
      001
      101
      210
      301
      410
      510
      611
      700
      810
      910
      df.plot(kind='bar')

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      df.A.value_counts().plot(kind='bar')

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      df.A[df.B == 1].plot(kind='kde')   
      df.A[df.B == 0].plot(kind='kde')    # 密度圖

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      df = DataFrame(np.random.rand(6, 4),
                     index=['one', 'two', 'three', 'four', 'five', 'six'],
                     columns=pd.Index(['A', 'B', 'C', 'D'], name='Genus'))
      df
      GenusABCD
      one0.7607500.9511590.6431810.792940
      two0.1372940.0054170.6856680.858801
      three0.2574550.7219730.9689510.043061
      four0.2981000.1212930.4006580.236369
      five0.4639190.5370550.6759180.487098
      six0.7986760.2391880.9155830.456184
      df.plot(kind='bar',stacked='True') #行索引:橫坐標(biāo)

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      values = Series(np.random.normal(0, 1, size=200))
      values.hist(bins=100, alpha=0.3, color='k', normed=True)
      values.plot(kind='kde', style='k--')

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      df = DataFrame(np.random.randn(10,2),
                     columns=['A', 'B'],
                     index=np.arange(0, 10, 1))
      df
      plt.scatter(df.A, df.B)

      如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib

      關(guān)于如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。


      標(biāo)題名稱:如何實(shí)現(xiàn)數(shù)據(jù)可視化matplotlib
      網(wǎng)頁網(wǎng)址:http://www.ef60e0e.cn/article/jjcoji.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        毕节市| 集安市| 营口市| 林口县| 天等县| 胶州市| 吴川市| 陈巴尔虎旗| 青海省| 达拉特旗| 博客| 兴山县| 镇康县| 温州市| 车致| 夹江县| 武定县| 吉安市| 平乡县| 新竹县| 金坛市| 商都县| 阿鲁科尔沁旗| 孝感市| 朔州市| 承德市| 甘孜| 卓尼县| 岳普湖县| 建湖县| 晋中市| 民县| 平凉市| 滁州市| 南漳县| 重庆市| 合阳县| 增城市| 沽源县| 大连市| 山阳县|