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

PolarAxis improvements (full rlimits, thetalimits, improved controls, argument order) #3154

Merged
merged 109 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
0624e50
prototype new clip
ffreyer Aug 14, 2023
10040f4
render spine through clip
ffreyer Aug 14, 2023
72e9584
clamp grid lines to clipped area
ffreyer Aug 14, 2023
f9ab16d
improve tick align a little
ffreyer Aug 14, 2023
29bf8fd
Merge branch 'master' into ff/polar_segments
ffreyer Aug 15, 2023
ab160a0
fix angle conversion
ffreyer Aug 15, 2023
37befc3
consider direction and theta_0 in clip poly
ffreyer Aug 15, 2023
c8f796e
fix zoom error
ffreyer Aug 15, 2023
bf0d77d
update camera
ffreyer Aug 15, 2023
9a7b31f
minor cleanup
ffreyer Aug 15, 2023
0aaec33
fix tick align
ffreyer Aug 15, 2023
14e9330
add maximum_clip_radius
ffreyer Aug 17, 2023
e77e100
set up translating controls
ffreyer Aug 17, 2023
c9e045e
improve theta translation
ffreyer Aug 17, 2023
e8cedec
move some code around
ffreyer Aug 17, 2023
81fe7ba
stop drag rotation from rotating clip
ffreyer Aug 17, 2023
dc30f17
add thetalims
ffreyer Aug 17, 2023
f17d94a
improve radial translation
ffreyer Aug 17, 2023
4c948a6
add AngularTicks
ffreyer Aug 18, 2023
aa03956
Merge branch 'master' into ff/polar_segments
ffreyer Aug 18, 2023
bfee68f
improve rticklabel placement
ffreyer Aug 19, 2023
056f351
reduce observable update frequency
ffreyer Aug 19, 2023
a2d09f6
always push rticklabels clockwise
ffreyer Aug 19, 2023
0e64a0a
handle thetatick offsets like rticks
ffreyer Aug 19, 2023
b40c0a2
split up clip to avoid polygon recreation
ffreyer Aug 19, 2023
2f01ef6
cleanup
ffreyer Aug 19, 2023
e923bab
update NEWS
ffreyer Aug 19, 2023
0b521ce
don't allocate space for empty titles
ffreyer Aug 19, 2023
dd42dec
fix clip rotation
ffreyer Aug 19, 2023
1f37b65
restrict translation start to PolarAxis scene
ffreyer Aug 19, 2023
0c1020a
add refimg test
ffreyer Aug 19, 2023
9d2a402
add zoomspeed and update interactivity docs
ffreyer Aug 20, 2023
ac064c4
limit docs + tick alignment tweaks
ffreyer Aug 20, 2023
3091f1e
cleanup up `Makie.`
ffreyer Aug 20, 2023
fb910d1
tweak depth order
ffreyer Aug 20, 2023
b50061a
add missing observable tracking
ffreyer Aug 21, 2023
b0f8c72
Merge branch 'master' into ff/polar_segments
ffreyer Aug 21, 2023
b1cbc68
fix some errors
ffreyer Aug 21, 2023
febb7bc
fix rtick align with direction
ffreyer Aug 21, 2023
7548b95
fix clip and spine angle resolution
ffreyer Aug 21, 2023
708ee04
make translations aware of direction
ffreyer Aug 21, 2023
85488b6
default to no distortion & add note in docs
ffreyer Aug 21, 2023
61d5929
reorganize attributes
ffreyer Aug 21, 2023
c8ee936
use sample_density for clip and spine
ffreyer Aug 21, 2023
7745b53
consider rticks when reserving space for ticks
ffreyer Aug 21, 2023
a6fb146
Merge branch 'master' into ff/polar_segments
ffreyer Aug 21, 2023
41bef73
add target_thetalims
ffreyer Aug 22, 2023
2efbf25
Merge branch 'master' into ff/polar_segments
ffreyer Aug 22, 2023
8c30292
fix tick based error
ffreyer Aug 22, 2023
b813a33
rework zoom
ffreyer Aug 22, 2023
55b06d6
rweork translation and add clip rotation
ffreyer Aug 25, 2023
9eb6b94
improve clip quality
ffreyer Aug 25, 2023
00862d6
add `theta_as_x` and switch arg order by default
ffreyer Aug 25, 2023
96a3500
place grid behind plots by default
ffreyer Aug 25, 2023
cbcd085
Merge branch 'master' into ff/polar_segments
ffreyer Aug 25, 2023
4c1d3b6
reorganize attributes
ffreyer Aug 25, 2023
5d9fb71
improve clip rotation
ffreyer Aug 25, 2023
25a32f9
add rtickrotation
ffreyer Aug 25, 2023
83e57e8
clean up prints
ffreyer Aug 25, 2023
96116b6
fix and extend unit tests
ffreyer Aug 25, 2023
28e50bd
fix autolimits
ffreyer Aug 25, 2023
c2a98c8
fix default limits
ffreyer Aug 25, 2023
b208bd8
fix/tweak current refimgs
ffreyer Aug 25, 2023
4e1b2ce
rename some attributes
ffreyer Aug 26, 2023
115a861
test rticklabelrotation & pad
ffreyer Aug 26, 2023
c35d36b
automatically determine all limits
ffreyer Aug 27, 2023
2401360
add convenience function for 0..2pi PolarAxis
ffreyer Aug 27, 2023
097fb1d
tweak names
ffreyer Aug 27, 2023
035c77d
clip_rotation_button -> axis_rotation_button
ffreyer Aug 27, 2023
d25ec10
snap default limits to full circle
ffreyer Aug 27, 2023
85bd8f7
consider rtick pad when reserving space
ffreyer Aug 27, 2023
a32458a
fix title placement
ffreyer Aug 27, 2023
b29d53c
fix translation with multiple scenes
ffreyer Aug 27, 2023
97b0bb2
cleanup epsilon
ffreyer Aug 27, 2023
22891a2
fix voronoiplot
ffreyer Aug 27, 2023
4471f9d
rename griddepth to gridz
ffreyer Aug 27, 2023
b71d4e4
cleanup limit snapping
ffreyer Aug 27, 2023
51349fd
fix title positions
ffreyer Aug 27, 2023
95de6ef
update docs
ffreyer Aug 27, 2023
240e380
add some type annotations
ffreyer Aug 27, 2023
ae43c27
use atol instead of rtol
ffreyer Aug 27, 2023
7ba84a9
fix empty axis limits, test distortion
ffreyer Aug 28, 2023
0d32bf5
update NEWS [skip ci]
ffreyer Aug 28, 2023
3ac2d0f
Merge branch 'master' into ff/polar_segments
ffreyer Aug 29, 2023
153b9af
make linting happy
ffreyer Aug 30, 2023
8bcf4cf
improve axis reset
ffreyer Aug 30, 2023
e85372b
fix typo
ffreyer Aug 30, 2023
02b4149
switch back to full circle by default
ffreyer Aug 30, 2023
01df4b1
improve interactive theta tick normalization
ffreyer Aug 30, 2023
4be97c8
fix bad tick rounding
ffreyer Aug 30, 2023
e54422d
Merge branch 'master' into ff/polar_segments
ffreyer Aug 30, 2023
f716c35
update test
ffreyer Aug 30, 2023
2c39981
update docs, fix tick label error, tweak default labels
ffreyer Aug 30, 2023
1d91030
adjust default interactions, add zoomlocks
ffreyer Aug 30, 2023
c3bd4e0
update docs
ffreyer Aug 30, 2023
d733ccb
Merge branch 'master' into ff/polar_segments
ffreyer Aug 31, 2023
14e6093
Merge branch 'master' into ff/polar_segments
SimonDanisch Sep 12, 2023
7c8f0bb
set up tightlimits logic for PolarAxis
ffreyer Sep 12, 2023
e647c45
fix tests, add test for tight limits
ffreyer Sep 12, 2023
65dbeec
Merge branch 'master' into ff/polar_segments
SimonDanisch Sep 12, 2023
f7c3713
fix arg order related errors
ffreyer Sep 13, 2023
7045f86
fix spine attribute pasthrough
ffreyer Sep 19, 2023
2607b34
fix lazy limit reset
ffreyer Sep 19, 2023
aa926b3
Merge branch 'master' into ff/polar_segments
SimonDanisch Sep 20, 2023
4cb6b89
undo tight limits for surface
ffreyer Sep 20, 2023
a3956bf
don't rotate rtick labels with full limits
ffreyer Sep 20, 2023
d3bf414
fix tightlimits test
ffreyer Sep 20, 2023
fde215d
update tests
ffreyer Sep 20, 2023
82673df
tweak docs
ffreyer Sep 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## master

