show me global leatherback sizes across populations for various sexes
To upload files, please first save the app
import streamlit as st
import pandas as pd
import altair as alt
# Create sample data for leatherback turtles across populations
data = {
'Population': ['Western Pacific', 'Eastern Pacific', 'Atlantic', 'Indian Ocean'] * 3,
'Sex': ['Female', 'Female', 'Female', 'Female',
'Male', 'Male', 'Male', 'Male',
'Unknown', 'Unknown', 'Unknown', 'Unknown'],
'Carapace_Length_cm': [159, 145, 152, 147,
142, 138, 145, 140,
150, 142, 148, 143],
'Standard_Deviation': [12, 10, 11, 9,
8, 7, 9, 8,
10, 9, 10, 8]
}
df = pd.DataFrame(data)
st.title('Global Leatherback Turtle Sizes by Population and Sex')
st.markdown('''
This visualization shows the average carapace (shell) length of leatherback turtles
across different populations and sexes. Error bars represent standard deviation.
''')
# Create an error bar chart using Altair
chart = alt.Chart(df).mark_bar().encode(
x=alt.X('Population:N', title='Population'),
y=alt.Y('Carapace_Length_cm:Q', title='Carapace Length (cm)'),
color='Sex:N',
column=alt.Column('Sex:N', title=None)
).properties(
width=200
)
error_bars = alt.Chart(df).mark_errorbar().encode(
x=alt.X('Population:N'),
y=alt.Y('Carapace_Length_cm:Q',
scale=alt.Scale(zero=False),
title='Carapace Length (cm)'),
yError='Standard_Deviation:Q',
color='Sex:N',
column=alt.Column('Sex:N', title=None)
)
final_chart = (chart + error_bars).properties(
title='Leatherback Turtle Sizes Across Populations'
)
st.altair_chart(final_chart, use_container_width=True)
# Display the raw data in a table
st.subheader('Raw Data')
st.dataframe(df)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?