Create a Filtered Chart

In this section, we will see how you can add a filtered chart to your Pollination app. We will filter the dry bulb temperature data coming out of an EPW file and will visualize it as a Plotly chart in a Pollination app.

Install the following libraries first

pip install ladybug-charts streamlit

Start by importing the libraries

import streamlit as st
from ladybug.epw import EPW

Set the title of the page and layout

st.set_page_config(
    page_title='Dry bulb temperature', layout='wide'
)

Create an EPW object from an epw file and get the dry bulb temperature.

epw = EPW("file path to epw file")
dbt = epw.dry_bulb_temperature

Apply some filters to the dry bulb temperature. for example, let's visualize the dry bulb temperature between 18 and 24 degrees Celsius during 9am to 5pm all year.

dbt_work_hours = dbt.filter_by_analysis_period(
    AnalysisPeriod(1, 1, 9, 12, 31, 17)).filter_by_conditional_statement('a>=18 and a<=24')

Create a Plotly figure from the filtered chart

figure = dbt_work_hours.heat_map()

Visualize the filtered dry bulb temperature chart

st.title("Dry bulb temperature")
st.plotly_chart(figure, use_container_width=True)

You should see a filtered annual heatmap appear in the Streamlit app.

Last updated