Skip to content

Commit

Permalink
fix docs right sidebar and bokeh deprecation warning (#2405)
Browse files Browse the repository at this point in the history
  • Loading branch information
OriolAbril authored Dec 20, 2024
1 parent adb2fef commit 63f8985
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 48 deletions.
6 changes: 5 additions & 1 deletion arviz/plots/backends/bokeh/densityplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ def _d_helper(

if point_estimate is not None:
est = calculate_point_estimate(point_estimate, vec, bw, circular)
plotted.append(ax.circle(est, 0, fill_color=color, line_color="black", size=markersize))
plotted.append(
ax.scatter(
est, 0, marker="circle", fill_color=color, line_color="black", size=markersize
)
)

_title = Title()
_title.text = vname
Expand Down
7 changes: 5 additions & 2 deletions arviz/plots/backends/bokeh/dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def plot_dot(

if plot_kwargs is None:
plot_kwargs = {}
plot_kwargs.setdefault("color", dotcolor)
else:
plot_kwargs = plot_kwargs.copy()
plot_kwargs.setdefault("color", dotcolor)
plot_kwargs.setdefault("marker", "circle")

if linewidth is None:
linewidth = auto_linewidth
Expand Down Expand Up @@ -95,7 +98,7 @@ def plot_dot(
stack_locs, stack_count = wilkinson_algorithm(values, binwidth)
x, y = layout_stacks(stack_locs, stack_count, binwidth, stackratio, rotated)

ax.circle(x, y, radius=dotsize * (binwidth / 2), **plot_kwargs, radius_dimension="y")
ax.scatter(x, y, radius=dotsize * (binwidth / 2), **plot_kwargs, radius_dimension="y")
if rotated:
ax.xaxis.major_tick_line_color = None
ax.xaxis.minor_tick_line_color = None
Expand Down
6 changes: 4 additions & 2 deletions arviz/plots/backends/bokeh/essplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ def plot_ess(
for (var_name, selection, isel, x), ax_ in zip(
plotters, (item for item in ax.flatten() if item is not None)
):
bulk_points = ax_.circle(np.asarray(xdata), np.asarray(x), size=6)
bulk_points = ax_.scatter(np.asarray(xdata), np.asarray(x), marker="circle", size=6)
if kind == "evolution":
bulk_line = ax_.line(np.asarray(xdata), np.asarray(x))
ess_tail = ess_tail_dataset[var_name].sel(**selection)
tail_points = ax_.line(np.asarray(xdata), np.asarray(ess_tail), color="orange")
tail_line = ax_.circle(np.asarray(xdata), np.asarray(ess_tail), size=6, color="orange")
tail_line = ax_.scatter(
np.asarray(xdata), np.asarray(ess_tail), marker="circle", size=6, color="orange"
)
elif rug:
if rug_kwargs is None:
rug_kwargs = {}
Expand Down
15 changes: 11 additions & 4 deletions arviz/plots/backends/bokeh/forestplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,10 @@ def forestplot(self, hdi_prob, quartiles, linewidth, markersize, ax, rope, plott
)
)
plotted[model_name].append(
ax.circle(
ax.scatter(
x=values[mid],
y=y,
marker="circle",
size=markersize * 0.75,
fill_color=color,
)
Expand All @@ -555,9 +556,10 @@ def plot_neff(self, ax, markersize, plotted):
for y, ess, color, model_name in plotter.ess():
if ess is not None:
plotted[model_name].append(
ax.circle(
ax.scatter(
x=ess,
y=y,
marker="circle",
fill_color=color,
size=markersize,
line_color="black",
Expand All @@ -582,8 +584,13 @@ def plot_rhat(self, ax, markersize, plotted):
for y, r_hat, color, model_name in plotter.r_hat():
if r_hat is not None:
plotted[model_name].append(
ax.circle(
x=r_hat, y=y, fill_color=color, size=markersize, line_color="black"
ax.scatter(
x=r_hat,
y=y,
marker="circle",
fill_color=color,
size=markersize,
line_color="black",
)
)
ax.x_range._property_values["start"] = 0.9 # pylint: disable=protected-access
Expand Down
6 changes: 4 additions & 2 deletions arviz/plots/backends/bokeh/khatplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,21 @@ def plot_khat(

if not isinstance(rgba_c, str) and isinstance(rgba_c, Iterable):
for idx, (alpha, rgba_c_) in enumerate(zip(alphas, rgba_c)):
ax.cross(
ax.scatter(
xdata[idx],
khats[idx],
marker="cross",
line_color=rgba_c_,
fill_color=rgba_c_,
line_alpha=alpha,
fill_alpha=alpha,
size=10,
)
else:
ax.cross(
ax.scatter(
xdata,
khats,
marker="cross",
line_color=rgba_c,
fill_color=rgba_c,
size=10,
Expand Down
12 changes: 9 additions & 3 deletions arviz/plots/backends/bokeh/lmplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ def plot_lm(

if y_kwargs is None:
y_kwargs = {}
else:
y_kwargs = y_kwargs.copy()
y_kwargs.setdefault("marker", "circle")
y_kwargs.setdefault("fill_color", "red")
y_kwargs.setdefault("line_width", 0)
y_kwargs.setdefault("size", 3)

if y_hat_plot_kwargs is None:
y_hat_plot_kwargs = {}
else:
y_hat_plot_kwargs = y_hat_plot_kwargs.copy()
y_hat_plot_kwargs.setdefault("marker", "circle")
y_hat_plot_kwargs.setdefault("fill_color", "orange")
y_hat_plot_kwargs.setdefault("line_width", 0)

Expand Down Expand Up @@ -84,7 +90,7 @@ def plot_lm(
_, _, _, y_plotters = y[i]
_, _, _, x_plotters = x[i]
legend_it = []
observed_legend = ax_i.circle(x_plotters, y_plotters, **y_kwargs)
observed_legend = ax_i.scatter(x_plotters, y_plotters, **y_kwargs)
legend_it.append(("Observed", [observed_legend]))

if y_hat is not None:
Expand All @@ -98,14 +104,14 @@ def plot_lm(
x_plotters_jitter = x_plotters + np.random.uniform(
low=-scale_high, high=scale_high, size=len(x_plotters)
)
posterior_circle = ax_i.circle(
posterior_circle = ax_i.scatter(
x_plotters_jitter,
y_hat_plotters[..., j],
alpha=0.2,
**y_hat_plot_kwargs,
)
else:
posterior_circle = ax_i.circle(
posterior_circle = ax_i.scatter(
x_plotters, y_hat_plotters[..., j], alpha=0.2, **y_hat_plot_kwargs
)
posterior_legend.append(posterior_circle)
Expand Down
4 changes: 2 additions & 2 deletions arviz/plots/backends/bokeh/mcseplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def plot_mcse(
values = data[var_name].sel(**selection).values.flatten()
if errorbar:
quantile_values = _quantile(values, probs)
ax_.dash(probs, quantile_values)
ax_.scatter(probs, quantile_values, marker="dash")
ax_.multi_line(
list(zip(probs, probs)),
[(quant - err, quant + err) for quant, err in zip(quantile_values, x)],
)
else:
ax_.circle(probs, x)
ax_.scatter(probs, x, marker="circle")
if extra_methods:
mean_mcse_i = mean_mcse[var_name].sel(**selection).values.item()
sd_mcse_i = sd_mcse[var_name].sel(**selection).values.item()
Expand Down
15 changes: 10 additions & 5 deletions arviz/plots/backends/bokeh/pairplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ def plot_pair(
)

reference_values_kwargs = _init_kwargs_dict(reference_values_kwargs)
reference_values_kwargs.setdefault("marker", "circle")
reference_values_kwargs.setdefault("line_color", "black")
reference_values_kwargs.setdefault("fill_color", vectorized_to_hex("C2"))
reference_values_kwargs.setdefault("line_width", 1)
reference_values_kwargs.setdefault("size", 10)

divergences_kwargs = _init_kwargs_dict(divergences_kwargs)
divergences_kwargs.setdefault("marker", "circle")
divergences_kwargs.setdefault("line_color", "black")
divergences_kwargs.setdefault("fill_color", vectorized_to_hex("C1"))
divergences_kwargs.setdefault("line_width", 1)
Expand Down Expand Up @@ -155,6 +157,7 @@ def plot_pair(
)

point_estimate_marker_kwargs = _init_kwargs_dict(point_estimate_marker_kwargs)
point_estimate_marker_kwargs.setdefault("marker", "square")
point_estimate_marker_kwargs.setdefault("size", markersize)
point_estimate_marker_kwargs.setdefault("color", "black")
point_estimate_kwargs.setdefault("line_color", "black")
Expand Down Expand Up @@ -265,9 +268,11 @@ def get_width_and_height(jointplot, rotate):
elif j + marginals_offset > i:
if "scatter" in kind:
if divergences:
ax[j, i].circle(var1, var2, source=source, view=source_nondiv)
ax[j, i].scatter(
var1, var2, marker="circle", source=source, view=source_nondiv
)
else:
ax[j, i].circle(var1, var2, source=source)
ax[j, i].scatter(var1, var2, marker="circle", source=source)

if "kde" in kind:
var1_kde = plotters[i][-1].flatten()
Expand All @@ -293,7 +298,7 @@ def get_width_and_height(jointplot, rotate):
)

if divergences:
ax[j, i].circle(
ax[j, i].scatter(
var1,
var2,
source=source,
Expand All @@ -306,7 +311,7 @@ def get_width_and_height(jointplot, rotate):
var2_pe = plotters[j][-1].flatten()
pe_x = calculate_point_estimate(point_estimate, var1_pe)
pe_y = calculate_point_estimate(point_estimate, var2_pe)
ax[j, i].square(pe_x, pe_y, **point_estimate_marker_kwargs)
ax[j, i].scatter(pe_x, pe_y, **point_estimate_marker_kwargs)

ax_hline = Span(
location=pe_y,
Expand Down Expand Up @@ -344,7 +349,7 @@ def get_width_and_height(jointplot, rotate):
x = reference_values_copy[flat_var_names[j + marginals_offset]]
y = reference_values_copy[flat_var_names[i]]
if x and y:
ax[j, i].circle(y, x, **reference_values_kwargs)
ax[j, i].scatter(y, x, **reference_values_kwargs)
ax[j, i].xaxis.axis_label = flat_var_names[i]
ax[j, i].yaxis.axis_label = flat_var_names[j + marginals_offset]

Expand Down
3 changes: 2 additions & 1 deletion arviz/plots/backends/bokeh/ppcplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,10 @@ def plot_ppc(
obs_yvals += np.random.uniform(
low=scale_low, high=scale_high, size=len(obs_vals)
)
glyph = ax_i.circle(
glyph = ax_i.scatter(
obs_vals,
obs_yvals,
marker="circle",
line_color=colors[1],
fill_color=colors[1],
size=markersize,
Expand Down
3 changes: 2 additions & 1 deletion arviz/plots/backends/bokeh/rankplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def plot_rank(

if marker_vlines_kwargs is None:
marker_vlines_kwargs = {}
marker_vlines_kwargs.setdefault("marker", "circle")

if backend_kwargs is None:
backend_kwargs = {}
Expand Down Expand Up @@ -109,7 +110,7 @@ def plot_rank(
elif kind == "vlines":
ymin = np.full(len(all_counts), all_counts.mean())
for idx, counts in enumerate(all_counts):
ax.circle(
ax.scatter(
bin_ary,
counts,
fill_color=colors[idx],
Expand Down
3 changes: 2 additions & 1 deletion arviz/plots/backends/bokeh/traceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,10 @@ def _plot_chains_bokeh(
**dealiase_sel_kwargs(trace_kwargs, chain_prop, chain_idx),
)
if marker:
ax_trace.circle(
ax_trace.scatter(
x=x_name,
y=y_name,
marker="circle",
source=cds,
radius=0.30,
alpha=0.5,
Expand Down
3 changes: 2 additions & 1 deletion arviz/plots/backends/bokeh/violinplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ def plot_violin(
[0, 0], per[:2], line_width=linewidth * 3, line_color="black", line_cap="round"
)
ax_.line([0, 0], hdi_probs, line_width=linewidth, line_color="black", line_cap="round")
ax_.circle(
ax_.scatter(
0,
per[-1],
marker="circle",
line_color="white",
fill_color="white",
size=linewidth * 1.5,
Expand Down
8 changes: 5 additions & 3 deletions arviz/plots/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,16 +482,18 @@ def plot_point_interval(
if point_estimate:
point_value = calculate_point_estimate(point_estimate, values)
if rotated:
ax.circle(
ax.scatter(
x=0,
y=point_value,
marker="circle",
size=markersize,
fill_color=markercolor,
)
else:
ax.circle(
ax.scatter(
x=point_value,
y=0,
marker="circle",
size=markersize,
fill_color=markercolor,
)
Expand Down Expand Up @@ -534,7 +536,7 @@ def set_bokeh_circular_ticks_labels(ax, hist, labels):
)

radii_circles = np.linspace(0, np.max(hist) * 1.1, 4)
ax.circle(0, 0, radius=radii_circles, fill_color=None, line_color="grey")
ax.scatter(0, 0, marker="circle", radius=radii_circles, fill_color=None, line_color="grey")

offset = np.max(hist * 1.05) * 0.15
ticks_labels_pos_1 = np.max(hist * 1.05)
Expand Down
14 changes: 0 additions & 14 deletions doc/_templates/layout.html

This file was deleted.

8 changes: 8 additions & 0 deletions doc/_templates/sourcelink.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# Displays a link to the .rst source of the current page. #}
{% if show_source and has_source and sourcename %}
<div class="tocsection sourcelink">
<a href="{{ pathto('_sources/' + sourcename, true)|e }}">
<i class="fa-solid fa-file-lines"></i> {{ _("Show Source") }}
</a>
</div>
{% endif %}
1 change: 0 additions & 1 deletion doc/_templates/twitter.html

This file was deleted.

7 changes: 2 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"navbar_start": ["navbar-logo", "navbar-version"],
"navbar_align": "content",
"header_links_before_dropdown": 5,
"secondary_sidebar_items": ["page-toc", "searchbox", "edit-this-page", "sourcelink", "donate"],
"secondary_sidebar_items": ["page-toc", "edit-this-page", "sourcelink", "donate"],
"use_edit_page_button": True,
"analytics": {"google_analytics_id": "G-W1G68W77YV"},
"external_links": [
Expand All @@ -219,10 +219,7 @@
"doc_path": "doc/source/",
"default_mode": "light",
}
html_sidebars: Dict[str, Any] = {
"index": [],
"community": ["search-field.html", "sidebar-nav-bs.html", "twitter.html"],
}
html_sidebars: Dict[str, Any] = {"index": []}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down

0 comments on commit 63f8985

Please sign in to comment.