holoviz / hvplot

A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
https://hvplot.holoviz.org
BSD 3-Clause "New" or "Revised" License
1.14k stars 108 forks source link

While plotting a geojson Polygon with `geodataframe.hvplot.paths(geo=True)`, the Polygon is not enclosed in the resulting Bokeh plot #704

Open sunu opened 2 years ago

sunu commented 2 years ago

ALL software version info

hvplot '0.7.3' Python 3.10.0 bokeh 2.4.2 geoviews 1.9.3

Description of expected behavior and the observed behavior

I'm trying to plot a geojson Polygon as paths. But the Bokeh plot doesn't enclose the polygon.

Complete, minimal, self-contained example code that reproduces the issue

Here's the code to produce the behaviour:

import geopandas as gpd
import hvplot.pandas

import warnings
warnings.filterwarnings('ignore')

geojson = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              85.6167984008789,
              20.149751564715373
            ],
            [
              85.66426277160645,
              20.149751564715373
            ],
            [
              85.66426277160645,
              20.166913620901816
            ],
            [
              85.6167984008789,
              20.166913620901816
            ],
            [
              85.6167984008789,
              20.149751564715373
            ],
          ]
        ]
      }
    }
  ]
}

aoi = gpd.GeoDataFrame.from_features(geojson["features"])
geopath = aoi.hvplot.paths(geo=True, line_width=5)
geopath

Screenshots or screencasts of the bug in action

Here's screenshot of the resulting Bokeh plot:

image

Plotting the same Polygon with matplotlib results in a bounded box:

image

The same polygon also renders fine when geo=False: image

Let me know if I can provide any more info or if I'm doing something wrong while plotting.

jsignell commented 1 year ago

This is certainly an odd behavior, but I am wondering if as a workaround you might use:

aoi.hvplot.polygons(geo=True, line_width=5, fill_color=None)