{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import geoviews as gv\n", "import geoviews.tile_sources as gvts\n", "\n", "gv.extension('bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Declare data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cities = pd.read_csv('../../assets/cities.csv', encoding=\"ISO-8859-1\")\n", "\n", "points = gv.Points(cities, ['Longitude', 'Latitude'], ['City', 'Population', 'Country', 'Year'],\n", " label='Top 20 Cities by population in 2050').select(Year=2050).sort('Population').iloc[-20:]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "(gvts.CartoMidnight *\n", " points.opts(\n", " size=gv.dim('Population')*0.000002, fill_color='Population', line_color='gray', cmap='viridis',\n", " width=700, height=600, global_extent=True, tools=['hover'], show_legend=False) *\n", " gv.Labels(points).opts(\n", " text_font_size='8pt', text_color='white'))" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 2 }