Hello There!
my code ouputs two choropleth-georef-figs: fig1 and fig2. However, I don’t know how to plot both figs whitin the same page and how to set them in vertical or horizontal layout (side by side or top/bottom).
this code doesn’t work:
from plotly.offline import plot
plot(fig1,fig2)
following works but is not what I want. It creates two separate chrome-tabs for each plot.
plot(fig1)
plot(fig2)
I know it should be something with subplots but no idea how to handle choropleth_mapbox with subplots.
Any help?
Thanks in advance!
Best, A.
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 18:17:57 2020
@author: ale
"""
import fileinput
import sys
import numpy as np
import scipy.integrate as intgr
import matplotlib.pyplot as plt
#%matplotlib qt
from urllib.request import urlopen
import json
geoprov = 'C:/Users/ale/OneDrive/Ale/COVID/grafici/limits_IT_provinces.json'
with open(geoprov, 'r') as response:
geo = json.load(response)
# geoprov ='https://githubusercontent.com/openpolis/geojson-italy/master/geojson/limits_IT_provinces.json'
# with urlopen(geoprov, 'r') as response:
# geo = json.load(response)
import plotly.express as px
#filedata = 'C:/Users/ale/OneDrive/Ale/COVID/grafici/dpc-covid19-ita-province-latest.csv'
filedata = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-province/dpc-covid19-ita-province-latest.csv"
import pandas as pd
import requests
df = pd.read_csv(filedata,dtype={"sigla_provincia": str},error_bad_lines=True)
fig1 = px.choropleth_mapbox(df, geojson=geo, color="totale_casi",
locations="sigla_provincia", featureidkey="properties.prov_acr",
center={"lat": 42.35, "lon": 14.70},
mapbox_style="carto-positron", zoom=5,
labels={'totale_casi':'Totale casi al 04/04'})
fig1.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig1.show()
filedata = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-province/dpc-covid19-ita-province-20200310.csv"
df = pd.read_csv(filedata,dtype={"sigla_provincia": str},error_bad_lines=True)
fig2 = px.choropleth_mapbox(df, geojson=geo, color="totale_casi",
locations="sigla_provincia", featureidkey="properties.prov_acr",
center={"lat": 42.35, "lon": 14.70},
mapbox_style="carto-positron", zoom=5,
labels={'totale_casi':'Totale casi al 04/04'})
fig2.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig2.show()
from plotly.offline import plot
plot(fig1)
plot(fig2)