LGSInnovations / sigplot

SigPlot provides fast interactive web-plotting for software defined radio.
https://sigplot.lgsinnovations.com
Apache License 2.0
36 stars 26 forks source link

Plotting array layer of data with varied xdelta values #109

Closed KevinPoole closed 2 years ago

KevinPoole commented 3 years ago

Hi Sigplot team,

You all have been very helpful helping me with a couple of other issues I have worked through, so I thought I might push my luck with my latest question...

I have a situation where I need to plot a set of values, and want them connected with a line, but the values are not guaranteed to have a consistent xdelta. To give a trivial illustration:

x  | y
-----
0  | 1
2  | 5
5  | 10
6  | 7
10 | 11

so x is guaranteed to monotonically increase, but the gaps from one value to the next vary. I was wondering if there is a way to accomplish this with sigplot? I have seen the xdelta and xstart options which are all relevant to my problem space, but do not seem to aid this particular issue.

A work around I have considered, is linearly interpolating the data so that it ends up having a constant xdelta but this would require inserting "fake data" and I would rather avoid this if at all possible.

Your assistance is, as always, greatly appreciated!

KevinPoole commented 3 years ago

For now I have gone with the interpolation approach, and while not ideal, I am quite pleased to see how snappy it performs even with 43k + 15.6k data points. very impressive

maihde commented 3 years ago

Kevin, there isn't a way to do variable xdelta, but there is a way to provide a series of X/Y coordinate pairs. I'll dig up an example for you and respond here.

maihde commented 3 years ago

Also, if this is a work-related project, it might be nice to connect so that we can better understand your needs and requirements. Feel free to email me directly at mihde@spectric.com.

KevinPoole commented 3 years ago

@maihde if there were a way to provide a series of X/Y coordinate points and have them plotted as a connected line then that would solve my dilemma perfectly!

Thanks very much!

maihde commented 3 years ago

@KevinPoole try this example: https://jsfiddle.net/68hkc0dx/1/

maihde commented 3 years ago

@KevinPoole I've added a new mode to layer1d this is more clearly for XY drawing. Historically, XY plots were done by sending in "complex" format data and rendering in "IR" mode. This new feature achieves the same effect without resorting to an esoteric method.

https://github.com/spectriclabs/sigplot/tree/feature/layer1d-xy-mode https://github.com/spectriclabs/sigplot/blob/9c7958a063762a369196cb8c2ec8cc28b00b56bf/test/tests.interactive-symbols.js#L175

KevinPoole commented 2 years ago

@maihde I have been away from this particular issue for some time. I have been hesitant to adopt the above update in large part because up until now I have been utilizing the react-sigplot library and that is based on what I gather to be the original repo, LGSInnovations/sigplot.

However I am thinking I have gotten to the point where I can avoid this issue no longer, so I will need to adopt your above XY changes. I noticed that this feature branch is not merged even into the fork though at spectriclabs/sigplot - is there any reason for this? could it be? presently I am even contemplating just using the feature branch directly, but that does not seem ideal.

Thanks again for your help with these matters.

KevinPoole commented 2 years ago

@maihde I can't complain seeing as you were just trying to help, but it seems there is something not quite right about the above XY mode. It works with the basic data set that is used in the test case you linked to, but it seems to be easier to find data sets that don't work than do 😢 for example, just multiplying each value by 10 is already enough to break it and have no data plotted.

If for some reason you are willing to revisit this, it would be greatly appreciated.

maihde commented 2 years ago

@KevinPoole I'm not sure if anyone is still maintaining the LGSInnovations/sigplot library anymore. The spectriclabs/sigplot library is probably the only version that will receive updates.

I'm happy to revisit this, but I cannot guarantee any particular schedule for when it will be completed. If this is an urgent need please reach out to me directly via e-mail and I would be happy to discuss options where we might be able to address your specific concern.

KevinPoole commented 2 years ago

Sounds good @maihde , I totally understand. If you do get back to this at some point, the following may be of use to you. I forked from the branch you had linked, https://github.com/spectriclabs/sigplot/tree/feature/layer1d-xy-mode , and it seems that the following tweak got it to work:

diff --git a/js/sigplot.layer1d.js b/js/sigplot.layer1d.js
index c0c261e..f4764a0 100644
--- a/js/sigplot.layer1d.js
+++ b/js/sigplot.layer1d.js
@@ -243,7 +243,10 @@

             var imin = 0;
             var imax = 0;
-            if (Gx.index) {
+            if(this.mode === 'XY'){
+                imin = 0;
+                imax = size - 1;
+            }else if (Gx.index) {
                 imin = Math.floor(xmin);
                 imax = Math.floor(xmax + 0.5);
             } else if (HCB.xdelta >= 0.0) {

You may know better than I do whether this indicates other changes that would also be needed, or if this truly is sufficient, but it has seemed to do the trick for me.

Cheers.

maihde commented 2 years ago

@KevinPoole your fix looks good to me and works when I apply it to master baseline. I've added a unittest for this as well. Thanks for debugging that and providing a fix!

KevinPoole commented 2 years ago

@maihde happy to help. perhaps at some point I will port the react-sigplot over to use spectriclabs/sigplot (I do not think it would take much effort). that way I would be able to utilize the latest and greatest. we'll see.

maihde commented 2 years ago

@KevinPoole there is also a react-sigplot here https://github.com/spectriclabs/react-sigplot which uses newer SigPlot as well.

KevinPoole commented 2 years ago

Wonderful. Perhaps I will make the switch then.

On Wed, Feb 23, 2022 at 1:42 PM maihde @.***> wrote:

@KevinPoole https://github.com/KevinPoole there is also a react-sigplot here https://github.com/spectriclabs/react-sigplot which uses newer SigPlot as well.

— Reply to this email directly, view it on GitHub https://github.com/LGSInnovations/sigplot/issues/109#issuecomment-1049095251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7PVSGUI3ZNCOQTIWGMHI3U4UTAXANCNFSM5DXF7VXA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>