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

clean_figure not working due to dead code if lines temporarily leave visible box #589

Open
Naikless opened this issue Jun 23, 2023 · 0 comments

Comments

@Naikless
Copy link

Naikless commented Jun 23, 2023

The following code throws NotImplementedError: There is data outside of the box. Don't know how to handle during cleaning. Please check if x/ylim is to tight:

import matplotlib.pyplot as plt
from tikzplotlib import clean_figure

x = range(1001)
y = [1]*1001
y[500] = 100

fig = plt.figure()
plt.plot(x,y)
plt.xlim(400, 600)
plt.ylim(0,10)

clean_figure(fig)

The reason lies in _move_points_closer that supposedly once was thought to map the points outside the visible domain to points on the edge of that domain.
However, it seems this was never implemented and this function only returns the data unchanged if there are no points outside the visible area or throws the above error otherwise.

In my actual use case I have a very long timesignal of which I only want to plot a short fraction. Cutting this out is already done by _prune_outside_box. However, the signal also has some peaks that lie outside the domain which trigger the above error.

Since _move_points_closer currently doesn't do anything anyway, it seems exaggerated to me to completely abort the figure cleaning process just because some values are still outside the axis area. I would suggest to change this into a warning instead.

@Naikless Naikless changed the title clean_figure not working if lines temporarily leave visible box due to dead code clean_figure not working due to dead code if lines temporarily leave visible box Jun 23, 2023
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