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

Labels become colors in figure options in qt backends #4303

Closed
Acanthostega opened this issue Apr 1, 2015 · 4 comments
Closed

Labels become colors in figure options in qt backends #4303

Acanthostega opened this issue Apr 1, 2015 · 4 comments
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues GUI: Qt status: confirmed bug
Milestone

Comments

@Acanthostega
Copy link
Contributor

Hi everyone,

I noticed a small issue in the implementation of the figure options panel inside the navigation tool bar for qt. If a plot as a name of a valid color in matplotlib, the field in the figure options becomes a color field and the label is converted into an hexadecimal color. The name of the curve is then affected by this change, since a later call to legend show that it has the hexadecimal color name. Since it is frequent I think to make plots with one letter name (y vs x), it would be nice to correct it.

The problem, looking at the source, is that the formlayout code has been modified to check if the value in a field is a valid matplotlib color, and if it is the case, returns a color field, converting the name of the color into hexadecimal. I think that such things should not be checked inside the formlayout code, but that colors should be explicitly converted into valid text color before submitting them to create a layout, for the field that are colors (here inside matplotlib.backend.qt_editor.figureoptions.py).

The problem appears with all fields. Opening the panel, setting the axes title to "y", validating and closing, reopening again the panel shows the problem.

I can make a PR if you want but not now (I must read the guidelines before...)

@tacaswell tacaswell added this to the next point release milestone Apr 1, 2015
@tacaswell tacaswell added the Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Apr 1, 2015
@tacaswell
Copy link
Member

Ha! That is a cute bug.

A PR would be most appreciated.

@Acanthostega
Copy link
Contributor Author

I think that the problem is a little more complex. With the formlayout used, every fields is processed in the same way. In order to be able to display a color field or a text field, the code have to decide if an argument is a color or not. So, keeping the formlayout module in the code, will always transform a field into a color field if the user, for example, wants to give the name "#FFFFFF" to its figure (what a weird user...), because it is a valid color name. The only idea I have is to reimplement the widget not using formlayout, it is not very useful I think.

If someone has an idea to not completely change the structure of this part of the code...

@tacaswell
Copy link
Member

You would be surprised what users want to do!

I don't remember exactly how that code works of the top of my head, does that processing code know the field name? If so, we can white-list 'label' and 'title'? Not sustainable, but solves this problem.

@Acanthostega
Copy link
Contributor Author

I implemented your idea and it corrects the problem. I sent a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues GUI: Qt status: confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants