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

contour plot scale invariance #485

Open
gaponenko opened this issue Nov 1, 2024 · 0 comments
Open

contour plot scale invariance #485

gaponenko opened this issue Nov 1, 2024 · 0 comments

Comments

@gaponenko
Copy link

Hello,

I got an unexpected result in a contour plot: the lines had way too many labels. A simplified demo code is pasted below, and the corresponding pdf output is attached. The left and right sides show contour lines for the same function with two different scalings of its input coordinates (using different units). The blue plot on the left looks as expected. The red one on the right should look the same (it is the same function), but it does not. The reason seems to be that contour() sometimes breaks what should be a single returned guide into many pieces, and this behavior is scale-dependent.

Andrei

contour-scale-labels.pdf

`
//----------------------------------------------------------------
// Draw a contour plot with labels. In Asymptote 2.92 the number of
// labels depends on the scaling of the function (e.g. whether X and Y
// are expressed in meters or mm). The reason is that contour()
// sometimes breaks what should be a single returned guide into
// pieces, and this behavior is scale-dependent.

import contour;

real f_m(real x, real y) {
return x^2 - y^2;
}

real f_mm(real x, real y) {
return (x/1000)^2 - (y/1000)^2;
}

pair Am = (-20, -20);
pair Bm = (+20, +20);

pair Amm = 1000 * Am;
pair Bmm = 1000 * Bm;

real[] c = {20.};
Label[] lab = { Label("20", Relative(0.2), (0,0), UnFill(1bp)) };

picture pic1;
size(pic1,200);
draw(pic1, lab, contour(pic1, f_m, Am, Bm, c), blue);

picture pic2;
size(pic2, 200);
draw(pic2, lab, contour(pic2, f_mm, Amm, Bmm, c), red);

add(pic1.fit(), (0,0), W);
add(pic2.fit(), (0,0), 100E);
//----------------------------------------------------------------
`

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