Skip to content

Commit

Permalink
Extend the matplotlib transforms mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Sep 7, 2021
1 parent 1d9090e commit 483fe17
Showing 1 changed file with 297 additions and 4 deletions.
301 changes: 297 additions & 4 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@

UNSET = type('UNSET', (), {})

_line_cap_bk_mpl_mapping = {
'butt': 'butt',
'round': 'round',
'square': 'projecting',
}
_text_baseline_bk_mpl_mapping = {
'top': 'top',
'middle': 'center',
'bottom': 'bottom',
'alphabetic': UNSET,
'hanging': UNSET,
'ideographic': UNSET,
}

BACKEND_TRANSFORMS = {
'matplotlib': {
Expand All @@ -56,13 +69,292 @@
'sizing_mode': UNSET,
'responsive': UNSET,
'shared_axes': UNSET,
'tools': UNSET
'shared_datasource': UNSET,
'selected': UNSET,
'tools': UNSET,
'active_tools': UNSET,
'default_tools': UNSET,
'toolbar': UNSET,
'align': UNSET,
'lod': UNSET,
'margin': UNSET,
'border': UNSET,
'jitter': UNSET,
'legend_muted': UNSET,
'legend_offset': UNSET,
'gridstyle': UNSET,
'colorbar_position': UNSET,
'violin_width': UNSET,
},
'style': {
'fill_color': lambda k, v: ('facecolors', v),
'bar_width': UNSET,
'size': lambda k, v: ('s', v),
'fill_color': lambda k, v: ('facecolor', v),
'fill_alpha': UNSET,
'line_alpha': UNSET,
'line_cap': lambda k, v: ('capstyle', _line_cap_bk_mpl_mapping.get(v, v)),
'line_color': lambda k, v: ('edgecolor', v),
'line_dash': lambda k, v: ('linestyle', v),
'line_join': lambda k, v: ('joinstyle', v),
'line_width': lambda k, v: ('linewidth', v),
'line_color': lambda k, v: ('edgecolors', v),
'nonselection_alpha': UNSET,
'nonselection_color': UNSET,
'nonselection_line_alpha': UNSET,
'nonselection_line_color': UNSET,
'selection_alpha': UNSET,
'selection_color': UNSET,
'selection_line_alpha': UNSET,
'selection_line_color': UNSET,
'hover_alpha': UNSET,
'hover_color': UNSET,
'hover_line_alpha': UNSET,
'hover_line_color': UNSET,
'muted': UNSET,
'muted_alpha': UNSET,
'muted_color': UNSET,
'muted_line_alpha': UNSET,
'muted_line_color': UNSET,
'click_policy': UNSET,
'annular_alpha': UNSET,
'annular_color': UNSET,
'annular_fill_alpha': UNSET,
'annular_fill_color': UNSET,
'annular_hover_alpha': UNSET,
'annular_hover_color': UNSET,
'annular_hover_fill_alpha': UNSET,
'annular_hover_fill_color': UNSET,
'annular_hover_line_alpha': UNSET,
'annular_hover_line_color': UNSET,
'annular_line_alpha': UNSET,
'annular_line_cap': UNSET,
'annular_line_color': lambda k, v: ('annular_edgecolors', v),
'annular_line_dash': UNSET,
'annular_line_join': UNSET,
'annular_line_width': lambda k, v: ('annular_linewidth', v),
'annular_muted': UNSET,
'annular_muted_alpha': UNSET,
'annular_muted_color': UNSET,
'annular_muted_fill_alpha': UNSET,
'annular_muted_fill_color': UNSET,
'annular_muted_line_alpha': UNSET,
'annular_muted_line_color': UNSET,
'annular_nonselection_alpha': UNSET,
'annular_nonselection_color': UNSET,
'annular_nonselection_fill_alpha': UNSET,
'annular_nonselection_fill_color': UNSET,
'annular_nonselection_line_alpha': UNSET,
'annular_nonselection_line_color': UNSET,
'annular_selection_alpha': UNSET,
'annular_selection_color': UNSET,
'annular_selection_fill_alpha': UNSET,
'annular_selection_fill_color': UNSET,
'annular_selection_line_alpha': UNSET,
'annular_selection_line_color': UNSET,
'annular_visible': UNSET,
'dilate': UNSET,
'ticks_text_align': UNSET,
'ticks_text_alpha': UNSET,
'ticks_text_baseline': UNSET,
'ticks_text_color': UNSET,
'ticks_text_font': UNSET,
'ticks_text_font_size': UNSET,
'ticks_text_font_style': UNSET,
'xmarks_alpha': UNSET,
'xmarks_color': UNSET,
'xmarks_hover_alpha': UNSET,
'xmarks_hover_color': UNSET,
'xmarks_hover_line_alpha': UNSET,
'xmarks_hover_line_color': UNSET,
'xmarks_line_alpha': UNSET,
'xmarks_line_cap': UNSET,
'xmarks_line_color': lambda k, v: ('xmarks_edgecolor', v),
'xmarks_line_dash': UNSET,
'xmarks_line_join': UNSET,
'xmarks_line_width': lambda k, v: ('xmarks_linewidth', v),
'xmarks_muted': UNSET,
'xmarks_muted_alpha': UNSET,
'xmarks_muted_color': UNSET,
'xmarks_muted_line_alpha': UNSET,
'xmarks_muted_line_color': UNSET,
'xmarks_nonselection_alpha': UNSET,
'xmarks_nonselection_color': UNSET,
'xmarks_nonselection_line_alpha': UNSET,
'xmarks_nonselection_line_color': UNSET,
'xmarks_selection_alpha': UNSET,
'xmarks_selection_color': UNSET,
'xmarks_selection_line_alpha': UNSET,
'xmarks_selection_line_color': UNSET,
'xmarks_visible': UNSET,
'ymarks_alpha': UNSET,
'ymarks_color': UNSET,
'ymarks_hover_alpha': UNSET,
'ymarks_hover_color': UNSET,
'ymarks_hover_line_alpha': UNSET,
'ymarks_hover_line_color': UNSET,
'ymarks_line_alpha': UNSET,
'ymarks_line_cap': UNSET,
'ymarks_line_color': lambda k, v: ('ymarks_edgecolor', v),
'ymarks_line_dash': UNSET,
'ymarks_line_join': UNSET,
'ymarks_line_width': lambda k, v: ('ymarks_linewidth', v),
'ymarks_muted': UNSET,
'ymarks_muted_alpha': UNSET,
'ymarks_muted_color': UNSET,
'ymarks_muted_line_alpha': UNSET,
'ymarks_muted_line_color': UNSET,
'ymarks_nonselection_alpha': UNSET,
'ymarks_nonselection_color': UNSET,
'ymarks_nonselection_line_alpha': UNSET,
'ymarks_nonselection_line_color': UNSET,
'ymarks_selection_alpha': UNSET,
'ymarks_selection_color': UNSET,
'ymarks_selection_line_alpha': UNSET,
'ymarks_selection_line_color': UNSET,
'ymarks_visible': UNSET,
'lower_head': lambda k, v: ('lolims', v),
'upper_head': lambda k, v: ('uplims', v),
'whisker_color': UNSET,
'outlier_color': UNSET,
'text_align': lambda k, v: ('horizontalalignment', v),
'text_alpha': lambda k, v: ('alpha', v),
'text_baseline': lambda k, v: ('verticalalignment', _text_baseline_bk_mpl_mapping.get(v, v)),
'text_color': lambda k, v: ('color', v),
'text_font': UNSET,
'text_font_size': lambda k, v: ('size', v),
'text_font_style': UNSET,
'box_alpha': UNSET,
'box_cmap': UNSET,
'box_fill_alpha': UNSET,
'box_fill_color': UNSET,
'box_hover_alpha': UNSET,
'box_hover_color': UNSET,
'box_hover_fill_alpha': UNSET,
'box_hover_fill_color': UNSET,
'box_hover_line_alpha': UNSET,
'box_hover_line_color': UNSET,
'box_line_alpha': UNSET,
'box_line_cap': UNSET,
'box_line_color': UNSET,
'box_line_dash': UNSET,
'box_line_join': UNSET,
'box_line_width': UNSET,
'box_muted': UNSET,
'box_muted_alpha': UNSET,
'box_muted_color': UNSET,
'box_muted_fill_alpha': UNSET,
'box_muted_fill_color': UNSET,
'box_muted_line_alpha': UNSET,
'box_muted_line_color': UNSET,
'box_nonselection_alpha': UNSET,
'box_nonselection_color': UNSET,
'box_nonselection_fill_alpha': UNSET,
'box_nonselection_fill_color': UNSET,
'box_nonselection_line_alpha': UNSET,
'box_nonselection_line_color': UNSET,
'box_selection_alpha': UNSET,
'box_selection_color': UNSET,
'box_selection_fill_alpha': UNSET,
'box_selection_fill_color': UNSET,
'box_selection_line_alpha': UNSET,
'box_selection_line_color': UNSET,
'box_visible': UNSET,
'median_alpha': UNSET,
'median_color': UNSET,
'outline_alpha': UNSET,
'outline_color': UNSET,
'outline_hover_alpha': UNSET,
'outline_hover_color': UNSET,
'outline_hover_line_alpha': UNSET,
'outline_hover_line_color': UNSET,
'outline_line_alpha': UNSET,
'outline_line_cap': UNSET,
'outline_line_color': UNSET,
'outline_line_dash': UNSET,
'outline_line_join': UNSET,
'outline_line_width': UNSET,
'outline_muted': UNSET,
'outline_muted_alpha': UNSET,
'outline_muted_color': UNSET,
'outline_muted_line_alpha': UNSET,
'outline_muted_line_color': UNSET,
'outline_nonselection_alpha': UNSET,
'outline_nonselection_color': UNSET,
'outline_nonselection_line_alpha': UNSET,
'outline_nonselection_line_color': UNSET,
'outline_selection_alpha': UNSET,
'outline_selection_color': UNSET,
'outline_selection_line_alpha': UNSET,
'outline_selection_line_color': UNSET,
'outline_visible': UNSET,
'stats_alpha': UNSET,
'stats_hover_alpha': UNSET,
'stats_hover_color': UNSET,
'stats_hover_line_alpha': UNSET,
'stats_hover_line_color': UNSET,
'stats_line_alpha': UNSET,
'stats_line_cap': UNSET,
'stats_line_color': UNSET,
'stats_line_dash': UNSET,
'stats_line_join': UNSET,
'stats_line_width': UNSET,
'stats_muted': UNSET,
'stats_muted_alpha': UNSET,
'stats_muted_color': UNSET,
'stats_muted_line_alpha': UNSET,
'stats_muted_line_color': UNSET,
'stats_nonselection_alpha': UNSET,
'stats_nonselection_color': UNSET,
'stats_nonselection_line_alpha': UNSET,
'stats_nonselection_line_color': UNSET,
'stats_selection_alpha': UNSET,
'stats_selection_color': UNSET,
'stats_selection_line_alpha': UNSET,
'stats_selection_line_color': UNSET,
'stats_visible': UNSET,
'violin_alpha': UNSET,
'violin_cmap': UNSET,
'violin_color': UNSET,
'violin_fill_alpha': UNSET,
'violin_fill_color': UNSET,
'violin_hover_alpha': UNSET,
'violin_hover_color': UNSET,
'violin_hover_fill_alpha': UNSET,
'violin_hover_fill_color': UNSET,
'violin_hover_line_alpha': UNSET,
'violin_hover_line_color': UNSET,
'violin_line_alpha': UNSET,
'violin_line_cap': UNSET,
'violin_line_color': UNSET,
'violin_line_dash': UNSET,
'violin_line_join': UNSET,
'violin_line_width': UNSET,
'violin_muted': UNSET,
'violin_muted_alpha': UNSET,
'violin_muted_color': UNSET,
'violin_muted_fill_alpha': UNSET,
'violin_muted_fill_color': UNSET,
'violin_muted_line_alpha': UNSET,
'violin_muted_line_color': UNSET,
'violin_nonselection_alpha': UNSET,
'violin_nonselection_color': UNSET,
'violin_nonselection_fill_alpha': UNSET,
'violin_nonselection_fill_color': UNSET,
'violin_nonselection_line_alpha': UNSET,
'violin_nonselection_line_color': UNSET,
'violin_selection_alpha': UNSET,
'violin_selection_color': UNSET,
'violin_selection_fill_alpha': UNSET,
'violin_selection_fill_color': UNSET,
'violin_selection_line_alpha': UNSET,
'violin_selection_line_color': UNSET,
'violin_visible': UNSET,
'editable': UNSET,
'fit_columns': UNSET,
'index_position': UNSET,
'row_headers': UNSET,
'scroll_to_selection': UNSET,
'selectable': UNSET,
'sortable': UNSET
},
},
'plotly': {
Expand All @@ -87,7 +379,6 @@
}



class StreamingCallable(Callable):
"""
StreamingCallable is a DynamicMap callback wrapper which keeps
Expand Down Expand Up @@ -672,6 +963,8 @@ def _transfer_opts(self, element, backend):
continue
elif transform:
opt, val = transform(opt, val)
if val is UNSET:
continue
if opt not in el_opts.allowed_keywords:
continue
new_opts[opt] = val
Expand Down

0 comments on commit 483fe17

Please sign in to comment.