8000 New subplottool and various fixes by rhoef · Pull Request #2112 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

New subplottool and various fixes #2112

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
value labels in subplottool added
  • Loading branch information
rhoef authored and twmr committed Oct 26, 2013
commit 2364f4794c793dd6d33530310e10c2874b8c43a4
29 changes: 21 additions & 8 deletions lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@ def _setSliderPositions(self):
int(self.targetfig.subplotpars.bottom*1000))
self.sliderright.setSliderPosition(
int(self.targetfig.subplotpars.right*1000))
self.slidertop.setSliderPosition(int(
self.targetfig.subplotpars.top*1000))
self.slidertop.setSliderPosition(
int(self.targetfig.subplotpars.top*1000))
self.sliderwspace.setSliderPosition(
int(self.targetfig.subplotpars.wspace*1000))
self.sliderhspace.setSliderPosition(
Expand All @@ -793,43 +793,56 @@ def _setSliderPositions(self):
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.

self.targetfig.subplots_adjust(left=val)
self.leftvalue.setText("%.2f" %val)
if self.drawon:
self.targetfig.canvas.draw()

def funcright(self, val):
if val == self.sliderleft.value():
val += 1
self.targetfig.subplots_adjust(right=val/1000.)
val /= 1000.
self.targetfig.subplots_adjust(right=val)
self.rightvalue.setText("%.2f" %val)
if self.drawon:
self.targetfig.canvas.draw()

def funcbottom(self, val):
if val == self.slidertop.value():
val -= 1
self.targetfig.subplots_adjust(bottom=val/1000.)
val /= 1000.
self.targetfig.subplots_adjust(bottom=val)
self.bottomvalue.setText("%.2f" %val)
if self.drawon:
self.targetfig.canvas.draw()

def functop(self, val):
if val == self.sliderbottom.value():
val += 1
self.targetfig.subplots_adjust(top=val/1000.)
val /= 1000.0
self.targetfig.subplots_adjust(top=val)
self.topvalue.setText("%.2f" %val)
if self.drawon:
self.targetfig.canvas.draw()

def funcwspace(self, val):
self.targetfig.subplots_adjust(wspace=val/1000.)
val /= 1000.
self.targetfig.subplots_adjust(wspace=val)
self.wspacevalue.setText("%.2f" %val)
if self.drawon:
self.targetfig.canvas.draw()

def funchspace(self, val):
self.targetfig.subplots_adjust(hspace=val/1000.)
val /= 1000.
self.targetfig.subplots_adjust(hspace=val)
self.hspacevalue.setText("%.2f" %val)
if self.drawon:
self.targetfig.canvas.draw()

def functight(self):
self.targetfig.tight_layout()
self._setSliderPositions()
self.targetfig.canvas.draw()

def reset(self):
Expand Down
79 changes: 63 additions & 16 deletions lib/matplotlib/backends/qt4_editor/formsubplottool.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'subplot_conftool.ui'
# Form implementation generated from reading ui file 'lib/matplotlib/backends/qt4_editor/subplot_conftool.ui'
#
# Created: Sun May 5 20:30:44 2013
# by: PyQt4 UI code generator 4.9.3
# Created: Mon Jun 3 01:47:41 2013
# by: PyQt4 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!

Expand All @@ -12,7 +12,16 @@
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_SubplotTool(object):
def setupUi(self, SubplotTool):
Expand Down Expand Up @@ -60,13 +69,20 @@ def setupUi(self, SubplotTool):
self.labeltop.setObjectName(_fromUtf8("labeltop"))
self.hboxtop.addWidget(self.labeltop)
self.slidertop = QtGui.QSlider(self.groupBox)
self.slidertop.setMouseTracking(False)
self.slidertop.setProperty("value", 0)
self.slidertop.setOrientation(QtCore.Qt.Horizontal)
self.slidertop.setInvertedAppearance(False)
self.slidertop.setInvertedControls(False)
self.slidertop.setTickPosition(QtGui.QSlider.TicksAbove)
self.slidertop.setTickInterval(100)
self.slidertop.setObjectName(_fromUtf8("slidertop"))
self.hboxtop.addWidget(self.slidertop)
self.topvalue = QtGui.QLabel(self.groupBox)
self.topvalue.setMinimumSize(QtCore.QSize(30, 0))
self.topvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.topvalue.setObjectName(_fromUtf8("topvalue"))
self.hboxtop.addWidget(self.topvalue)
self.verticalLayout.addLayout(self.hboxtop)
self.hboxbottom = QtGui.QHBoxLayout()
self.hboxbottom.setObjectName(_fromUtf8("hboxbottom"))
Expand All @@ -87,6 +103,11 @@ def setupUi(self, SubplotTool):
self.sliderbottom.setTickInterval(100)
self.sliderbottom.setObjectName(_fromUtf8("sliderbottom"))
self.hboxbottom.addWidget(self.sliderbottom)
self.bottomvalue = QtGui.QLabel(self.groupBox)
self.bottomvalue.setMinimumSize(QtCore.QSize(30, 0))
self.bottomvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.bottomvalue.setObjectName(_fromUtf8("bottomvalue"))
self.hboxbottom.addWidget(self.bottomvalue)
self.verticalLayout.addLayout(self.hboxbottom)
self.hboxleft = QtGui.QHBoxLayout()
self.hboxleft.setObjectName(_fromUtf8("hboxleft"))
Expand All @@ -107,6 +128,11 @@ def setupUi(self, SubplotTool):
self.sliderleft.setTickInterval(100)
self.sliderleft.setObjectName(_fromUtf8("sliderleft"))
self.hboxleft.addWidget(self.sliderleft)
self.leftvalue = QtGui.QLabel(self.groupBox)
self.leftvalue.setMinimumSize(QtCore.QSize(30, 0))
self.leftvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.leftvalue.setObjectName(_fromUtf8("leftvalue"))
self.hboxleft.addWidget(self.leftvalue)
self.verticalLayout.addLayout(self.hboxleft)
self.hboxright = QtGui.QHBoxLayout()
self.hboxright.setObjectName(_fromUtf8("hboxright"))
Expand All @@ -127,6 +153,11 @@ def setupUi(self, SubplotTool):
self.sliderright.setTickInterval(100)
self.sliderright.setObjectName(_fromUtf8("sliderright"))
self.hboxright.addWidget(self.sliderright)
self.rightvalue = QtGui.QLabel(self.groupBox)
self.rightvalue.setMinimumSize(QtCore.QSize(30, 0))
self.rightvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.rightvalue.setObjectName(_fromUtf8("rightvalue"))
self.hboxright.addWidget(self.rightvalue)
self.verticalLayout.addLayout(self.hboxright)
self.gridLayout.addWidget(self.groupBox, 5, 0, 1, 1)
self.groupBox_2 = QtGui.QGroupBox(SubplotTool)
Expand Down Expand Up @@ -154,6 +185,11 @@ def setupUi(self, SubplotTool):
self.sliderhspace.setTickInterval(100)
self.sliderhspace.setObjectName(_fromUtf8("sliderhspace"))
self.hboxhspace.addWidget(self.sliderhspace)
self.hspacevalue = QtGui.QLabel(self.groupBox_2)
self.hspacevalue.setMinimumSize(QtCore.QSize(30, 0))
self.hspacevalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.hspacevalue.setObjectName(_fromUtf8("hspacevalue"))
self.hboxhspace.addWidget(self.hspacevalue)
self.verticalLayout_2.addLayout(self.hboxhspace)
self.hboxwspace = QtGui.QHBoxLayout()
self.hboxwspace.setObjectName(_fromUtf8("hboxwspace"))
Expand All @@ -175,6 +211,11 @@ def setupUi(self, SubplotTool):
self.sliderwspace.setTickInterval(100)
self.sliderwspace.setObjectName(_fromUtf8("sliderwspace"))
self.hboxwspace.addWidget(self.sliderwspace)
self.wspacevalue = QtGui.QLabel(self.groupBox_2)
self.wspacevalue.setMinimumSize(QtCore.QSize(30, 0))
self.wspacevalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.wspacevalue.setObjectName(_fromUtf8("wspacevalue"))
self.hboxwspace.addWidget(self.wspacevalue)
self.verticalLayout_2.addLayout(self.hboxwspace)
self.gridLayout.addWidget(self.groupBox_2, 6, 0, 1, 1)
self.horizontalLayout.addLayout(self.gridLayout)
Expand All @@ -184,15 +225,21 @@ def setupUi(self, SubplotTool):
QtCore.QMetaObject.connectSlotsByName(SubplotTool)

def retranslateUi(self, SubplotTool):
SubplotTool.setWindowTitle(QtGui.QApplication.translate("SubplotTool", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.tightLayout.setText(QtGui.QApplication.translate("SubplotTool", "tight layout", None, QtGui.QApplication.UnicodeUTF8))
self.resetButton.setText(QtGui.QApplication.translate("SubplotTool", "reset", None, QtGui.QApplication.UnicodeUTF8))
self.doneButton.setText(QtGui.QApplication.translate("SubplotTool", "close", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("SubplotTool", "Borders", None, QtGui.QApplication.UnicodeUTF8))
self.labeltop.setText(QtGui.QApplication.translate("SubplotTool", "top", None, QtGui.QApplication.UnicodeUTF8))
self.labelbottom.setText(QtGui.QApplication.translate("SubplotTool", "bottom", None, QtGui.QApplication.UnicodeUTF8))
self.labelleft.setText(QtGui.QApplication.translate("SubplotTool", "left", None, QtGui.QApplication.UnicodeUTF8))
self.labelright.setText(QtGui.QApplication.translate("SubplotTool", "right", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_2.setTitle(QtGui.QApplication.translate("SubplotTool", "Spaces", None, QtGui.QApplication.UnicodeUTF8))
self.labelhspace.setText(QtGui.QApplication.translate("SubplotTool", "hspace", None, QtGui.QApplication.UnicodeUTF8))
self.labelwspace.setText(QtGui.QApplication.translate("SubplotTool", "wspace", None, QtGui.QApplication.UnicodeUTF8))
SubplotTool.setWindowTitle(_translate("SubplotTool", "Dialog", None))
self.tightLayout.setText(_translate("SubplotTool", "tight layout", None))
self.resetButton.setText(_translate("SubplotTool", "reset", None))
self.doneButton.setText(_translate("SubplotTool", "close", None))
self.groupBox.setTitle(_translate("SubplotTool", "Borders", None))
self.labeltop.setText(_translate("SubplotTool", "top", None))
self.topvalue.setText(_translate("SubplotTool", "0", None))
self.labelbottom.setText(_translate("SubplotTool", "bottom", None))
self.bottomvalue.setText(_translate("SubplotTool", "0", None))
self.labelleft.setText(_translate("SubplotTool", "left", None))
self.leftvalue.setText(_translate("SubplotTool", "0", None))
self.labelright.setText(_translate("SubplotTool", "right", None))
self.rightvalue.setText(_translate("SubplotTool", "0", None))
self.groupBox_2.setTitle(_translate("SubplotTool", "Spaces", None))
self.labelhspace.setText(_translate("SubplotTool", "hspace", None))
self.hspacevalue.setText(_translate("SubplotTool", "0", None))
self.labelwspace.setText(_translate("SubplotTool", "wspace", None))
self.wspacevalue.setText(_translate("SubplotTool", "0", None))
102 changes: 102 additions & 0 deletions lib/matplotlib/backends/qt4_editor/subplot_conftool.ui
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
</item>
<item>
<widget class="QSlider" name="slidertop">
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -134,6 +140,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="topvalue">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -176,6 +198,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="bottomvalue">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -218,6 +256,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="leftvalue">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -260,6 +314,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rightvalue">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down Expand Up @@ -317,6 +387,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="hspacevalue">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -362,6 +448,22 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="wspacevalue">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
54E7 </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
0