-
Notifications
You must be signed in to change notification settings - Fork 74
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
silx.gui.plot.PlotWidget.addCurve: Fixed progression in color, linestyle #4138
silx.gui.plot.PlotWidget.addCurve: Fixed progression in color, linestyle #4138
Conversation
Thanks for the PR! I think the rotation of the color and style should be handled differently between the 3 cases:
This code from silx import sx
w = sx.plot()
w.addCurve([1, 2], [0, 1], legend="1")
w.addCurve([1, 2], [0, 2], legend="2")
w.addCurve([1, 2], [0, 3], legend="3", color="black")
w.addCurve([1, 2], [0, 4], legend="4") displays: So passing only the color rotate the linestyle. I would propose the following behavior:
What do you think? |
Also, we need to keep the behavior as compatible as possible in order to limit unexpected changes for application using it. |
The way I did it:
I think this is the logical way, if the user provides a constant color and style, (s)he is aware that eventually the color-style is going to be duplicated. Is this behavior something to avoid at all? Because in that case we can easily use only one method (_getColorAndStyle), both indices (color and style) are always connected, and then repetition of curves is always avoided. |
Agreed. To me the key issue is that if both color and style are provided, it should not rotate the default. The fact that adding a curve with a color rotates the style for the next curve without color (see code in #4138 (comment)) sounds hard to understand without knowing the internals, thus my previous propositions reorganised here:
Agreed.
Anyone has comments on this discussion? |
Ok, yes, I fully agree with not-rotating the style if color is provided, especially because is keeping the same behavior as before the PR |
I think this way it stays as similar as before but solving the index bug and the rotating style discussion
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
I made a PR on your branch to include in this PR if it's OK for you to also fix the issue for the addHistogram
method
silx.gui.plot.PlotWidget.addHistogram: Fixed progression in color, linestyle
perfect, thanks |
Checklist:
<Module or Topic>: <Action> <Summary>
(see contributing guidelines)From #4133
This PR fixed the way the addCurve requests color and style (examples)
Test code:
Before the PR, addCurve request the color again (not to be used) but advances +1, so the colormap finish after 5 iterations:

Before the PR, it waits 10 color indexes to change the style:

closes #4133