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

How to make lines smoother or have anti aliasing generics #166

Open
Mr-Liu-CUG opened this issue Feb 21, 2021 · 4 comments
Open

How to make lines smoother or have anti aliasing generics #166

Mr-Liu-CUG opened this issue Feb 21, 2021 · 4 comments

Comments

@Mr-Liu-CUG
Copy link

I have some data points that need to be connected into a curve. How can I do that? If the number of points is too many, there will be obvious unevenness, and if the number of points is too few, there will be obvious edges and corners. How to make the line present a smooth curve effect in the triangle? Or anti aliasing?
I would appreciate your advice.

@maximweb
Copy link
Contributor

Maybe it helps to smoothen your data, for example using SavGol filter?

@Mr-Liu-CUG
Copy link
Author

Maybe it helps to smoothen your data, for example using SavGol filter?

Usually it is to carry on the filter processing to the two-dimensional data, but my triangle chart data is the three-dimensional data, how should carry on the filter operation

@maximweb
Copy link
Contributor

Maybe it helps to smoothen your data, for example using SavGol filter?

Usually it is to carry on the filter processing to the two-dimensional data, but my triangle chart data is the three-dimensional data, how should carry on the filter operation

Lets assume you have 2D data y over x: As long as you are not interested in a derivative but only the data itself, SavGol does not care whether the points are equidistant (see delta parameter in the documentation, which is not required when deriv=0 and the SavGol function has no input for x AND y but only one data array.)
So in this case you could just use SavGol over your x and y data arrays individually.

For ternary data (x+y+z=1) I would suggest you use SavGol filter over x, y and z individually.

What could go wrong:

  • You have to set a fixed window_length, which is basically the amount of points used for a polynomial fit. If your data are very unevenly distributed, I am not sure whether the strength of smoothing then might differ in regions with narrow points and regions with coars point distribution, but it should be very easy to test.
  • Special care has to be taken regarding the edges of your data (the first and last window_length/2 points), see mode and cval parameters. As far as I know this is, however, an issue with all filtering functions

Feel free to post code of a minimal example with your data.

@Mr-Liu-CUG
Copy link
Author

Thank you very much for your detailed reply, thank you for giving me ideas

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

2 participants