SoFunction
Updated on 2024-11-19

Python Plotting Grouped Comparison Histograms

This article example for you to share the specific code of python draw group comparison bar chart for your reference, the specific content is as follows

First the rendering.

 # -*- coding: utf-8 -*-
import numpy as np
 
import tensorflow as tf
from  import Path
from  import PathPatch
import  as plt
import matplotlib
from  import FuncAnimation
import matplotlib as mpl
import datetime
import time
import  re
import 
np.set_printoptions(suppress=True)
 
['-serif'] = ['SimHei'] # Specify the default font, SimHei, to be bold
['axes.unicode_minus'] = False # Used to properly display negative
import requests
import re
import hashlib
 
#test data osm's point and line data
#test host 8G 4-core 1T mechanical disk
#mysql 5.7.23
#postgresql 12
#dameng 7
#oracle 19c 19.3
 
 
#Read Efficiency Point, Line, Plane
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
     ]
 # Write efficiency
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
    ]      
# This is the bar chart x-axis label
ysr = ['Oracle','GDB','SQLITE','MySQL','PostgreSQL','DAMENG','ArcGIS_GDB','ArcGIS_ORACLE']  
 
 
def DrawGeoDtaabse(rcount, wcount, y):
    #First row, first column, 2,1 for 2 rows and 1 column.
    ax1 = (2,1,1)
    # Second row, first column of graphics #
    ax3 = (2,1,2)
    # Default time format
    (ax1)
    ("",color = 'r') #X-axis labels
    ("Article/s",color = 'r')  #Y-axis labels
    #(True) Show Grid
    #().autofmt_xdate() display time
    () # Show legend
    ("[Reading] efficiency") # Title
 
    x1 = [1,5,9,13,17,21,25,29] # x-axis point efficiency position
    x2 = [i + 1 for i in x1]    # x-axis line efficiency position
    x3 = [i + 2 for i in x1]    # x-axis face efficiency position
    y1 = [i[0] for i in rcount] # y-axis point efficiency position
    y2 = [i[1] for i in rcount] # y-axis line efficiency position
    y3 = [i[2] for i in rcount] # y-axis face efficiency position
    #Placeholder to avoid loss of data source labels
    y0 = ["","","","","","","",""]
    (x1, y1, alpha=0.7, width=1, color='r',label="Point.", tick_label=y0)
    (x3, y3, alpha=0.7, width=1, color='b',label="Face.", tick_label=y0)
    (x2, y2, alpha=0.7, width=1, color='g',label="Line.", tick_label=y)
    #The read efficiency of the first line is plotted, and the write efficiency of the second line is repeated.
 
    (ax3)
    ("Data source",color = 'r') #X-axis labels
    ("Article/s",color = 'r') #Y-axis labels
    #(True)
    () # Show legend
    ("[Write] efficiency") # Figure Title
 
 
    y1 = [i[0] for i in wcount]
    y2 = [i[1] for i in wcount]
    y3 = [i[2] for i in wcount]
    y0 = ["","","","","","","",""]
    (x1, y1, alpha=0.7, width=0.6, color='r',label="Point.", tick_label=y0)
    (x3, y3, alpha=0.7, width=0.6, color='b',label="Face.", tick_label=y0)
    (x2, y2, alpha=0.7, width=0.6, color='g',label="Line.", tick_label=y)
 
    ()
    () 
 
DrawGeoDtaabse(r,w,ysr)

All of the above code was tested successfully on python 3.6.4

This is the whole content of this article.