Closed Freed-Wu closed 2 years ago
@Freed-Wu Thanks for the suggestion! I guess what you would want is that when plotting NaN's are silently dropped, right?
So plot([1,2,3])
should be itentical to plot([1,2,3,np.nan])
, right?
No.
import numpy as np
from matplotlib import pyplot as plt
a = np.arange(10.)
a[2:5] = [np.nan] * 3
plt.plot(a)
plt.show()
Okay got it, I'll look into it. Might be that I'll only get around to the simpler option of the above.
Let me know if you want to have a go at this yourself, and we'll coordinate
Not sure. I notice another library named plotext has same problem, however, it only ignore NaN (the simpler option of the above). I maybe try to solve https://github.com/piccolomo/plotext/issues/114
@Freed-Wu It sounds like you have another solution now. In any case I've implemented the simple version we discussed in 0.6.0
and maybe I'll get around to the more sophisticated one eventually.
Thank you for your input!
You are welcome. :smile:
This should now work as requested. 😄
>>> import numpy as np
>>> from uniplot import plot
>>> a = np.arange(10.)
>>> a[2:5] = [np.nan] * 3
>>> plot(a, lines=True)
┌────────────────────────────────────────────────────────────┐
│ ▗▄▀▀│
│ ▄▞▀▘ │ 8
│ ▗▄▀▀ │
│ ▄▞▀▘ │
│ ▗▄▀▀ │
│ ▄▞▀▘ │
│ ▗▄▀▀ │
│ ▞▀▘ │
│ │
│ │ 4
│ │
│ │
│ │
│ │
│ │
│ ▗▄▞▀ │
│▄▄▀▘▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁│ 0
└────────────────────────────────────────────────────────────┘
2 5 7 10
When ys contain NaN, it will not display.
Thanks.