Skip to content
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

addCurve advances color index even if color is provided #4133

Closed
EdgarGF93 opened this issue Jun 13, 2024 · 3 comments · Fixed by #4138
Closed

addCurve advances color index even if color is provided #4133

EdgarGF93 opened this issue Jun 13, 2024 · 3 comments · Fixed by #4138
Milestone

Comments

@EdgarGF93
Copy link
Contributor

EdgarGF93 commented Jun 13, 2024

from silx.gui.plot import Plot2D
import numpy as np
from PyQt5.QtWidgets import QApplication, QMainWindow

if __name__ == "__main__":
    app = QApplication([])
    mw = QMainWindow()
    plot = Plot2D()

    x = np.linspace(0,10,10)
    y = [x, x ** 2]

    for _ in range(2):
        color, style = plot._getColorAndStyle()
        #color = f"black"
        print(f"color index is {plot._colorIndex}")
        plot.addCurve(x,y[_], color=color, legend=_)

    mw.setCentralWidget(plot)
    mw.show()
    app.exec_()

color index is 1
color index is 3

Would it make sense to make an if statement here?
If the color is provided (custom color or because we have requested the color before), do not request a new color

https://github.com/silx-kit/silx/blob/755fa6d3cbe35e1078f65557f6e9e8352b826da5/src/silx/gui/plot/PlotWidget.py#L1203C1-L1203C72

@t20100
Copy link
Member

t20100 commented Jun 13, 2024

Yes definitely!
It would also need to be fixed in PlotWidget.addHistogram

@t20100 t20100 added this to the Next release milestone Jun 13, 2024
@EdgarGF93
Copy link
Contributor Author

To #4138

@t20100
Copy link
Member

t20100 commented Jun 17, 2024

Reopening, this will get closed when PR #4138 gets merged

@t20100 t20100 reopened this Jun 17, 2024
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 a pull request may close this issue.

2 participants