mirror of
https://github.com/marceloprates/prettymaps.git
synced 2025-08-01 04:10:32 +02:00
Merge
This commit is contained in:
@@ -27,6 +27,35 @@ from collections.abc import Iterable
|
||||
# Fetch
|
||||
from .fetch import *
|
||||
|
||||
# Helper functions
|
||||
def get_hash(key):
|
||||
return frozenset(key.items()) if type(key) == dict else key
|
||||
|
||||
# Drawing functions
|
||||
def show_palette(palette, description = ''):
|
||||
'''
|
||||
Helper to display palette in Markdown
|
||||
'''
|
||||
|
||||
colorboxes = [
|
||||
f''
|
||||
for c in palette
|
||||
]
|
||||
|
||||
display(Markdown((description)))
|
||||
display(Markdown(tabulate(pd.DataFrame(colorboxes), showindex = False)))
|
||||
|
||||
def get_patch(shape, **kwargs):
|
||||
'''
|
||||
Convert shapely object to matplotlib patch
|
||||
'''
|
||||
#if type(shape) == Path:
|
||||
# return patches.PathPatch(shape, **kwargs)
|
||||
if type(shape) == Polygon and shape.area > 0:
|
||||
return PolygonPatch(list(zip(*shape.exterior.xy)), **kwargs)
|
||||
else:
|
||||
return None
|
||||
|
||||
# Plot a single shape
|
||||
def plot_shape(shape, ax, vsketch = None, **kwargs):
|
||||
'''
|
||||
|
Reference in New Issue
Block a user