Visualization

visualize accepts an ordinary function, a polynomial system, or an existing TriangulationCache. Functions and systems return (TC, fig); plotting an existing cache returns only the figure.

Refinement strategy

Choose where new samples are placed with strategy: :sierpinski (the default) uses edge midpoints, :barycenter uses centroids, and :random uses interior points.

TC, fig = visualize((x, y) -> x^2 + y^2; strategy=:barycenter)

Slices of higher-dimensional functions

For an ordinary function, input_dimension=n tells visualize how many coordinates each input point has. It chooses a random two-dimensional plane through the origin in that input space. For example, each input to f below has four coordinates, while the plot has two axes:

using AdaptiveVisualization

f(p) = sum(abs2, p)
TC, fig = visualize(f; input_dimension=4, batched=false)

Alternatively, supply near=p for a plane through p, or plane_points=[p, q, r] to specify the plane. Their point lengths determine the input dimension, so input_dimension can be omitted. HomotopyContinuation systems infer it from their parameters automatically.

TC.parameter_slice([u, v]) maps plot coordinates back to the original input space. zoomer scales the plane, and rng controls random plane selection.

Figure options

Use discrete=true for categorical values, including integer solution counts:

TC, fig = visualize((x, y) -> floor(Int, 4x); discrete=true)

This requires exact agreement of non-wildcard vertex values, hides incomplete triangles by default, and uses a categorical legend regardless of how many values occur. Mixed-value triangles are never colored with an averaged value in this mode. A custom is_complete predicate still controls refinement.

Use discrete=false for continuous numeric values and a colorbar. Omitting discrete keeps automatic detection. The setting is retained by the cache during refinement and navigation. For an existing cache, visualize(TC; discrete=true) updates its classification without resampling; discrete=nothing restores the evaluator's default. Ordinary functions use automatic detection, while HomotopyContinuation solution counters default to discrete behavior. An explicit discrete=false overrides either default.

Categorical legends show only values on colored triangles in the current window. They update when you zoom or pan, including with the mouse. Colors remain assigned to the same values across window changes and refinement; newly discovered values do not change existing assignments. Legend entries are sorted independently of those assignments. Values found only on uncolored triangles are omitted.

discrete_legend remains available as a legend-only override: true forces a categorical legend and false a colorbar. show_legend=false hides either. Use edges=true to show triangle boundaries, and figure_padding=(20, 20, 20, 40) to set the left, right, bottom, and top margins. Set buttons=false to omit interactive controls.

Methods

AdaptiveVisualization.visualize — Function
visualize(TC::TriangulationCache; kwargs...) -> GLMakie.Figure

Render a TriangulationCache using GLMakie.

Categorical legends list only values on colored triangles visible in the current window, updating during mouse zoom/pan and navigation-button redraws. Colors are retained across window changes and refinement: newly discovered values receive colors without reassigning existing ones. Legend entries are sorted independently of color assignment. Values that occur only in uncolored triangles are omitted.

Useful keyword arguments:

  • buttons: add interactive refinement controls, default true.
  • button_refinement_passes: number of refinement passes per button click.
  • navigation_step: arrow-button pan amount as a fraction of window size.
  • zoom_step: zoom amount as a fraction of window size.
  • navigation_refinement_budget: maximum new refinement samples after pan/zoom, in addition to samples used to seed the new window.
  • navigation_initial_resolution: coarse mesh size seeded after pan/zoom.
  • min_refinement_area_controls: add a slider that selects the normalized minimum used by the Fully Refine button.
  • min_refinement_area_slider_range: integer exponents for a normalized minimum area of 1e-X, default 2:6.
  • figure_size: Makie figure size, default (1300, 900) with buttons enabled or (900, 900) when buttons=false.
  • figure_padding: outer margins (left, right, bottom, top), default (20, 20, 20, 40). A single number applies to all sides.
  • xlabel: axis x label, default "x".
  • ylabel: axis y label, default "y".
  • xlabelsize: axis x label font size, default Makie axis label size.
  • ylabelsize: axis y label font size, default Makie axis label size.
  • xticklabelsize: axis x tick label font size, default Makie tick label size.
  • yticklabelsize: axis y tick label font size, default Makie tick label size.
  • title: axis title, default "".
  • titlesize: axis title font size, default Makie axis title size.
  • discrete: true requires exact agreement of non-wildcard vertex values, hides incomplete triangles by default, and selects a categorical legend. Mixed-value triangles remain uncolored even with plot_all_triangles=true. false uses continuous numeric behavior and a colorbar; nothing uses the evaluator's default, or automatic detection for ordinary functions. Omission retains the cache's setting. Changing it updates the cache's completeness rule and triangle classification without resampling; custom is_complete predicates are preserved. HomotopyContinuation solution counters default to true, which an explicit false overrides.
  • plot_all_triangles: include incomplete triangles in the colored mesh. Defaults to false for discrete caches and true for continuous caches.
  • edges: overlay thin triangle edges, default false.
  • plot_triangle_edges: deprecated alias for edges.
  • triangle_edge_color: edge overlay color.
  • triangle_edge_linewidth: edge overlay line width.
  • show_legend: show legends and colorbars, default true.
  • legend_max_values: categorical legend threshold, default 20.
  • discrete_legend: optional legend-only override, retained for compatibility. true selects a categorical legend and false a colorbar, taking precedence over discrete for the legend only. Default nothing follows discrete, or chooses using legend_max_values when discrete=nothing. show_legend=false hides either; no legend is drawn if no non-wildcard values are visible.
