Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo in MATPLOTLIB_TRANSFORMS #1380

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

LecrisUT
Copy link

@LecrisUT LecrisUT commented Jul 25, 2024

I was using these transforms manually (because I've had other issues with hvplot.extension(compatibility) not working) and I've encountered, at least one typo/renamed option. I did not look into other ones if there are more typos there.

I have encountered a few other issues that could be addressed here:

  • Missing markers compatibility. Reference 1 2
  • (marker) size is inconsistent, I am multiplying by 20 and seems alright?
  • Edges are not color linked by default. Don't know how to address this

@LecrisUT LecrisUT changed the title Fix typo in MATPLOTLIB_TRANSFORMS Fix typo in MATPLOTLIB_TRANSFORMS Jul 25, 2024
Copy link
Member

@maximlt maximlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LecrisUT, I'd appreciate if you could open different issues for what you reported here.

@@ -145,7 +145,7 @@ def _transfer_opts_cur_backend(element):
'style': {
'bar_width': UNSET,
'size': lambda k, v: ('s', v),
'fill_color': lambda k, v: ('facecolor', v),
'fill_color': lambda k, v: ('facecolors', v),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please demonstrate with an example the effect of this change? I think that HoloViews accepts either facecolor or facecolors as a style option for the Matplotlib backend, depending on the element type (e.g. https://github.com/holoviz/holoviews/blob/e6024ccc0c04e1b8678b76467491cf85c68a9aee/holoviews/plotting/mpl/chart.py#L215 and https://github.com/holoviz/holoviews/blob/e6024ccc0c04e1b8678b76467491cf85c68a9aee/holoviews/plotting/mpl/chart.py#L589). So we need to make sure what we map to exactly. And maybe, given the current mapping structure, it might not always be possible to map from a bokeh option to a mpl one if there are this kind of differences.

This comment was marked as outdated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me update the example based on #1378:

import hvplot.xarray
import holoviews
import xarray
from hvplot.backend_transforms import MATPLOTLIB_TRANSFORMS

hvplot.extension("bokeh", "matplotlib", compatibility="bokeh")

data = xarray.DataArray([0, 1, 2])
data.name="Needs a name"

hvplot.output(backend="matplotlib")

## Uncomment to see it fixed
# MATPLOTLIB_TRANSFORMS["style"]["fill_color"] = lambda k, v: ('facecolors', v)

overlay = holoviews.Overlay()
curve_line = data.hvplot(kind="line")
overlay *= curve_line
curve_scatter = data.hvplot(kind="scatter", fill_color="red", size=5000)
overlay *= curve_scatter
overlay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To illustrate what I mean with the complexity to map from a backend to another.

global_option_tree = hv.Store.options(backend='bokeh')
fill_color = []
for element, option_tree in global_option_tree.items():
    element = element[0]
    style_opts = option_tree.groups['style']
    allowed_styles = style_opts.allowed_keywords
    if 'fill_color' in allowed_styles:
        fill_color.append(str(element))

print('Bokeh')
print(f'fill_color: {sorted(fill_color)}')
print()

global_option_tree = hv.Store.options(backend='matplotlib')
facecolors = []
facecolor = []
for element, option_tree in global_option_tree.items():
    element = element[0]
    style_opts = option_tree.groups['style']
    allowed_styles = style_opts.allowed_keywords
    if 'facecolor' in allowed_styles:
        facecolor.append(str(element))
    if 'facecolors' in allowed_styles:
        facecolors.append(str(element))


print('Matplotlib')
print(f'facecolor: {sorted(facecolor)}')
print(f'facecolors: {sorted(facecolors)}')
Bokeh
fill_color: ['Area', 'Bars', 'Bivariate', 'Distribution', 'HSpan', 'HSpans', 'HeatMap', 'HexTiles', 'Histogram', 'Nodes', 'Points', 'Polygons', 'QuadMesh', 'Rectangles', 'Scatter', 'Spread', 'VSpan', 'VSpans']

Matplotlib
facecolor: ['Area', 'Bars', 'Bivariate', 'Distribution', 'HLines', 'HSpan', 'HSpans', 'Histogram', 'Polygons', 'Rectangles', 'Spread', 'VLines', 'VSpan', 'VSpans']
facecolors: ['Nodes', 'Points', 'Scatter', 'Scatter3D', 'Surface', 'VectorField', 'Violin']

So this is likely not a type, and needs more investigation to see whether changing it as suggested in the PR is worth it (i.e. another class of users happy with the current behavior may be unhappy with the new one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants