日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

python繪制分組對比柱狀圖_python

作者:cejutue ? 更新時間: 2022-06-19 編程語言

本文實例為大家分享了python繪制分組對比柱狀圖的具體代碼,供大家參考,具體內容如下

首先放效果圖:?

?# -*- 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'] #指定默認字體 SimHei為黑體
mpl.rcParams['axes.unicode_minus'] = False #用來正常顯示負
import requests
import re
import hashlib
?
#測試數據 ?osm的點線面數據
#測試主機 8G 4核 1T機械盤
#mysql 5.7.23
#postgresql 12
#dameng 7
#oracle 19c 19.3
?
?
#讀取效率 點 ? ? ? ? ? ? 線 ? ? ? ? ? 面
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軸標簽
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)
? ? #默認時間格式
? ? plt.sca(ax1)
? ? plt.xlabel("",color = 'r') #X軸標簽
? ? plt.ylabel("條/s",color = 'r') ?#Y軸標簽
? ? #plt.grid(True) ? 顯示格網
? ? #plt.gcf().autofmt_xdate() 顯示時間
? ? plt.legend() # 顯示圖例
? ? plt.title("[讀取]效率") #標題
?
? ? x1 = [1,5,9,13,17,21,25,29] # x軸點效率位置
? ? x2 = [i + 1 for i in x1] ? ?# x軸線效率位置
? ? x3 = [i + 2 for i in x1] ? ?# x軸面效率位置
? ? y1 = [i[0] for i in rcount] # y軸點效率位置
? ? y2 = [i[1] for i in rcount] # y軸線效率位置
? ? y3 = [i[2] for i in rcount] # y軸面效率位置
? ? #占位以免 數據源標簽丟失
? ? y0 = ["","","","","","","",""]
? ? plt.bar(x1, y1, alpha=0.7, width=1, color='r',label="點", 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)
? ? #至此第一行的讀取效率繪制完畢,再重復一下第二行的寫效率
?
? ? plt.sca(ax3)
? ? plt.xlabel("數據源",color = 'r') #X軸標簽
? ? plt.ylabel("條/s",color = 'r') #Y軸標簽
? ? #plt.grid(True)
? ? plt.legend() # 顯示圖例
? ? plt.title("[寫入]效率") #圖標題
?
?
? ? 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="點", 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上運行測試成功

原文鏈接:https://blog.csdn.net/chijingjing/article/details/104018194

欄目分類
最近更新