You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

297 lines
8.6 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "4d098df7-6998-4e10-99fd-5e68aa01a997",
"metadata": {},
"outputs": [],
"source": [
"# data = \"data/data-3d9Ex.csv\"\n",
"import plotly.express as px\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f49def17-f64f-46bf-a056-1d8a063ce3a6",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"data/data-3d9Ex.csv\")\n",
"df = df.fillna(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17975a6c-686e-43c3-a644-18004f74880b",
"metadata": {},
"outputs": [],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d41f39d0-36fb-45d4-8d34-bd9dfd9545ad",
"metadata": {},
"outputs": [],
"source": [
"fig = px.scatter_geo(df.head(), lat=\"Lat\", lon=\"Lon\", scope=\"europe\", fitbounds='locations',\n",
" size=\"Lakosság\")\n",
"fig.show(width=1000, height=800)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2940dc7-1221-4545-bcee-9eecf7b75fdb",
"metadata": {},
"outputs": [],
"source": [
"import plotly.express as px\n",
"\n",
"colorscales = px.colors.named_colorscales()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc5fe5a3-ba73-49ca-8c3d-24c5404b4ad5",
"metadata": {},
"outputs": [],
"source": [
"import plotly.graph_objects as go\n",
"\n",
"import pandas as pd\n",
"\n",
"df['text'] = df['Name'] + ': ' + df['Elhunytak száma 100000 főre'].astype('str')\n",
"tdf = df.head(100)\n",
"\n",
"\n",
"fig = go.Figure(data=go.Scattergeo(\n",
" #locationmode = 'USA-states',\n",
" lon = tdf['Lon'],\n",
" lat = tdf['Lat'],\n",
" text = tdf['text'],\n",
" mode = 'markers',\n",
" marker = dict(\n",
" size = 5,\n",
" opacity = 0.6,\n",
" #color_continuous_scale=px.colors.sequential.Viridis,\n",
" #reversescale = True,\n",
" #autocolorscale = False,\n",
" symbol = 'square',\n",
" line = dict(\n",
" width=1,\n",
" color='rgba(102, 102, 102)'\n",
" ),\n",
" cmin = 0,\n",
" color = np.log(df['Elhunytak száma 100000 főre']),\n",
" cmax = np.log(df['Elhunytak száma 100000 főre'].max()),\n",
" colorbar_title=\"Population\"\n",
" )))\n",
"\n",
"fig.update_layout(\n",
" title = 'Halálesetek száma',\n",
" height=1000,\n",
" width=1200,\n",
" geo = dict(\n",
" fitbounds='locations',\n",
" scope='europe',\n",
" #projection_type='albers usa',\n",
" showland = True,\n",
" landcolor = \"rgb(250, 250, 250)\",\n",
" subunitcolor = \"rgb(217, 217, 217)\",\n",
" countrycolor = \"rgb(217, 217, 217)\",\n",
" #countrywidth = 0.5,\n",
" #subunitwidth = 0.5\n",
" ),\n",
" )\n",
"fig.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "109c8725-0e01-4ad3-9185-813d5db115b7",
"metadata": {},
"outputs": [],
"source": [
"import plotly.graph_objects as go\n",
"\n",
"import pandas as pd\n",
"\n",
"df['text'] = df['Name'] + ': ' + df['Elhuyntak száma'].astype('str')\n",
"tdf = df[df['Elhuyntak száma']>0]#.head(100)\n",
"\n",
"\n",
"fig = go.Figure(data=go.Scattergeo(\n",
" #locationmode = 'USA-states',\n",
" lon = tdf['Lon'],\n",
" lat = tdf['Lat'],\n",
" text = tdf['text'],\n",
" mode = 'markers',\n",
" marker = dict(\n",
" size = np.log(tdf['Elhuyntak száma'])*5,\n",
" opacity = 0.6,\n",
" #color_continuous_scale=px.colors.sequential.Viridis,\n",
" #reversescale = True,\n",
" #autocolorscale = False,\n",
" symbol = 'circle',\n",
" line = dict(\n",
" width=1,\n",
" color='rgba(102, 102, 102)'\n",
" ),\n",
" cmin = 0,\n",
" color = np.log(tdf['Elhuyntak száma']),\n",
" cmax = np.log(tdf['Elhuyntak száma'].max()),\n",
" colorbar_title=\"Population\"\n",
" )))\n",
"\n",
"fig.update_layout(\n",
" title = 'Halálesetek száma',\n",
" height=1000,\n",
" width=1200,\n",
" geo = dict(\n",
" fitbounds='locations',\n",
" scope='europe',\n",
" #projection_type='albers usa',\n",
" showland = True,\n",
" landcolor = \"rgb(250, 250, 250)\",\n",
" subunitcolor = \"rgb(217, 217, 217)\",\n",
" countrycolor = \"rgb(217, 217, 217)\",\n",
" #countrywidth = 0.5,\n",
" #subunitwidth = 0.5\n",
" ),\n",
" )\n",
"fig.show()\n"
]
},
{
"cell_type": "markdown",
"id": "bb6b0eda-51f1-4bf9-b161-487db05e4ebc",
"metadata": {},
"source": [
"## Heti adatok"
]
},
{
"cell_type": "markdown",
"id": "770e6ba1-e48a-4fde-aa77-5b898e9853e5",
"metadata": {},
"source": [
"### Letoltes\n",
"https://atlo.team/koronaterkep/#megyeibovebb"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "40f6a53f-c929-4b86-b355-20997ca6adbe",
"metadata": {},
"outputs": [],
"source": [
"url = \"https://docs.google.com/spreadsheets/d/1djH-yUHLPwuEExCjiXS__6-8W2Yp_msFvShpL4bBcuM/export?format=xlsx&gid=1283792994\"\n",
"heti_df = pd.read_excel(url) "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2e89ed3a-3afe-42ee-b923-cd7e659ae9a8",
"metadata": {},
"outputs": [],
"source": [
"heti_df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c319fee-1e1b-4b8a-bea0-690b5e3d67d3",
"metadata": {},
"outputs": [],
"source": [
"df['text'] = df['Name'] + ': ' + df['Elhuyntak száma'].astype('str')\n",
"tdf = df[df['Elhuyntak száma']>0]#.head(100)\n",
"\n",
"\n",
"fig = go.Figure(data=go.Scattergeo(\n",
" #locationmode = 'USA-states',\n",
" lon = tdf['Lon'],\n",
" lat = tdf['Lat'],\n",
" text = tdf['text'],\n",
" mode = 'markers',\n",
" marker = dict(\n",
" size = np.log(tdf['Elhuyntak száma'])*5,\n",
" opacity = 0.6,\n",
" #color_continuous_scale=px.colors.sequential.Viridis,\n",
" #reversescale = True,\n",
" #autocolorscale = False,\n",
" symbol = 'circle',\n",
" line = dict(\n",
" width=1,\n",
" color='rgba(102, 102, 102)'\n",
" ),\n",
" cmin = 0,\n",
" color = np.log(tdf['Elhuyntak száma']),\n",
" cmax = np.log(tdf['Elhuyntak száma'].max()),\n",
" colorbar_title=\"Population\"\n",
" )))\n",
"\n",
"fig.update_layout(\n",
" title = 'Halálesetek száma',\n",
" height=1000,\n",
" width=1200,\n",
" geo = dict(\n",
" fitbounds='locations',\n",
" scope='europe',\n",
" #projection_type='albers usa',\n",
" showland = True,\n",
" landcolor = \"rgb(250, 250, 250)\",\n",
" subunitcolor = \"rgb(217, 217, 217)\",\n",
" countrycolor = \"rgb(217, 217, 217)\",\n",
" #countrywidth = 0.5,\n",
" #subunitwidth = 0.5\n",
" ),\n",
" )\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a60442e-74fa-45a3-a50c-6808c52c7ca9",
"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.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}