-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Implement backend options transformer #653
Conversation
This is now in a reasonable state but the list of transforms is not at all exhaustive. So as you take over @maximlt here's what needs to be done. Basically I've transformed some of the most important options but there is a long tail of options which are currently not handled. As a start it would be great if you could go through all user guides and reference notebooks and visually compare the plotly and matplotlib output with the bokeh output. Another useful approach is to insert this print statement: if opt not in el_opts.allowed_keywords:
print(f'{opt} not supported')
... and see which options are currently being skipped and either make sure they are also UNSET (if not supported) or define the appropriate transform to ensure they are supported. |
Here is a small write-up to clarify our intent here. As of now hvplot relies obviously on holoviews which itself supports two additional backends: matplotlib and plotly. It seems natural then to add support in hvplot for these alternative backends. There's however code out there that surely relies on customizing plots with bokeh kwargs. Where this happens, hvplot should try its best to transform the bokeh options provided to options understood by the targeted backend. For instance, the This allows for instance a user to turn a notebook with bokeh plots to a notebook with matplotlib plots, while partly preserving the plot options originally defined for the bokeh backend. Note that this is not a dead-end, the underlying plot object can be accessed with # These two lines change the backend to matplotlib
import holoviews as hv
hv.extension('matplotlib')
import hvplot.pandas
df = ...
plot = df.hvplot.line(x='x', y='y', line_dash='dashed')
# Display plot in a cell
plot
# Get the Matplotlib figure to further customize it if required
fig = hv.render(plot)
...
fig.savefig('fig.png') What has not yet been done in this work is to directly deal with matplotlib or plotly options, e.g. what to do with |
Here's a list of the current issues observed while running all the notebooks with the PR in its current state. General:
User guides
Reference
Extras
|
EDIT 22/03/2022: Fixed @philippjfr about the issue with At this line Line 958 in 483fe17
the options I get for a Curve plot when I have declared that I want a Matplotlib plot (import holoviews as hv; hv.extension('matplotlib'); import hvplot.pandas ) are:
OrderedDict([('axiswise', False),
('color', Cycle()),
('framewise', True),
('height', 300),
('labelled', ['x', 'y']),
('line_width', 20),
('linewidth', 2),
('logx', False),
('logy', False),
('muted_alpha', 0.2),
('responsive', False),
('shared_axes', True),
('show_grid', False),
('show_legend', True),
('tools', ['hover']),
('width', 700)]) They include Is it expected that |
In the Plotting guide the call to create a Hexbin plot ( Since the following code correctly displays an image with the Matplotlib backend I assume this is a hvplot issue. hv.HexTiles(flights, kdims=['airtime', 'arrdelay']).opts(fig_size=200, logz=True, colorbar=True) The object returned by hvplot has this
while the one returned by holoviews has:
|
Executing this: fig = airports.hvplot.points('Longitude', 'Latitude', geo=True, color='red', alpha=0.2,
xlim=(-180, -30), ylim=(0, 72), tiles='ESRI') works correctly with the Bokeh backend but fails with a horrible error message (holoviz/geoviews#540) with the Matplotlib one. Interestingly
Anyway, One way to adapt the code to support plotting background tiles with the Matplotlib backend may be to use the WMTS elements provided by geoviews instead of the Tiles elements provided by holoviews, given that the latter have no projection. |
Plotly issues:General
Plotting notebook:
|
@jlstevens could you please review the last changes wrt compatibility? |
Other than the suggestion to update the parameter docstring, the latest changes look fine to me! |
"x = np.cumsum(np.random.normal(loc=1, scale=5, size=50))\n", | ||
"s = pd.Series(x, name='Time series')\n", | ||
"\n", | ||
"s.hvplot()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this is really related to this PR, but the lack of an x-axis label bothers me. What are the units? Absolute time or presumably time deltas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the exact same example as pandas' one, which doesn't mean it's perfect!
https://pandas.pydata.org/docs/reference/api/pandas.plotting.lag_plot.html
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"As we discovered in the [Introduction](Introduction.ipynb), HoloViews allows plotting a variety of data types. Here we will use the sample data module and load the pandas and dask hvPlot API:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a sentence along the lines of 'This notebook demonstrates the use of the Matplotlib plotting backend, the equivalent notebook demonstrating the Plotly backend may be found HERE (link)'
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"As we discovered in the [Introduction](Introduction.ipynb), HoloViews allows plotting a variety of data types. Here we will use the sample data module and load the pandas and dask hvPlot API:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for matplotlib. One sentence should be enough to link the contents of the notebook to the notebook title.
Made some suggestions for the docs but overall this looks good! |
Co-authored-by: Jean-Luc Stevens <[email protected]>
@jlstevens thanks for the review! I applied your suggestions in the last two commits. |
Tests look like they are passing and I'm happy to see it merge from my side! |
Enables plotting hvPlot output with HoloViews Matplotlib and Plotly backends.
Matplotlib
Plotly