2021年5月1日星期六

No color in folium choropleth legend implemented in pyqt5 and tooltips not showing

I'm having 2 problems with implementing folium in a pyqt5 UI:

  1. The legend in my choropleth is showing the correct numbers, but the color in the legend is not displaying! Here is the code. The .json and data can be found here:

https://github.com/python-visualization/folium/blob/master/examples/data/us-states.json

https://github.com/python-visualization/folium/blob/master/examples/data/US_Unemployment_Oct2012.csv

  1. The code snippet I have listed below is not showing tooltips! Any help would be appreciated!

The code to both questions is here:

from PyQt5.QtWebEngineWidgets import QWebEngineView  from PyQt5.QtWidgets import QApplication, QWidget, QFileDialog, QHBoxLayout, QVBoxLayout  from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets  import folium  import io  import pandas as pd  import os      class foliumWidget(QWidget):        def __init__(self, parent = None):          #super().__init__()          QWidget.__init__(self, parent)            layout = QVBoxLayout()          self.setLayout(layout)                                state_data = 'US_Unemployment_Oct2012.csv'          us_geo = 'us-states.json'                    df = pd.read_csv(state_data, na_values=[" "])                 m = folium.Map(location=[48, -102], tiles="cartodbpositron", zoom_start=3)              choropleth = folium.Choropleth(              geo_data= us_geo,              name="choropleth",              data=df,              columns=["State","Unemployment"],              key_on="feature.id",              fill_color="PuRd",              fill_opacity=0.7,              line_opacity=0.1,              legend_name="Unemployment",              reset=True,          ).add_to(m)            choropleth.geojson.add_child(              folium.features.GeoJsonTooltip(['State'])              )              #folium.LayerControl().add_to(m)          data = io.BytesIO()          m.save(data, close_file=False)              webView = QWebEngineView()          webView.setHtml(data.getvalue().decode())          layout.addWidget(webView)    

enter image description here

https://stackoverflow.com/questions/67352395/no-color-in-folium-choropleth-legend-implemented-in-pyqt5-and-tooltips-not-showi May 02, 2021 at 10:05AM

没有评论:

发表评论