Skip to content

New Plottables: RepeatingAxisLine and AxisLineVector#1557

Merged
swharden merged 13 commits intoScottPlot:masterfrom
BambOoxX:plottable-repeatingaxislines
Jan 18, 2022
Merged

New Plottables: RepeatingAxisLine and AxisLineVector#1557
swharden merged 13 commits intoScottPlot:masterfrom
BambOoxX:plottable-repeatingaxislines

Conversation

@BambOoxX
Copy link
Contributor

New Plottables - RepeatingAxisLine and AxisLineVector
New plots proposed after the discussion in #1535

  • The RepeatingAxisLine behaves as an AxisLine with additional surrounding lines
    • The first line is positioned at Position
    • The subsequent Count - 1 lines are positioned according to parameters Offset , Shift and RelativePosition
    • The first line is thicker by default but this can be disabled with the HighlightReferenceLine property
  • The AxisLineVector behaves as an undraggable AxisLine and multiple lines are plotted according to the values in a double[] object.

New plots proposed after the discussion in ScottPlot#1535

- The `RepeatingAxisLine` behaves as an `AxisLine` with additional surrounding lines
    - The first line is positionned at `Position`
    - The subsequent `Count - 1` lines are positionned according to parameters `Offset` , `Shift` and `RelativePosition`
    - The first line is thicker by default but this can be disabled with the `HighlightReferenceLine` property
- The `AxisLineVector` behaves as an undraggable `AxisLine` and multiple lines are plotted according to the values in a `double[]` object.
@BambOoxX
Copy link
Contributor Author

@swharden I feel my two PRs are a bit messy ! Sorry in advance for the inconvenience.

@swharden
Copy link
Member

I feel my two PRs are a bit messy ! Sorry in advance for the inconvenience.

No worries! I cleaned it up a bit and resolved some merge conflicts introduced by #1556

Would you be up for adding a cookbook recipe to demonstrate this new plot type? Here's an example recipe to help you get started. You can add your own recipes by adding a similar code blocks to the end of this file demonstrating how to use these new plot types and perhaps showing-off what they're capable of.

public class AxisLineAndSpan : IRecipe
{
public string Category => "Plottable: Axis Line and Span";
public string ID => "axisLine_basics";
public string Title => "Axis Line";
public string Description =>
"An axis line marks a position on an axis. " +
"Axis lines extend to positive and negative infinity on the other axis.";
public void ExecuteRecipe(Plot plt)
{
// plot sample data
plt.AddSignal(DataGen.Sin(51));
plt.AddSignal(DataGen.Cos(51));
// add axis lines
plt.AddHorizontalLine(.85);
plt.AddVerticalLine(23);
// customize axis lines with optional arguments
plt.AddVerticalLine(x: 33, color: Color.Magenta, width: 3, style: LineStyle.Dot);
}
}

Note that just by adding to the bottom of this file your recipe will appear in the cookbook on the website automatically (e.g., that code above becomes https://scottplot.net/cookbook/4.1/category/plottable-axis-line-and-span/#axis-line) and also in the demo application which has the interactive cookbook browser.

@swharden swharden changed the title New Plottables : repeating axislines New Plottables: RepeatingAxisLine and AxisLineVector Jan 16, 2022
@BambOoxX
Copy link
Contributor Author

I am currently working on the PR, but could you clarify which project I should try to compile in order to have the CookBook pop up so I can see if it works properly ?

@swharden
Copy link
Member

clarify which project I should try to compile in order to have the CookBook

I made this video to help you out real quick... but I can see the utility of making/advertising a better video to help people in the future because I'm sure this is a common question! Let me know if this is still unclear and I'd be happy to help. ScottPlot has a Discord we almost never use but if that's a more convenient form of discussion I'd be happy to connect there.

You've been making fantastic contributions so far - thanks for all your work!

output-32.mp4

@swharden
Copy link
Member

womp, sorry about the audio quality - I was a little too aggressive with OBS Studio's noise gate 🤷

@BambOoxX
Copy link
Contributor Author

That's awesome ! Thanks. I will try to finish the examples tomorrow !

@BambOoxX
Copy link
Contributor Author

You've been making fantastic contributions so far - thanks for all your work!

That's very generous, I am mostly building on your canvas !

@swharden
Copy link
Member

Hi @BambOoxX! I see the cookbook example was there but the tests were complaining of an extra space at the bottom of the file 😝 The formatting of these cookbook recipes is a bit particular since the source code is parsed to generate the content of the website, and it was the double line break that failing test was complaining about.

image

I'll try to make this less finnicky in the future!

This is looking good, and about ready to merge. Before I do, can I confirm with you that this is the correct behavior, or give you the opportunity to change it once more? I'm noticing that when dragged to the right labels disappear one by one, but when dragged to the left labels disappear all at once. I'm guessing this is because harmonic labels are only drawn if the primary label is drawn? I didn't look deep into the code yet but thought I'd bounce this off you before I continue. Thanks for your input!

screenshot-drag5

@swharden
Copy link
Member

Actually this is working so well already I'm going to go ahead and merge it in so it gets in tonight's release.

If you want to refine the label behavior in a new PR, you're welcome to! As it is now, it's pretty good, and worth including in its present state.

@swharden swharden enabled auto-merge January 18, 2022 03:27
@swharden swharden merged commit af79b6a into ScottPlot:master Jan 18, 2022
@swharden swharden linked an issue Jan 18, 2022 that may be closed by this pull request
@BambOoxX
Copy link
Contributor Author

BambOoxX commented Jan 18, 2022

If you want to refine the label behavior in a new PR, you're welcome to! As it is now, it's pretty good, and worth including in its present state.

I will correct this. Also, I totally missed the AxisLineVector example. I will put up a PR for this too.

Do I have to create a new branch, or can this one still support these developments ?

@swharden
Copy link
Member

Do I have to create a new branch, or can this one still support these developments ?

I already merged this branch, and I recommend making a new branch 😅

Multiple, smaller, shorter-lived branches seem to be easier to work with than larger longer-lived branches which are more prone to merge conflicts.

@BambOoxX BambOoxX deleted the plottable-repeatingaxislines branch January 20, 2022 18:22
BambOoxX added a commit to BambOoxX/ScottPlot that referenced this pull request Jan 21, 2022
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

Successfully merging this pull request may close these issues.

New plot type: harmonic lines

2 participants