.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/line/plot_tow_line_rick.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_line_plot_tow_line_rick.py: RICK Time-of-Week Line Chart ============================ Example time-of-week line chart. .. GENERATED FROM PYTHON SOURCE LINES 7-35 .. code-block:: default 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 CONFIG = configparser.ConfigParser() # CONFIG.read(r'C:\Users\rliu4\Documents\Python\config.cfg') CONFIG.read(r'/home/cnangini/db.cfg') dbset = CONFIG['DBSETTINGS'] con = connect(**dbset) .. GENERATED FROM PYTHON SOURCE LINES 36-40 Data Collection ---------------- This Section grabs and formats the data. .. GENERATED FROM PYTHON SOURCE LINES 40-67 .. code-block:: default query = ''' WITH sum AS ( SELECT pickup_datetime, hr, sum(count) as count, extract(month from pickup_datetime) as mon, extract(year from pickup_datetime) as yr, extract(dow from pickup_datetime) as dow FROM ptc.trip_data_agg_ward_25 WHERE pickup_datetime > '2018-08-31' GROUP BY pickup_datetime, hr ) , collect AS ( SELECT avg(count) as count, hr, dow from sum group by hr, dow) SELECT period_name, period_uid, count, hr, CASE WHEN dow = 0 THEN 7 ELSE dow END AS dow, CASE WHEN swatch IS NULL THEN '#999999' ELSE swatch END AS swatch FROM collect LEFT JOIN ptc.period_lookup_simple ON dow=period_dow AND hr=period_hr LEFT JOIN ptc.periods_simple USING (period_uid) ORDER BY dow, hr ''' count_18 = pandasql.read_sql(query,con) fig, ax, prop = rick.charts.tow_chart(data = count_18['count'], ylab='Trips', ymax = 14000, yinc= 3500) .. image:: /auto_examples/line/images/sphx_glr_plot_tow_line_rick_001.png :alt: plot tow line rick :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.176 seconds) .. _sphx_glr_download_auto_examples_line_plot_tow_line_rick.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_tow_line_rick.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_tow_line_rick.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_