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

New subplottool and various fixes #2112

Closed
wants to merge 7 commits into from
Closed

New subplottool and various fixes #2112

wants to merge 7 commits into from

Conversation

rhoef
Copy link
Contributor

@rhoef rhoef commented Jun 2, 2013

This pull request summarises three commits:

  1. subplottool customized
    -) new subplottool, sliders are all vertially arranged, buttons for tight layout and reset (new files: a ui file to compile formsubplottool.py using pyrcc)
    -) fix: subplottool is now modal dialog, was previously a QMainWindow, leaving the SPT open if one closed the plotwindow

  2. function col2hex could not handle different color representations of mpl. Further the hexcodes in the dict COLORS did not correspond to the hexcodes for the default colors (quick workaround since default colors are defined somewhere else.)

I also change the labeling of untitled axes figureoptions dialog.
Use the subplots_demo.py (at4 backend) to overview the changes.

subplottool
figureoptions

@efiring
Copy link
Member

efiring commented Jun 2, 2013

I think a critical functionality of the subplot tool must be to show the numeric values. This allows one to use the tool to find good values, and then use those values in a script. I don't know when this functionality was lost on the qt backend, but I hope you will restore it. This should be facilitated by the layout in your PR, which is closer to the original and generic mpl subplot tool--which is functionally quite good.

@rhoef
Copy link
Contributor Author

rhoef commented Jun 3, 2013

Here it is. the button also update the the labels.
What exactly went wrong with the commit 629d11c?

subplottool

@efiring
Copy link
Member

efiring commented Jun 3, 2013

Thank you--looks good! I haven't tested it or looked closely at the code.

What did you use to generate the .ui file?

The Travis failure looks completely unrelated.

@rhoef
Copy link
Contributor Author

rhoef commented Jun 6, 2013

I used the command
pyuic4 -o ui_myGUI.py myGUI.ui

pyuic4 comes with PyQt4. (or pyqt4-dev-tools on debian based systems) .

@efiring
Copy link
Member

efiring commented Jun 6, 2013

Right, that generates the .py file from the .ui file. Presumably you used Qt Designer to generate the .ui file. Does the PyQt4 tool write code that is immediately usable with pyside? We need to keep everything working with both pyqt4 and pyside.

@rhoef
Copy link
Contributor Author

rhoef commented Jun 9, 2013

As you see in my last commit I removed the ui file. There's just the formsubplottool.py, no compilation at all. It seemed to me simpler this way, since there is no framework to handle ui files. Although it would be nice to have, since handwriting of forms in general is inexpedient.

I tested it with pyqt4 and pyside.


def funcleft(self, val):
if val == self.sliderright.value():
val -= 1
self.targetfig.subplots_adjust(left=val/1000.)
val /= 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful about integer division here.

@thisch
Copy link
Contributor

thisch commented Jul 11, 2013

Should the qt4agg fixes and the subplottool improvements be separated into two independent PRs s.t. reviewing them is easier ?

win.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)

win.show()
image = os.path.join( matplotlib.rcParams['datapath'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite this module not being pep8 compliant, let's try to have the new code as pep8 as possible.
There should be no spaces after and before ( and ).

@rhoef
Copy link
Contributor Author

rhoef commented Jul 19, 2013

I meant "integer division"
Since I can click on the single commits, it is not worth to tear apart the pull request now, but I'll keep it in mind for future.

@tacaswell
Copy link
Member

@rhoef Can you re-base this branch?

@thisch
Copy link
Contributor

thisch commented Oct 26, 2013

edit:
rebase done + pep8 fixes

item, ok = QtGui.QInputDialog.getItem(self, 'Customize',
'Select axes:', titles,
0, False)
text = "_axes%d" % i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhoef why do you use a leading underscore here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The figureeditor uses this kind of notation for lines, graphs with no label. I took it over from there.

@thisch
Copy link
Contributor

thisch commented Nov 15, 2013

What still needs to be done in order to get this PR merged ?

@WeatherGod
Copy link
Member

Haven't looked over the PR, but you will definitely need to add an entry to the "whats_new.rst" file in the documentation.

@thisch
Copy link
Contributor

thisch commented Nov 15, 2013

I tried to separate the subplottool specific changes from the figureoptions stuff. The subplottools code is now in #2594, the figureoptions PR still needs to be done. @rhoef can you create the figureoptions PR ?

Here is the diff between this PR and #2594.

index 9bde376..7e7e844 100644
--- a/lib/matplotlib/backends/backend_qt4.py
+++ b/lib/matplotlib/backends/backend_qt4.py
@@ -615,18 +615,28 @@ class NavigationToolbar2QT(NavigationToolbar2, QtGui.QToolBar):
                 axes = allaxes[0]
             else:
                 titles = []
-                for i, axes in enumerate(allaxes):
+                for axes in allaxes:
+                    title = axes.get_title()
                     ylabel = axes.get_ylabel()
-                    text = "_axes%d" % i
-                    if ylabel:
-                        text += " %s" % ylabel
-                    titles.append(text)
+                    if title:
+                        fmt = "%(title)s"
+                        if ylabel:
+                            fmt += ": %(ylabel)s"
+                        fmt += " (%(axes_repr)s)"
+                    elif ylabel:
+                        fmt = "%(axes_repr)s (%(ylabel)s)"
+                    else:
+                        fmt = "%(axes_repr)s"
+                    titles.append(fmt % dict(title=title,
+                                         ylabel=ylabel,
+                                         axes_repr=repr(axes)))
                 item, ok = QtGui.QInputDialog.getItem(
                     self.parent, 'Customize', 'Select axes:', titles, 0, False)
                 if ok:
                     axes = allaxes[titles.index(six.text_type(item))]
                 else:
                     return
+
             figureoptions.figure_edit(axes, self)

     def _update_buttons_checked(self):
diff --git a/lib/matplotlib/backends/qt4_editor/figureoptions.py b/lib/matplotlib/backends/qt4_editor/figureoptions.py
index a8732bd..f9dc2f8 100644
--- a/lib/matplotlib/backends/qt4_editor/figureoptions.py
+++ b/lib/matplotlib/backends/qt4_editor/figureoptions.py
@@ -17,7 +17,6 @@ import os.path as osp
 import matplotlib.backends.qt4_editor.formlayout as formlayout
 from matplotlib.backends.qt4_compat import QtGui
 from matplotlib import markers
-from matplotlib.colors import rgb2hex

 def get_icon(name):
     import matplotlib
@@ -35,21 +34,6 @@ LINESTYLES = {

 MARKERS = markers.MarkerStyle.markers

-COLORS = {'c': '#00bfbf', 'b': '#0000ff', 'w': '#ffffff', 'g': '#008000',
-          'y': '#bfbf00', 'k': '#000000', 'r': '#ff0000', 'm': '#bf00bf'}
-
-def col2hex(color):
-    # default colors and hex colors
-    if isinstance(color, basestring):
-        try:
-            chex = COLORS[color]
-        except KeyError:
-            chex = color
-    else: # rgb tuples
-        chex = rgb2hex(color)
-    return chex
-
-
 def figure_edit(axes, parent=None):
     """Edit matplotlib figure options"""
     sep = (None, None) # separator

@tacaswell
Copy link
Member

This PR changes the new-style signal/slot calls back to the old-style, which suffer from a bug in PySides (see #2382).

👎 on merging this until the signals/slots are fixed.

@rhoef rhoef closed this Dec 17, 2013
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.

None yet

7 participants