holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
577 stars 75 forks source link

mpl backend Shape turns LineString into Polygons #294

Open poplarShift opened 5 years ago

poplarShift commented 5 years ago

Is there a reason for this behaviour? Could the same logic that is currently used for the bokeh backend be used to implement the distinction for mpl as well?

(If anyone's wondering, I use the mpl backend only for svg export.)

Compare

import geoviews as gv
from shapely.geometry import LineString
gv.extension('bokeh')
gv.Shape(LineString([(0,0),(0,1),(1,0)])).opts(xlim=(-.5,1.5), ylim=(-.5,1.5))

https://github.com/pyviz/geoviews/blob/56784cddefeca40e969da97f4d029cfa802ce503/geoviews/plotting/bokeh/__init__.py#L171

bokeh

with

gv.extension('matplotlib')
gv.Shape(LineString([(0,0),(0,1),(1,0)])).opts(xlim=(-.5,1.5), ylim=(-.5,1.5))

https://github.com/pyviz/geoviews/blob/56784cddefeca40e969da97f4d029cfa802ce503/geoviews/plotting/mpl/__init__.py#L302

mpl

philippjfr commented 5 years ago

Thanks for the issue, and yes, that logic should be used here too.

poplarShift commented 4 years ago

For the record, when specifying color, the matplotlib backend still gives filled Polygons even for LineStrings:

import geoviews as gv
from shapely.geometry import LineString
gv.extension('matplotlib')
gv.Shape(LineString([(0,0),(0,1),(1,0)])).opts(xlim=(-.5,1.5), ylim=(-.5,1.5), color='red')

This is easy to fix, one would just have to pass the color option into "facecolor" instead. Currently that might be non-intuitive for end users.