-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Continuation of polar axis #2990
Merged
Merged
Changes from 69 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
ba2318a
start implementation
jkrumbiegel ad8900c
First implementation of polar axis
asinghvi17 9f662fb
Try to make the polar axis "plottable-to"
asinghvi17 828c9a4
Revert MakieLayout.jl to master state
asinghvi17 be9302b
Correct documentation of `adjustcam!`
asinghvi17 8a1d0a6
Implement angular ticks
asinghvi17 9f2c0a3
Inherit a bit more
asinghvi17 8c2dc4b
Implement radial ticks
asinghvi17 3d0f20c
Fix translation for GLMakie
asinghvi17 eff6180
In Camera2D's ratio check, use only Float32 to compare
asinghvi17 603f706
Fix bad bbox method, add comments
asinghvi17 25dca9a
Remove debug statements
asinghvi17 4fd1d5d
Update for MakieLayout module removal
asinghvi17 5539a5a
Update the lines when the camera changes.
asinghvi17 0e4292d
Lift on camera also
asinghvi17 1d133a1
Add protrusion calculation for theta ticks
asinghvi17 0ea9644
Allow plot!(po::PolarAxis, ...)
asinghvi17 e9ba2e4
Manual protrusion calc by checking text bboxes individually.
asinghvi17 227b0b5
Implement a foundation for hacked theta-lims
asinghvi17 e662ee6
Fix update_cam!(::Scene)
asinghvi17 aa0bb82
Quick fix for overlooked item
asinghvi17 08d7a91
Implement `text_bbox(plot::Text)`
asinghvi17 8fb816f
Implement inherit for nested theme attributes
asinghvi17 44eb5ba
Implement title for PolarAxis
asinghvi17 e2a3582
Switch default theme to inheriting from Axis
asinghvi17 3dba936
Separate r and theta minor grids in theme
asinghvi17 bfc2c1d
Update NEWS
asinghvi17 f2c90c8
General cleanup
asinghvi17 60ee94a
Adjust ticks, grid and camera on scene area / limit change
asinghvi17 9432e1f
Change r-tick angle to avoid overlap
asinghvi17 ae09053
Implement "nonlinear clip" without transparency
asinghvi17 afbde6e
Address comments from code review
asinghvi17 061dabd
Merge branch 'master' into jk/polar-axis
Moelf f6b69b2
Merge branch 'master' into jk/polar-axis
SimonDanisch 2542326
Merge branch 'master' into jk/polar-axis
SimonDanisch 190cb33
fix errors
ffreyer 2309c09
prototype axis decorations in polar coords
ffreyer 64a1654
move axis to overlay scene
ffreyer e3e936f
rename θ to theta
ffreyer 68f5462
add theta tick pad and split onany
ffreyer f8809b1
get arbitrary scene areas going
ffreyer 9a76ff5
cleanup axis clip
ffreyer ab168bb
switch to two step limits, remove min radius
ffreyer fb3eba3
Merge branch 'master' into ff/jk-as-polar-axis
ffreyer 2340891
discard camera changes
ffreyer c42e851
improve observable tracking/cleanup
ffreyer 0069fc0
add camera reset
ffreyer 573dde2
add r tick stroke
ffreyer 651cc48
use degrees for tick labels
ffreyer 171af16
cleanup background color
ffreyer 23cb046
fix theta_0 handling for ticks
ffreyer d0425a0
turn off minor grid by default
ffreyer 0ce66d7
Merge branch 'master' into ff/jk-as-polar-axis
ffreyer 17eb51a
rename Polar transform and move it
ffreyer 88e5856
Merge branch 'master' into ff/jk-as-polar-axis
SimonDanisch 5f023f4
Merge branch 'master' into ff/jk-as-polar-axis
SimonDanisch cc02239
temp fix for poly transforms
ffreyer dcd01f1
cleanup background color handling
ffreyer 7f379c1
cleanup protrusions
ffreyer c7e86af
cleanup title position
ffreyer d9620a9
remove default outline on r tick labels
ffreyer 2e03171
general cleanup
ffreyer 17b7208
add docs
ffreyer ea6d168
add refimg tests
ffreyer dd1ac4d
add polar transform test & fix inverse
ffreyer 884656e
fix duplicate NEWS entry
ffreyer ecd8e06
add outlines for theta ticks
ffreyer c856680
add cycler support to PolarAxis
SimonDanisch 52b13fa
Merge branch 'master' into ff/jk-as-polar-axis
SimonDanisch 43532ee
inherit background color
ffreyer 45ecfb6
add attrdocs
ffreyer 59bbb79
Merge branch 'master' into ff/jk-as-polar-axis
SimonDanisch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# 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. | ||
|
||
## Creating a PolarAxis | ||
|
||
Creating a `PolarAxis` works the same way as creating an `Axis`. | ||
|
||
\begin{examplefigure}{svg = true} | ||
```julia | ||
using CairoMakie | ||
CairoMakie.activate!() # hide | ||
|
||
f = Figure() | ||
|
||
ax = PolarAxis(f[1, 1], title = "Title") | ||
|
||
f | ||
``` | ||
\end{examplefigure} | ||
|
||
## 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). | ||
|
||
\begin{examplefigure}{svg = true} | ||
```julia | ||
lineobject = lines!(ax, 0..10, sin, color = :red) | ||
scatobject = scatter!(0:0.5:10, 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` works in both, as it is designed to generate a | ||
triangle mesh. | ||
|
||
\begin{examplefigure}{svg = false} | ||
```julia | ||
f = Figure() | ||
ax = PolarAxis(f[1, 1]) | ||
# The first two arguments should be set to a sensible radial and angular range | ||
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)) | ||
Colorbar(f[1, 2], p) | ||
f | ||
``` | ||
\end{examplefigure} | ||
|
||
## Hiding spines and decorations | ||
|
||
For a `PolarAxis` we interpret the outer ring limitting the plotting are as the | ||
axis spine. You can manipulate it with the `spine...` attributes. | ||
|
||
\begin{examplefigure}{svg = true} | ||
```julia | ||
f = Figure(resolution = (800, 400)) | ||
ax1 = PolarAxis(f[1, 1], title = "No spine", spinevisible = 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) | ||
|
||
f | ||
``` | ||
\end{examplefigure} | ||
|
||
Decorations such as grid lines and tick labels can be adjusted through | ||
attributes in much the same way. | ||
|
||
\begin{examplefigure}{svg = true} | ||
```julia | ||
f = Figure(resolution = (600, 600), backgroundcolor = :black) | ||
ax = PolarAxis( | ||
f[1, 1], | ||
backgroundcolor = :black, | ||
# r minor grid | ||
rminorgridvisible = true, rminorgridcolor = :red, | ||
rminorgridwidth = 1.0, rminorgridstyle = :dash, | ||
# theta minor grid | ||
thetaminorgridvisible = true, thetaminorgridcolor = :lightblue, | ||
thetaminorgridwidth = 1.0, thetaminorgridstyle = :dash, | ||
# major grid | ||
rgridwidth = 2, rgridcolor = :red, | ||
thetagridwidth = 2, thetagridcolor = :lightblue, | ||
# r labels | ||
rticklabelsize = 18, rticklabelcolor = :red, | ||
rticklabelstrokewidth = 1.0, rticklabelstrokecolor = :white, | ||
# theta labels | ||
thetaticklabelsize = 18, thetaticklabelcolor = :lightblue | ||
) | ||
|
||
f | ||
``` | ||
\end{examplefigure} | ||
|
||
## 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. | ||
|
||
Note that `PolarAxis` currently does not implement the interaction itnerface | ||
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 | ||
to translate those plots to a z range between `9000` and `10_000` or disable | ||
clipping via the `clip` attribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
project_x
functions in CairoMakie are currently build to taketransform_func
from passed scenes, which isn't correct but usually irrelevant. However forPolarAxis
I added a poly without transformations to fill the outer background which is plotted incorrectly with this approach, so I did a quick and dirty fix here (and in utils.jl). Proper fix/cleanup is in #3040.