Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Theme and App Name\n",
"\n",
"This notebook demonstrates how to customize the kepler.gl UI theme and application name.\n",
"\n",
"**`theme`** controls the kepler.gl UI appearance:\n",
"- `\"light\"` – light UI, pairs well with Mapbox light basemap styles\n",
"- `\"dark\"` – dark UI (default)\n",
"- `\"base\"` – base theme\n",
"\n",
"**`app_name`** controls the title shown in the side panel header and the HTML `<title>` when exporting."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import keplergl"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame({\n",
" 'City': ['Buenos Aires', 'Brasilia', 'Santiago', 'Bogota', 'Caracas'],\n",
" 'Country': ['Argentina', 'Brazil', 'Chile', 'Colombia', 'Venezuela'],\n",
" 'Latitude': [-34.58, -15.78, -33.45, 4.60, 10.48],\n",
" 'Longitude': [-58.66, -47.91, -70.66, -74.08, -66.86]\n",
"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Default (dark theme)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "dd4973c6f6294e22be290563363f66f1",
"version_major": 2,
"version_minor": 1
},
"text/plain": [
"<keplergl.widget.KeplerGl object at 0x10db8d070>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w_default = keplergl.KeplerGl(height=400, data={'cities': df})\n",
"w_default"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Light theme with custom app name"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2711ffcffb5845acabd195c823da7fba",
"version_major": 2,
"version_minor": 1
},
"text/plain": [
"<keplergl.widget.KeplerGl object at 0x10db8f170>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w_light = keplergl.KeplerGl(\n",
" height=400,\n",
" data={'cities': df},\n",
" theme='light',\n",
" app_name='City Explorer'\n",
")\n",
"w_light"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Export to HTML\n",
"\n",
"Both `theme` and `app_name` carry over to `save_to_html`. You can also override them at export time."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Map saved to light_theme_map.html!\n"
]
}
],
"source": [
"# Uses the widget's theme=\"light\" and app_name=\"City Explorer\"\n",
"w_light.save_to_html(file_name='light_theme_map.html')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Map saved to custom_export.html!\n"
]
}
],
"source": [
"# Override theme and app_name at export time\n",
"w_default.save_to_html(\n",
" file_name='custom_export.html',\n",
" theme='light',\n",
" app_name='My Custom Map'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}