python繪制分組對(duì)比柱狀圖
更新時(shí)間:2022年04月21日 11:12:44 作者:cejutue
這篇文章主要為大家詳細(xì)介紹了python繪制分組對(duì)比柱狀圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了python繪制分組對(duì)比柱狀圖的具體代碼,供大家參考,具體內(nèi)容如下
首先放效果圖:
?# -*- coding: utf-8 -*- import numpy as np ? import tensorflow as tf from matplotlib.path import Path from matplotlib.patches import PathPatch import matplotlib.pyplot as plt import matplotlib from matplotlib.animation import FuncAnimation import matplotlib as mpl import datetime import time import ?re import urllib.request np.set_printoptions(suppress=True) ? mpl.rcParams['font.sans-serif'] = ['SimHei'] #指定默認(rèn)字體 SimHei為黑體 mpl.rcParams['axes.unicode_minus'] = False #用來(lái)正常顯示負(fù) import requests import re import hashlib ? #測(cè)試數(shù)據(jù) ?osm的點(diǎn)線面數(shù)據(jù) #測(cè)試主機(jī) 8G 4核 1T機(jī)械盤 #mysql 5.7.23 #postgresql 12 #dameng 7 #oracle 19c 19.3 ? ? #讀取效率 點(diǎn) ? ? ? ? ? ? 線 ? ? ? ? ? 面 r = [ ? ? [24714, ? ? ? 21748,?? ? ? ?19298], ? ? #Oracle ? ? ? ? ? [44127, ? ? ? 45943,?? ? ? ?42199], ? ? #GDB ? ? ? ? ? #[0, ? ? ?0,?? ??? ?0], ? ?#SQLITE ? ? ? ? ?# [0, ? ? ?0,?? ? ? ?0], ? ?#MySQL ? ? ? ? ? [352641, ? ? ?352739,?? ??? ?304189], ? ?#SQLITE ? ? ? ? ? [213550, ? ? ?218095,?? ? ? ?212749], ? ?#MySQL ? ? ? ? ? [36556, ? ? ? 22172,?? ??? ?12741], ? ? #PostgreSQL ? ? ? ? ? [52749, ? ? ? 46292,?? ??? ?20040], ? ? #dameng ? ? ? ? ? [25111, ? ? ? 12000,?? ? ? ?11000], ? ? #ArcGIS_GDB ? ? ? ? ? [10102, ? ? ? 9003,?? ??? ?7003] ? ? ? #ArcGIS_ORACLE ? ? ?] ?#寫入效率 w = [ ? ? [190, ? ? ? ? 675,?? ??? ?40], ? ? ? ?#Oracle ? ? ? ? ? [15815, ? ? ? 9820,?? ??? ?11892], ? ? #GDB ? ? ? ? ? [94547, ? ? ? 81847,?? ? ? ?57235], ? ? #SQLITE ? ? ? ? ? # [0, ? ? ? 0,?? ? ? ?0], ? ? #SQLITE ? ? ? ? ?[502, ? ? ? ? 662,?? ??? ?403], ? ? ? #MySQL ? ? ? ? ? #[0, ? ? ? ? 0,?? ??? ?0], ? ? ? #MySQL ? ? ? ? ? [1631, ? ? ? ?1599,?? ??? ?1502], ? ? ?#PostgreSQL ? ? ? ? ? [2004, ? ? ? ?1849,?? ??? ?1524], ? ? ?#dameng ? ? ? ? ? [10111, ? ? ? 8000,?? ??? ?5600] , ? ? #ArcGIS_GDB ? ? ? ? ? [1100, ? ? ? 1000,?? ??? ?900] ? ? ? ?#ArcGIS_ORACLE ? ? ] ? ? ? #這是柱圖x軸標(biāo)簽 ysr = ['Oracle','GDB','SQLITE','MySQL','PostgreSQL','DAMENG','ArcGIS_GDB','ArcGIS_ORACLE'] ? ? ? def DrawGeoDtaabse(rcount, wcount, y): ? ? #第一行 第一列圖形 ? 2,1 代表2行1列 ? ? ax1 = plt.subplot(2,1,1) ? ? #第二行 第一列圖形? ? ? ax3 = plt.subplot(2,1,2) ? ? #默認(rèn)時(shí)間格式 ? ? plt.sca(ax1) ? ? plt.xlabel("",color = 'r') #X軸標(biāo)簽 ? ? plt.ylabel("條/s",color = 'r') ?#Y軸標(biāo)簽 ? ? #plt.grid(True) ? 顯示格網(wǎng) ? ? #plt.gcf().autofmt_xdate() 顯示時(shí)間 ? ? plt.legend() # 顯示圖例 ? ? plt.title("[讀取]效率") #標(biāo)題 ? ? ? x1 = [1,5,9,13,17,21,25,29] # x軸點(diǎn)效率位置 ? ? x2 = [i + 1 for i in x1] ? ?# x軸線效率位置 ? ? x3 = [i + 2 for i in x1] ? ?# x軸面效率位置 ? ? y1 = [i[0] for i in rcount] # y軸點(diǎn)效率位置 ? ? y2 = [i[1] for i in rcount] # y軸線效率位置 ? ? y3 = [i[2] for i in rcount] # y軸面效率位置 ? ? #占位以免 數(shù)據(jù)源標(biāo)簽丟失 ? ? y0 = ["","","","","","","",""] ? ? plt.bar(x1, y1, alpha=0.7, width=1, color='r',label="點(diǎn)", tick_label=y0) ? ? plt.bar(x3, y3, alpha=0.7, width=1, color='b',label="面", tick_label=y0) ? ? plt.bar(x2, y2, alpha=0.7, width=1, color='g',label="線", tick_label=y) ? ? #至此第一行的讀取效率繪制完畢,再重復(fù)一下第二行的寫效率 ? ? ? plt.sca(ax3) ? ? plt.xlabel("數(shù)據(jù)源",color = 'r') #X軸標(biāo)簽 ? ? plt.ylabel("條/s",color = 'r') #Y軸標(biāo)簽 ? ? #plt.grid(True) ? ? plt.legend() # 顯示圖例 ? ? plt.title("[寫入]效率") #圖標(biāo)題 ? ? ? ? y1 = [i[0] for i in wcount] ? ? y2 = [i[1] for i in wcount] ? ? y3 = [i[2] for i in wcount] ? ? y0 = ["","","","","","","",""] ? ? plt.bar(x1, y1, alpha=0.7, width=0.6, color='r',label="點(diǎn)", tick_label=y0) ? ? plt.bar(x3, y3, alpha=0.7, width=0.6, color='b',label="面", tick_label=y0) ? ? plt.bar(x2, y2, alpha=0.7, width=0.6, color='g',label="線", tick_label=y) ? ? ? plt.legend() ? ? plt.show()? ? DrawGeoDtaabse(r,w,ysr)
以上所有代碼在python3.6.4上運(yùn)行測(cè)試成功
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
python判斷計(jì)算機(jī)是否有網(wǎng)絡(luò)連接的實(shí)例
今天小編就為大家分享一篇python判斷計(jì)算機(jī)是否有網(wǎng)絡(luò)連接的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-12-12使用python實(shí)現(xiàn)excel的Vlookup功能
這篇文章主要介紹了使用python實(shí)現(xiàn)excel的Vlookup功能,當(dāng)我們想要查找的數(shù)據(jù)量較大時(shí),這時(shí)則有請(qǐng)我們的主角VLookup函數(shù)出場(chǎng),那么如何用python實(shí)現(xiàn)VLookup呢,需要的朋友可以參考下2023-04-04python實(shí)現(xiàn)ftp文件傳輸系統(tǒng)(案例分析)
最近做了一個(gè)簡(jiǎn)單的文件傳輸系統(tǒng),基于ftp協(xié)議,使用python語(yǔ)言開發(fā),雖然python里面已經(jīng)有ftplib模塊,可以很容易的實(shí)現(xiàn)ftp服務(wù)器,這篇文章主要介紹了python實(shí)現(xiàn)ftp文件傳輸系統(tǒng)的案例分析,需要的朋友可以參考下2020-03-03