SignalXY: improve rendering and extend customization options [and rename things]#4102
SignalXY: improve rendering and extend customization options [and rename things]#4102BrianAtZetica wants to merge 8 commits intoScottPlot:mainfrom
Conversation
…g rotated plots. Xs becomes Positions (the uniform, ordered dimension of the signal) Ys becomes Amplitudes (the measured property of the signal). This commit also resolves some minor rendering glitches Introduces rotated option for Generic SignalXY plots and finishes introduction of an offset along the Positions domain.
|
Hello @BrianAtZetica, I am also not very happy with the names |
|
I had a long conversation with ChatGPT about what terms to use to replace X and Y 😄 at one point "Range" was in the mix for X, until I realised I would have a parameter called range range 😁 Am definitely open to the popular vote (although I'm not sure how intuitive Abscissa and Ordinate will be across the user base). Understand the reluctance about API change. Not sure how best to approach that. |
|
@KroMignon maybe I can reinstate XOffset, YOffset and YScale as obselete properties that set PositionOffset, AmplitudeOffset and AmplitudeScale respectively. That should take care of the breaking changes ? |
This sounds good to me! |
|
It is unlikely that someone will want to rotate Maybe we should create two separate plottables The proposed renaming is confusing, the amplitude is associated with periodic signals. |
…ability. These are marked as obselete
My program allows the user to do exactly this. I dont want to have to change from one plottable type to another. The rotate option is a great feature for exposing choice to the end user.
I disagree that 'amplitude' implies periodicity. Amplitude is simply the magnitude or value of a signal. I think we will struggle to identify any two words with unanimous agreement:
So how do we choose (it doesn't matter too much to me, so long as we can avoid mixing up X and Y variables with X and Y axes)? I'll wait for @swharden to weigh in. |
This is why I suggest them as For me, the very important point is that there is no API break, and currently developed software still works.
I cannot see any benefit of this suggestion? Having the capability to rotate does not imply that you have to use it... So why create a new plottable type? |
… longer needed following refactor and improvements made in PR ScottPlot#4102. This should boost performance slightly.
… longer needed following refactor and improvements made in PR ScottPlot#4102. This should boost performance slightly (this time remembering rotated SignalXY part of code).
|
Hi @BrianAtZetica and the group, this is a great PR and the discussion here is really interesting too! I plan to leave this PR open for a little longer while I close out simpler high-priority open issues, then I'll publish a new release to NuGet tomorrow, then I'll loop back here and pick this PR up again. If this PR were limited to fixing the rendering artifacts, adding custom offset support, and improving rotation support, I'd merge it in now and publish it in the next release. However, because the PR also renames some important things, I'm inclined to put more time and research into considering the best way to proceed before merging this one. I will offer my quick thoughts on the topic of naming, and I welcome feedback. The discussion of naming extends beyond I'll put this down for a few days but pick it up again next week. Thanks again everyone for your input! |
|
@swharden, understood. As I said, I needed to rename things to work through and understnad the code logic before I could find the small indexing and X/Y confusions that were causing some of the artefacts. But, now that I understand it better, I've managed to achieve the same fixes to rendering starting from the current main branch. I'll make another PR, to keep the refactorign as a seperate issue. |
I just merged #4112 so depending on how similar the implementation there is to this branch, we could "resolve conflicts" here, then update from main, and this PR would just track the name changes. If resolving the merge conflicts gets to hard, we can open a new PR just for the renaming and pick it up from there. Thanks again for getting this conversation going! |
Sorry, slow to respond to this. But just to be clear, my intention is to follow this up in a few weeks time, as work allows. |
…XScale and a renamed method GetColumnPixels
|
@swharden, this has now been merged with the main branch with all conflicts resolved. I've tested it for offsets and scales in both dimensions and all seems to be OK from my perspective. I realise now I should have rebased instead of merged, as that would have been easier to work with. As the discussion on this thread was unresolved, I'm not sure I can take this any further. I think the naming I've introduced in SignalXY is easier to work with, but I realise it doesn't represent the perfect naming in every use context. It also has only addressed one plot type, and your suggestion of finding consistency across other plot types makes sense. I'll think I'll close this PR now and leave it with you to either reopen (if you think it is an incremental improvement that can be taken forward) or put the issue on a todo list somewhere else. Thanks |
I was experiencing rendering artefacts with rotated SignalXY plots, but found it very difficult to debug these due to the confusing use of X and Y parameter names in the rotated graph context. This PR fully refactors SignalXY (double and generic versions) so that:
Xs (the array defining the uniform, ordered dimension of the signal) becomes "Positions"
Ys (the unordered, measured property of the signal) becomes "Amplitudes"
All method names are refactored to make their role/purpose clearer.
In the process of the refactor, I managed to:
The main artefact was best illustrated when plotting a rotated signal on inverted axes
After this PR the same code produces a smooth sinusoid:

Aretefacts with incomplete handling of offsets canbe seen with teh following code:
After this PR the same code (except YOffset replaced with AmplitudeOffset) produces a smooth sinusoid:

Similarly with XOffset in original code:

And with PositionOffset in revised code:

Similarly with YScale in original code:

And with AmplitudeScale in revised code:

For completeness, the following illustrates the newly exposed PositionScale option:

Finally, I have float versions of some of the Generate functions for convenience when testing the generic version of the SignalXY (maybe the naming convention isn't right for these functions?):
Note that I am using the Rotated option here with generic SignalXY class.
The main resolution to the original rendering artefacts was changing the order of the min and max values in each pixel column to prevent unecessary over-drawing of hte continuous line through the listed pixels.