source
visualize(function_oracle::Function; kwargs...) -> (TriangulationCache, GLMakie.Figure)

Construct, refine, display, and return a TriangulationCache and its Makie figure. total_resolution is the maximum number of sampled input points (default 1000), counting initialization and refinement, unless min_refinement_area is supplied. In that case, refinement continues until no incomplete triangle in the current window exceeds min_refinement_area * window_area. If initial_resolution is supplied, it controls the initialization mesh size; otherwise initialization uses one quarter of total_resolution. An explicit initial_resolution larger than the default total raises the effective total unless total_resolution was explicitly supplied. The remaining budget uses the number of points actually initialized.

The strategy keyword selects refinement points for incomplete triangles: :sierpinski (default) samples the three edge midpoints, :barycenter samples the centroid, and :random samples a random interior point. The selected strategy is stored in the returned cache and used for subsequent refinement.

Set discrete=true for categorical values such as solution counts. It requires exact value agreement for completeness, hides incomplete triangles by default, and selects a categorical legend regardless of the number of values. discrete=false uses continuous numeric behavior and a colorbar; the default nothing uses the evaluator's default, or automatic detection for ordinary functions. HomotopyContinuation solution counters default to true, which an explicit false overrides. A custom is_complete predicate overrides the built-in completeness rule.

For ordinary functions, input_dimension=n specifies the number of coordinates in each input point and selects a random two-dimensional plane through the origin. Its default is nothing; supply near or plane_points=[p,q,r] to infer the input dimension from those points instead. For two-dimensional inputs, the original axis directions are retained. The plot always has two axes. zoomer scales the plane and rng selects its random directions. The original coordinates are retained in TC.parameter_slice for retrieve_witnesses(TC). Set batched=false for a single-point function whose batch call could look valid by accident; use batched=true to require a batch oracle. Omission keeps automatic detection. Sampling budgets count individual points, even when the function evaluates several points in a single batched call.

Figure options such as discrete_legend, figure_padding, and buttons are forwarded to visualize(TC; kwargs...); see that method’s keyword descriptions.

source
visualize(F::HomotopyContinuation.System; func=:real, near=nothing,
          plane_points=nothing, kwargs...) -> (TriangulationCache, GLMakie.Figure)

Visualize solution counts or an imaginary-part diagnostic on an affine parameter plane. Load both AdaptiveVisualization and HomotopyContinuation to enable this method.

func defaults to :real (numerical real counts) and also accepts :certify_real (soft-certified real counts), :positive (numerical strictly positive real counts), and :dietmaier (minimum nonzero imaginary L1 norm). The latter uses imaginary_zero_atol=1e-10 and returns zero when no norm exceeds that tolerance. plane_points=[p,q,r] overrides near and maps plot coordinates (u,v) to p + zoomer*(u*(q-p) + v*(r-p)). Without plane_points, two-parameter systems keep their original axis directions, centered at near or zero. Larger parameter spaces use random orthonormal directions through near, or the origin if omitted. At least two parameters are required. xlims and ylims refer to plot coordinates. The returned cache retains this map in TC.parameter_slice; retrieve_witnesses(TC) returns sampled witnesses in the original parameter coordinates for discrete caches.

The :real, :positive, and :certify_real modes default to discrete=true, requiring exact count agreement under the default completeness rule and a categorical legend regardless of the number of counts. Pass discrete=false to use continuous behavior instead. The :dietmaier diagnostic retains automatic classification unless discrete is supplied. discrete_legend can still override only the legend.

The legend title defaults to n_real for :real and :certify_real, and n_pos for :positive. Pass legend_title to override it.

The :certify_real mode provides soft certificates for floating-point input, not guarantees about an intended exact model or input rounding. See AdaptiveVisualization.certify_real and AdaptiveVisualization.real_solution_function for numerical options. Remaining keywords are forwarded to the ordinary function-based visualize.

source