網站首頁 編程語言 正文
本文實例為大家分享了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
相關推薦
- 2023-06-20 Redis?設置密碼無效問題解決_Redis
- 2023-01-10 SpringEvent優雅解耦時連續兩個bug的解決方案_Golang
- 2022-09-02 Python用matplotlib庫畫圖中文和負號顯示為方框的問題解決_python
- 2022-07-13 VMware Workstation Pro界面設置為中文界面
- 2022-09-07 Python和C語言利用棧分別實現進制轉換_python
- 2022-09-30 python實現圖像邊緣檢測_python
- 2022-06-24 使用Go語言寫一個Http?Server的實現_Golang
- 2022-07-17 使用非root用戶安裝及啟動docker的問題(rootless模式運行)_docker
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支