Search…
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
1
pip install ladybug-charts streamlit
Copied!
Start by importing the libraries
1
import streamlit as st
2
from ladybug.epw import EPW
Copied!
Set the title of the page and layout
1
st.set_page_config(
2
page_title='Dry bulb temperature', layout='wide'
3
)
Copied!
Create an EPW object from an epw file and get the dry bulb temperature.
1
epw = EPW("file path to epw file")
2
dbt = epw.dry_bulb_temperature
Copied!
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.
1
dbt_work_hours = dbt.filter_by_analysis_period(
2
AnalysisPeriod(1, 1, 9, 12, 31, 17)).filter_by_conditional_statement('a>=18 and a<=24')
Copied!
Create a Plotly figure from the filtered chart
1
figure = dbt_work_hours.heat_map()
Copied!
Visualize the filtered dry bulb temperature chart
1
st.title("Dry bulb temperature")
2
st.plotly_chart(figure, use_container_width=True)
Copied!
You should see a filtered annual heatmap appear in the Streamlit app.
Copy link