Subplotting with Every Individual Plot Occupies Different Areas in Figure - Subplotting with Every Individual Plot Occupies Different Areas in Figure - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-09
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

This example shows the steps to subplot with every individual plot occupies different areas in figure.

Example

  • >>> load_example_data("weightedmovavg", "stock_vol")
  • Axis and Figure using subplots().
    >>> fig, axes = subplots(grid={(1,1): (1, 1), (1,2): (1,1), (2, 1): (1, 2)})
  • >>> stock_vol = DataFrame("stock_vol")
    >>> stock_vol
       name    period  stockprice     volume
    id
    3    pg  61/05/19      17.625  1582000.0
    3    pg  61/05/23      17.625   608800.0
    3    pg  61/05/24      17.750  1038800.0
    3    pg  61/05/25      17.250   911200.0
    3    pg  61/05/29      18.000  1672800.0
    3    pg  61/05/31      18.000  1735600.0
    3    pg  61/05/26      17.500  2005600.0
    3    pg  61/05/22      17.750   317200.0
    3    pg  61/05/18      18.250  1435200.0
    3    pg  61/05/17      18.375  1032000.0
    
  • >>> ge_df = stock_vol[stock_vol.name == "ge"]
    >>> pg_df = stock_vol[stock_vol.name == "pg"]
    >>> ibm_df = stock_vol[stock_vol.name == "ibm"]
  • >>> ge_plot = ge_df.plot(x=ge_df.period,
                             y=ge_df.stockprice,
                             ax=axes[0],
                             figure=fig,
                             title="GE Stock Price",
                             style="green")
    >>> pg_plot = pg_df.plot(x=pg_df.period,
                             y=pg_df.stockprice,
                             ax=axes[1],
                             figure=fig,
                             title="PG Stock Price",
                             style="red")
    >>> ibm_plot = ibm_df.plot(x=ibm_df.period,
                               y=ibm_df.stockprice,
                               ax=axes[2],
                               figure=fig,
                               title="IBM Stock Price",
                               style="blue",
                               kind='bar')

    subplot different area