Skip to content

Commit

Permalink
#8 update grouped bar example
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhangyixue1537 committed Jun 11, 2024
1 parent a25911a commit df7d4c2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions sphinx/source/examples/grouped_bar/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Below is a gallery of grouped bar charts.

- RICK Vertical Grouped Bar Chart: derives from the RICK package with source code in `rick.py`.
- RICK Horizontal Grouped Bar Chart: derives from the RICK package with source code in `rick.py`.
- RICK Multi Stacked Bar Chart: derives from the RICK package with source code in `rick.py`.

52 changes: 52 additions & 0 deletions sphinx/source/examples/grouped_bar/plot_multi_stacked_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
RICK Multi Stacked Bar Chart
=======================
Example of a horizontal grouped bar chart.
"""
import os
import os.path as osp
import sys
sys.path.append(osp.dirname(osp.dirname(osp.dirname(osp.dirname(osp.dirname(osp.abspath(__file__)))))))

from sqlalchemy import create_engine
import matplotlib.pyplot as plt
import matplotlib as mpl
import pandas as pd
import configparser
from psycopg2 import connect
import psycopg2.sql as pg
import pandas.io.sql as pandasql
import numpy as np
import datetime
import math
import rick
import geopandas as gpd
import os
import shapely
from shapely.geometry import Point
####os.environ["PROJ_LIB"]=r"C:\Users\rliu4\AppData\Local\Continuum\anaconda3\Library\share"
import importlib
import matplotlib.ticker as ticker
import matplotlib.font_manager as font_manager


################################
#multi_stacked_bar_chart
#--------------------------
#
#This Section uses the revised multi_stacked_bar_chart function with a customized dataframe.

np.random.seed(42)
data1 = {
'Location': ['Scarborough', 'Etobicoke York', 'North York', 'East York'],
'2016': [58640, 57210, 59490, 63090],
'2018': [93810, 90690, 84720, 93550],
'2020': [81538, 77456, 80235, 73692]
}

df = pd.DataFrame(data1)
##df = df.set_index('Category')

fig, ax = rick.charts.multi_stacked_bar_chart(df, xlab = 'Trips', lab1 = '2016', lab2 = '2018', lab3 = '2020', xmax= 250000)
fig.tight_layout()

0 comments on commit df7d4c2

Please sign in to comment.