- [Breaking] Changed the default order Polar arguments to (theta, r). [#3154](https://github.com/MakieOrg/Makie.jl/pull/3154)
- General improvements to `PolarAxis`: full rlimtis & thetalimits, more controls and visual tweaks. See pr for more details.[#3154](https://github.com/MakieOrg/Makie.jl/pull/3154)

## v0.19.9

- Allow arbitrary reversible scale functions through `ReversibleScale`.
Expand Down
6 changes: 3 additions & 3 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ end
@reference_test "Triplot with nonlinear transformation" begin
f = Figure()
ax = PolarAxis(f[1, 1])
points = Point2f[(r, phi) for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
points = Point2f[(phi, r) for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
tr = triplot!(ax, points)
f
end
Expand Down Expand Up @@ -1303,13 +1303,13 @@ end

@reference_test "Voronoiplot with a nonlinear transform" begin
f = Figure()
ax = PolarAxis(f[1, 1])
ax = PolarAxis(f[1, 1], theta_as_x = false)
points = Point2f[(r, phi) for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
polygon_color = [r for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
polygon_color_2 = [phi for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
tr = voronoiplot!(ax, points, smooth = false, show_generators = false, color = polygon_color)
Makie.rlims!(ax, 12) # to make rect clip visible if circular clip doesn't happen
ax = PolarAxis(f[1, 2])
ax = PolarAxis(f[1, 2], theta_as_x = false)
tr = voronoiplot!(ax, points, smooth = true, show_generators = false, color = polygon_color_2)
Makie.rlims!(ax, 12)
f
Expand Down
32 changes: 25 additions & 7 deletions ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,25 @@ end
@reference_test "PolarAxis surface" begin
f = Figure()
ax = PolarAxis(f[1, 1])
zs = [r*cos(phi) for r in range(1, 2, length=100), phi in range(0, 4pi, length=100)]
p = surface!(ax, 0..10, 0..2pi, zs, shading = false, colormap = :coolwarm, colorrange=(-2, 2))
zs = [r*cos(phi) for phi in range(0, 4pi, length=100), r in range(1, 2, length=100)]
p = surface!(ax, 0..2pi, 0..10, zs, shading = false, colormap = :coolwarm, colorrange=(-2, 2))
rlims!(ax, 0, 11) # verify that r = 10 doesn't end up at r > 10
translate!(p, 0, 0, -200)
Colorbar(f[1, 2], p)
f
end

# may fail in WGLMakie due to missing dashes
@reference_test "PolarAxis scatterlines spine" begin
f = Figure(resolution = (800, 400))
ax1 = PolarAxis(f[1, 1], title = "No spine", spinevisible = false)
ax1 = PolarAxis(f[1, 1], title = "No spine", spinevisible = false, theta_as_x = false)
scatterlines!(ax1, range(0, 1, length=100), range(0, 10pi, length=100), color = 1:100)

ax2 = PolarAxis(f[1, 2], title = "Modified spine")
ax2.spinecolor[] = :red
ax2.spinestyle[] = :dash
ax2.spinewidth[] = 5
scatterlines!(ax2, range(0, 1, length=100), range(0, 10pi, length=100), color = 1:100)

scatterlines!(ax2, range(0, 10pi, length=100), range(0, 1, length=100), color = 1:100)
f
end

Expand All @@ -174,14 +175,31 @@ end
thetaminorgridwidth = 1.0, thetaminorgridstyle = :dash,
rgridwidth = 2, rgridcolor = :red,
thetagridwidth = 2, thetagridcolor = :blue,
rticklabelsize = 18, rticklabelcolor = :red,
rticklabelsize = 18, rticklabelcolor = :red, rtickangle = pi/6,
rticklabelstrokewidth = 1, rticklabelstrokecolor = :white,
thetaticklabelsize = 18, thetaticklabelcolor = :blue,
thetaticklabelstrokewidth = 1, thetaticklabelstrokecolor = :white,
)
f
end

@reference_test "PolarAxis limits" begin
f = Figure(resolution = (800, 600))
for (i, theta_0) in enumerate((0, -pi/6, pi/2))
for (j, thetalims) in enumerate(((0, 2pi), (-pi/2, pi/2), (0, pi/12)))
po = PolarAxis(f[i, j], theta_0 = theta_0, thetalimits = thetalims, rlimits = (1 + 2(j-1), 7))
po.scene.backgroundcolor[] = RGBAf(1,0.5,0.5,1)
lines!(po, range(0, 20pi, length=201), range(0, 10, length=201), color = :white, linewidth = 5)

b = Box(f[i, j], color = (:blue, 0.2))
translate!(b.blockscene, 0, 0, 9001)
end
end
colgap!(f.layout, 5)
rowgap!(f.layout, 5)
f
end

@reference_test "Axis3 axis reversal" begin
f = Figure(resolution = (1000, 1000))
revstr(dir, rev) = rev ? "$dir rev" : ""
Expand Down Expand Up @@ -223,4 +241,4 @@ end
Colorbar(fig[3, :][1, 2], hm; width=200)

fig
end
end
156 changes: 125 additions & 31 deletions docs/reference/blocks/polaraxis.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# PolarAxis

The `PolarAxis` is an axis for data in polar coordinates `(radius, angle)`. It
is currently an experimental feature, meaning that some functionality might be
missing or broken, and that the `PolarAxis` is (more) open to breaking changes.
The `PolarAxis` is an axis for data given in polar coordinates, i.e a radius and an angle.
It is currently an experimental feature, meaning that some functionality might be missing or broken, and that the `PolarAxis` is (more) open to breaking changes.

## Creating a PolarAxis

Expand All @@ -23,29 +22,79 @@ f

## Plotting into an PolarAxis

Like with an `Axis` you can use mutating 2D plot functions directly on a
`PolarAxis`. The input arguments of the plot functions will then be interpreted
in polar coordinates, i.e. as a radius and angle (in radians).
Like with an `Axis` you can use mutating 2D plot functions directly on a `PolarAxis`.
The input arguments of the plot functions will then be interpreted in polar coordinates, i.e. as an angle (in radians) and a radius.
The order of a arguments can be changed with `ax.theta_as_x`.

\begin{examplefigure}{svg = true}
```julia
lineobject = lines!(ax, 0..10, sin, color = :red)
scatobject = scatter!(0:0.5:10, cos, color = :orange)
f = Figure(resolution = (800, 400))

ax = PolarAxis(f[1, 1], title = "Theta as x")
lineobject = lines!(ax, 0..2pi, sin, color = :red)

ax = PolarAxis(f[1, 2], title = "R as x", theta_as_x = false)
scatobject = scatter!(range(0, 10, length=100), cos, color = :orange)

f
```
\end{examplefigure}

Note that not every plot type is compatible with polar transforms. For example
`image` is not as it expects to be drawn on a rectangle. `heatmap` works to a
degree in CairoMakie, but not GLMakie due to differences in the backend
implementation.
`surface` can be used as a replacement for `image` as it generates a triangle
mesh. However it also has a component in z-direction which will affect drawing
order. You can use `translate!(plot, 0, 0, z_shift)` to work around that.
As a replacement for `heatmap` you can use `voronoiplot`, which generates cells
of arbitrary shape around points given to it. Here you will generally need to
set `rlims!(ax, rmax)` yourself.
## PolarAxis Limits

By default the PolarAxis will assume `po.rlimits[] = (0.0, nothing)` and `po.thetalimits[] = (0.0, 2pi)`, showing a full circle.
You can adjust these limits to show different cut-outs of the PolarAxis.
For example, we can limit `thetalimits` to a smaller range to generate a circle sector and further limit rmin through `rlimits` to cut out the center to an arc.

\begin{examplefigure}{svg = true}
```julia
f = Figure(resolution = (600, 600))

ax = PolarAxis(f[1, 1], title = "Default")
lines!(ax, range(0, 8pi, length=300), range(0, 10, length=300))
ax = PolarAxis(f[1, 2], title = "thetalimits", thetalimits = (-pi/6, pi/6))
lines!(ax, range(0, 8pi, length=300), range(0, 10, length=300))

ax = PolarAxis(f[2, 1], title = "rlimits", rlimits = (5, 10))
lines!(ax, range(0, 8pi, length=300), range(0, 10, length=300))
ax = PolarAxis(f[2, 2], title = "both")
lines!(ax, range(0, 8pi, length=300), range(0, 10, length=300))
thetalims!(ax, -pi/6, pi/6)
rlims!(ax, 5, 10)

f
```
\end{examplefigure}

You can make further adjustments to the orientation of the PolarAxis by adjusting `ax.theta_0` and `ax.direction`.
These adjust how angles are interpreted by the polar transform following the formula `output_angle = direction * (input_angle + theta_0)`.

\begin{examplefigure}{svg = true}
```julia
f = Figure()

ax = PolarAxis(f[1, 1], title = "Reoriented Axis", theta_0 = -pi/2, direction = -1)
lines!(ax, range(0, 8pi, length=300), range(0, 10, length=300))
thetalims!(ax, -pi/6, pi/6)
rlims!(ax, 5, 10)

f
```
\end{examplefigure}

Note that by default translations in adjustments of rmin and thetalimits are blocked.
These can be unblocked by calling `autolimits!(ax[, true])` which also tells the PolarAxis to derive r- and thetalimits freely from data, or by setting `ax.fixrmin[] = false` and `ax.thetazoomlock[] = false`.


## Plot type compatability

Not every plot type is compatible with the polar transform.
For example `image` is not as it expects to be drawn on a rectangle.
`heatmap` works to a degree in CairoMakie, but not GLMakie due to differences in the backend implementation.
`surface` can be used as a replacement for `image` as it generates a triangle mesh.
However it also has a component in z-direction which will affect drawing order.
You can use `translate!(plot, 0, 0, z_shift)` to work around that.
As a replacement for `heatmap` you can use `voronoiplot`, which generates cells of arbitrary shape around points given to it. Here you will generally need to set `rlims!(ax, rmax)` yourself.

\begin{examplefigure}{svg = false}
```julia
Expand All @@ -54,22 +103,26 @@ f = Figure(resolution = (800, 500))
ax = PolarAxis(f[1, 1], title = "Surface")
rs = 0:10
phis = range(0, 2pi, 37)
cs = [r+cos(4phi) for r in rs, phi in phis]
p = surface!(ax, 0..10, 0..2pi, cs, shading = false, colormap = :coolwarm)
cs = [r+cos(4phi) for phi in phis, r in rs]
p = surface!(ax, 0..2pi, 0..10, cs, shading = false, colormap = :coolwarm)
ax.gridz[] = 100
Colorbar(f[2, 1], p, vertical = false, flipaxis = false)

ax = PolarAxis(f[1, 2], title = "Voronoi")
rs = 1:10
phis = range(0, 2pi, 37)[1:36]
cs = [r+cos(4phi) for r in rs, phi in phis]
p = voronoiplot!(ax, rs, phis, cs, show_generators = false, strokewidth = 0)
Makie.rlims!(ax, 10.5)
cs = [r+cos(4phi) for phi in phis, r in rs]
p = voronoiplot!(ax, phis, rs, cs, show_generators = false, strokewidth = 0)
rlims!(ax, 0.0, 10.5)
Colorbar(f[2, 2], p, vertical = false, flipaxis = false)

f
```
\end{examplefigure}

Note that in order to see the grid we need to adjust its depth with `ax.gridz[] = 100` (higher z means lower depth).
The hard limits for `ax.gridz` are `(-10_000, 10_000)` with `9000` being a soft limit where axis components may order incorrectly.

## Hiding spines and decorations

For a `PolarAxis` we interpret the outer ring limitting the plotting are as the
Expand Down Expand Up @@ -122,24 +175,65 @@ f

## Interactivity

The `PolarAxis` currently implements zooming by scrolling and allows you to
reset the view with left control + left mouse button. You can change the key
combination for resetting the view with the `reset_button` attribute, which
accepts anything `ispressed` accepts.
The `PolarAxis` currently implements zooming, translation and resetting.
Zooming is implemented via scrolling, with `ax.rzoomkey = Keyboard.r` restricting zooming to the radial direction and `ax.thetazoomkey = Keyboard.t` restring to angular zooming.
You can block zooming in the r-direction by setting `ax.rzoomlock = true` and `ax.thetazoomlock = true` for theta direction.
Furthermore you can disable zooming from changing just rmin with `ax.fixrmin = true` and adjust its speed with `ax.zoomspeed = 0.1`.

Translations are implemented with mouse drag.
By default radial translations use `ax.r_translation_button = Mouse.right` and angular translations also use `ax.theta_translation_button = Mouse.right`.
If `ax.fixrmin = true` translation in the r direction are not allowed.
If you want to disable one of these interaction you can set corresponding button to `false`.

Note that `PolarAxis` currently does not implement the interaction itnerface
There is also an interaction for rotating the whole axis using `ax.axis_rotation_button = Keyboard.left_control & Mouse.right` and resetting the axis view uses `ax.reset_button = Keyboard.left_control & Mouse.left`, matching `Axis`.
You can adjust whether this resets the rotation of the axis with `ax.reset_axis_orientation = false`.

Note that `PolarAxis` currently does not implement the interaction interface
used by `Axis`.

## Other Notes

### Plotting outside a PolarAxis

Currently there is a scatter and poly plot outside the area of the `PolarAxis`
which clips the content to the relevant area. If you want to draw outside the
circle limiting the polar axis but still within it's scene area, you will need
Currently there are two poly plots outside the area of the `PolarAxis`
which clip the content to the relevant area. If you want to draw outside the
clip limiting the polar axis but still within it's scene area, you need
to translate those plots to a z range between `9000` and `10_000` or disable
clipping via the `clip` attribute.

For reference, the z values used by `PolarAxis` are `po.griddepth[] = 8999` for grid lines, 9000 for the clip polygons, 9001 for spines and 9002 for tick labels.

### Radial Distortion

If you have a plot with a large rmin and rmax over a wide range of angles you will end up with a narrow PolarAxis.
Consider for example:

\begin{examplefigure}{svg = true}
```julia
fig = Figure()
ax = PolarAxis(fig[1, 1], thetalimits = (0, pi))
lines!(ax, range(0, pi, length=100), 10 .+ rand(100))
fig
```
\end{examplefigure}

In this case you may want to distort the r-direction to make more of your data visible.
This can be done by setting `ax.radial_distortion_threshold` to a value between 0 and 1.

\begin{examplefigure}{svg = true}
```julia
fig = Figure()
ax = PolarAxis(fig[1, 1], thetalimits = (0, pi), radial_distortion_threshold = 0.2)
lines!(ax, range(0, pi, length=100), 10 .+ rand(100))
fig
```
\end{examplefigure}

Internally PolarAxis will check `rmin/rmax` against the set threshold.
If that ratio exceed the threshold, the polar transform is adjusted to shift all radii by some `r0` such that `(rmin - r0) / rmax - r0) == ax.radial_distortion_threshold`.
In effect this will hold the inner cutout/clip radius at a fraction of the outer radius.
Note that at `ax.radial_distortion_threshold >= 1.0` (default) this will never distort your data.

## Attributes

\attrdocs{PolarAxis}
11 changes: 10 additions & 1 deletion src/basic_recipes/voronoiplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function plot!(p::Voronoiplot{<:Tuple{<:Vector{<:Point{N}}}}) where {N}
attr[:clip] = map(p, pop!(attr, :clip), p.unbounded_edge_extension_factor,
transform_func_obs(p), ps) do bb, ext, tf, ps
if bb === automatic && tf isa Polar
rscaled = maximum(first, ps) * (1 + ext)
rscaled = maximum(p -> p[1 + tf.theta_as_x], ps) * (1 + ext)
return Circle(Point2f(0), rscaled)
else
return bb
Expand All @@ -168,6 +168,15 @@ function plot!(p::Voronoiplot{<:Tuple{<:Vector{<:Point{N}}}}) where {N}
return voronoiplot!(p, attr, vorn; transformation=transform)
end

function data_limits(p::Voronoiplot{<:Tuple{<:Vector{<:Point{N}}}}) where {N}
if transform_func(p) isa Polar
iter = (to_ndim(Point3f, p, 0f0) for p in p.converted[1][])
limits_from_transformed_points(iter)
else
limits_from_transformed_points(iterate_transformed(p))
end
end

function plot!(p::Voronoiplot{<:Tuple{<:DelTri.VoronoiTessellation}})
generators_2f = Observable(Point2f[])
PolyType = typeof(Polygon(Point2f[], [Point2f[]]))
Expand Down
Loading
Loading