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

Vertex sampling uses different tolerances for objects within the same plot #1174

Closed
IKupriyanov-HORIS opened this issue Sep 9, 2024 · 1 comment
Assignees

Comments

@IKupriyanov-HORIS
Copy link
Collaborator

Sampling uses different tolerances for objects within the same plot:

from lets_plot import *
LetsPlot.setup_html()

from math import sin, cos
def circle(x, y, r, n, g, out):
    xs = []
    ys = []
    gs = [g] * n
    angle_step = 3.14 * 2 / n 
    angle = 0
    for i in range(n - 1):
        xs.append(x + cos(angle) * r)
        ys.append(y + sin(angle) * r)
        angle += angle_step

    xs.append(xs[0])
    ys.append(ys[0])

    out['x'].extend(xs)
    out['y'].extend(ys)
    out['g'].extend(gs)
    return out

data = { 'x': [], 'y': [], 'g': [] }
circle(10, 10, 5, 100, 'a', data)
circle (50, 50, 10, 100, 'b', data)
circle (70, 30, 15, 100, 'c', data)
circle (30, 70, 10, 100, 'd', data)
circle (30, 90, 5, 100, 'e', data)

p = ggplot(data, aes(x='x', y='y', group='g')) + coord_fixed()
p + geom_path(sampling=sampling_vertex_dp(100))

ggplot(data, aes(x='x', y='y')) + coord_fixed() + geom_polygon(sampling=sampling_vertex_dp(100))

Output:
image

@IKupriyanov-HORIS IKupriyanov-HORIS self-assigned this Sep 9, 2024
IKupriyanov-HORIS added a commit that referenced this issue Sep 9, 2024
Fix:
#1168 - Unable to display or save graph when using geom_path
#1174 - Vertex sampling uses different tolerances for objects within the same plot
#1175 - sampling_vertex_vw doesn't work as expected
#1176 - sampling_vertex_dp may break rings
@IKupriyanov-HORIS
Copy link
Collaborator Author

IKupriyanov-HORIS commented Sep 9, 2024

Fixed via 80fcbf2
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant