網(wǎng)站首頁 編程語言 正文
本文實(shí)例為大家分享了python繪制分組對比柱狀圖的具體代碼,供大家參考,具體內(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 #用來正常顯示負(fù)
import requests
import re
import hashlib
?
#測試數(shù)據(jù) ?osm的點(diǎn)線面數(shù)據(jù)
#測試主機(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)時間格式
? ? 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() 顯示時間
? ? 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)行測試成功
原文鏈接:https://blog.csdn.net/chijingjing/article/details/104018194
相關(guān)推薦
- 2022-03-09 C語言之選擇分支語句詳解_C 語言
- 2022-08-12 解決IE9下JQuery發(fā)送ajax請求失效的方法_jquery
- 2022-05-23 iOS實(shí)現(xiàn)垂直滑動條效果_IOS
- 2022-10-18 解決VMware?VCSA?5480?后臺登錄提示失敗的問題_VMware
- 2022-10-14 MapStruct 代碼生成器
- 2022-07-15 SQL?Server中的排名函數(shù)與分析函數(shù)詳解_MsSql
- 2023-04-26 C語言實(shí)現(xiàn)數(shù)組元素排序方法詳解_C 語言
- 2022-11-09 Python有序容器的?sort?方法詳解_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支