Skip to content

Commit

Permalink
GR switch to new 3d projection (#4232)
Browse files Browse the repository at this point in the history
* gr: switch to new projection

* gr: correct positions of 3d labels

* gr: fix problem with 3d markers and meshes

* Choose angles compatible with the old transformation

Co-authored-by: Simon Christ <[email protected]>

* Update src/backends/gr.jl

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* adjust tolerances on windows ci

Co-authored-by: Simon Christ <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Christ <[email protected]>
  • Loading branch information
4 people authored Jun 14, 2022
1 parent 6266ff8 commit b13ba27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/backends/gr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1433,13 +1433,8 @@ function gr_draw_axes(sp, viewport_plotarea)

camera = round.(Int, sp[:camera])

warn_invalid(val) =
if val < 0 || val > 90
@warn "camera: $(val)° ∉ [0°, 90°]"
end
warn_invalid.(camera)

GR.setspace(zmin, zmax, camera...)
GR.setwindow3d(xmin, xmax, ymin, ymax, zmin, zmax)
GR.setspace3d(-90 + camera[1], 90 - camera[2], 30, 0)

# fill the plot area
gr_set_fill(plot_color(sp[:background_color_inside]))
Expand Down Expand Up @@ -1679,6 +1674,7 @@ function gr_label_ticks_3d(sp, letter, ticks)
-1 : 1
end

GR.setwindow(-1, 1, -1, 1)
for (cv, dv) in zip((cvs, dvs)...)
xi, yi = gr_w3tondc(sort_3d_axes(cv, nt, ft, letter)...)
sz_rot = gr_text_size(dv, rot)
Expand Down Expand Up @@ -1843,11 +1839,13 @@ function gr_add_series(sp, series)
if st === :scatter3d || series[:markershape] !== :none
# TODO: Do we need to transform to 2d coordinates here?
x2, y2 = RecipesPipeline.unzip(map(GR.wc3towc, x, y, z))
GR.setwindow(-1, 1, -1, 1)
gr_draw_markers(series, x2, y2, clims)
end
elseif st === :contour
gr_draw_contour(series, x, y, z, clims)
elseif st in (:surface, :wireframe, :mesh3d)
GR.setwindow(-1, 1, -1, 1)
gr_draw_surface(series, x, y, z, clims)
elseif st === :volume
sp[:legend_position] = :none
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ default(show = false, reuse = true) # don't actually show the plots
is_ci() = get(ENV, "CI", "false") == "true"
const PLOTS_IMG_TOL = parse(
Float64,
get(ENV, "PLOTS_IMG_TOL", is_ci() ? Sys.iswindows() ? "2e-4" : "1e-4" : "1e-5"),
get(ENV, "PLOTS_IMG_TOL", is_ci() ? Sys.iswindows() ? "2e-3" : "1e-4" : "1e-5"),
)

## Uncomment the following lines to update reference images for different backends
Expand Down

0 comments on commit b13ba27

Please sign in to comment.