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

Add layout properties for Bokeh backend. #1089

Merged
merged 28 commits into from
Feb 28, 2020
Merged

Conversation

ahartikainen
Copy link
Contributor

@ahartikainen ahartikainen commented Feb 26, 2020

Description

Use bokeh.layouts.layout by default, when show is True. This enables user to define rcParams for sizing_mode and also setting the toolbar_location.

Checklist

  • Follows official PR format
  • Includes a sample plot to visually illustrate the changes (only for plot-related functions)
  • New features are properly documented (with an example if appropriate)?
  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

@ahartikainen
Copy link
Contributor Author

We probably could add also rcParam for the plot output?

E.g. bokeh.layout.shape = default would use the default order given our plot. But user could set it for .. square which would unravel axes (remove None) and then reshape so the plots fill a square.

Maybe other options could be possible based on maximum columns and maximum rows?

layout also eats rugged list of lists, so we could have 3 / 2 / 3 structure etc?

Or maybe this could be a function that user can use manually (show=False)?

@ahartikainen
Copy link
Contributor Author

cc @sethaxen @AlexAndorra

@ahartikainen
Copy link
Contributor Author

import arviz as az
import bokeh.plotting as bkp
from bokeh.layouts import layout
import numpy as np

def make_square(arr):
    """Flat list to square"""
    n = np.ceil(len(arr)**0.5)
    new_arr = arr + [None for _ in range(n**2 - len(arr))]
    return np.array(new_arr).reshape(n,n).tolist()

az.backends.output_file("pair_plot_centered_eight.html")

data = az.load_arviz_data("centered_eight")
axes = az.plot_pair(data, backend="bokeh", divergences=True, show=False)
ravelled_axes = [ax for ax in axes.ravel() if ax is not None]
padded_square = make_square(ravelled_axes)
bkp.show(layout(padded_square, sizing_mode="stretch_both"))

@ahartikainen
Copy link
Contributor Author

I think this has the main functionality. We need to add examples at some point to docs.

@OriolAbril @canyon289 and others, any better names / functionality for the row / column hack?

Should we use ncolumn / nrow structure --> 3column 2column 5row 6row etc for rcParam? How should we handle those cases?

row or column in param --> regex --> if not found --> normal test?

fyi

3column --> three columns --> shape == (-1, 3)

@codecov
Copy link

codecov bot commented Feb 27, 2020

Codecov Report

Merging #1089 into master will decrease coverage by 14.22%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1089       +/-   ##
===========================================
- Coverage   93.45%   79.22%   -14.23%     
===========================================
  Files          93       93               
  Lines        8705     8775       +70     
===========================================
- Hits         8135     6952     -1183     
- Misses        570     1823     +1253     
Impacted Files Coverage Δ
arviz/data/io_emcee.py 12.50% <0.00%> (-85.84%) ⬇️
arviz/data/io_pystan.py 16.47% <0.00%> (-82.60%) ⬇️
arviz/data/io_tfp.py 14.42% <0.00%> (-81.74%) ⬇️
arviz/data/io_cmdstanpy.py 21.69% <0.00%> (-78.31%) ⬇️
arviz/data/io_pymc3.py 22.94% <0.00%> (-71.68%) ⬇️
arviz/data/io_pyro.py 25.92% <0.00%> (-71.30%) ⬇️
arviz/data/io_numpyro.py 25.23% <0.00%> (-66.36%) ⬇️
arviz/data/io_cmdstan.py 43.77% <0.00%> (-51.08%) ⬇️
arviz/data/base.py 89.02% <0.00%> (-10.98%) ⬇️
arviz/data/converters.py 65.15% <0.00%> (-1.52%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc20591...971049a. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Feb 27, 2020

Codecov Report

Merging #1089 into master will decrease coverage by 14.22%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1089       +/-   ##
===========================================
- Coverage   93.45%   79.22%   -14.23%     
===========================================
  Files          93       93               
  Lines        8705     8775       +70     
===========================================
- Hits         8135     6952     -1183     
- Misses        570     1823     +1253     
Impacted Files Coverage Δ
arviz/data/io_emcee.py 12.50% <0.00%> (-85.84%) ⬇️
arviz/data/io_pystan.py 16.47% <0.00%> (-82.60%) ⬇️
arviz/data/io_tfp.py 14.42% <0.00%> (-81.74%) ⬇️
arviz/data/io_cmdstanpy.py 21.69% <0.00%> (-78.31%) ⬇️
arviz/data/io_pymc3.py 22.94% <0.00%> (-71.68%) ⬇️
arviz/data/io_pyro.py 25.92% <0.00%> (-71.30%) ⬇️
arviz/data/io_numpyro.py 25.23% <0.00%> (-66.36%) ⬇️
arviz/data/io_cmdstan.py 43.77% <0.00%> (-51.08%) ⬇️
arviz/data/base.py 89.02% <0.00%> (-10.98%) ⬇️
arviz/data/converters.py 65.15% <0.00%> (-1.52%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc20591...971049a. Read the comment docs.

Ari Hartikainen and others added 2 commits February 27, 2020 17:38
@codecov
Copy link

codecov bot commented Feb 27, 2020

Codecov Report

Merging #1089 into master will decrease coverage by 12.15%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1089       +/-   ##
===========================================
- Coverage   91.58%   79.43%   -12.16%     
===========================================
  Files          93       93               
  Lines        8713     8850      +137     
===========================================
- Hits         7980     7030      -950     
- Misses        733     1820     +1087     
Impacted Files Coverage Δ
arviz/data/io_emcee.py 12.50% <0.00%> (-83.34%) ⬇️
arviz/data/io_tfp.py 14.42% <0.00%> (-81.74%) ⬇️
arviz/data/io_cmdstanpy.py 21.69% <0.00%> (-78.31%) ⬇️
arviz/data/io_pyro.py 25.92% <0.00%> (-71.30%) ⬇️
arviz/data/io_pymc3.py 22.94% <0.00%> (-69.70%) ⬇️
arviz/data/io_numpyro.py 25.23% <0.00%> (-66.36%) ⬇️
arviz/data/io_cmdstan.py 43.77% <0.00%> (-51.08%) ⬇️
arviz/data/io_pystan.py 16.47% <0.00%> (-46.64%) ⬇️
arviz/data/base.py 89.02% <0.00%> (-10.98%) ⬇️
arviz/data/converters.py 65.15% <0.00%> (-1.52%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a0f18d...0382f65. Read the comment docs.

@OriolAbril
Copy link
Member

LGTM

@ahartikainen ahartikainen merged commit 3605a75 into master Feb 28, 2020
@ahartikainen ahartikainen deleted the feature/bokeh_sizing_mode branch February 28, 2020 16:17
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