Changeset 34f23c8 in sasview for src/sas/sasgui/plottools/PlotPanel.py
- Timestamp:
- Mar 20, 2019 10:06:22 AM (6 years ago)
- Branches:
- ticket-1249
- Children:
- 9305b46
- Parents:
- 09d7021
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/PlotPanel.py
r82d88d5 r34f23c8 339 339 # On Windows platform, default window size is incorrect, so set 340 340 # toolbar width to figure width. 341 tw, th = self.toolbar.GetSize Tuple()342 fw, fh = self.canvas.GetSize Tuple()341 tw, th = self.toolbar.GetSize() 342 fw, fh = self.canvas.GetSize() 343 343 # By adding toolbar in sizer, we are able to put it at the bottom 344 344 # of the frame - so appearance is closer to GTK version. … … 439 439 y = hi_y 440 440 # Move the legend from its previous location by that same amount 441 loc_in_canvas = self.legend_x - mouse_diff_x, \442 self.legend_y - mouse_diff_y441 loc_in_canvas = (self.legend_x - mouse_diff_x, 442 self.legend_y - mouse_diff_y) 443 443 # Transform into legend coordinate system 444 444 trans_axes = self.legend.parent.transAxes.inverted() … … 630 630 Return values and labels used by Fit Dialog 631 631 """ 632 return self.xLabel, self.yLabel, self.Avalue, self.Bvalue, \633 self.ErrAvalue, self.ErrBvalue, self.Chivalue 632 return (self.xLabel, self.yLabel, self.Avalue, self.Bvalue, 633 self.ErrAvalue, self.ErrBvalue, self.Chivalue) 634 634 635 635 def setTrans(self, xtrans, ytrans): … … 667 667 title='Linear Fit') 668 668 669 if ( self.xmin != 0.0)and (self.xmax != 0.0)\670 and(self.xminView != 0.0)and (self.xmaxView != 0.0):669 if ((self.xmin != 0.0) and (self.xmax != 0.0) 670 and (self.xminView != 0.0) and (self.xmaxView != 0.0)): 671 671 dlg.setFitRange(self.xminView, self.xmaxView, 672 672 self.xmin, self.xmax) … … 925 925 except: 926 926 # toolbar event 927 pos_x, pos_y = self.toolbar.GetPosition Tuple()927 pos_x, pos_y = self.toolbar.GetPosition() 928 928 pos = (pos_x, pos_y + 5) 929 929 … … 1059 1059 Allows you to add text to the plot 1060 1060 """ 1061 xaxis_label, xaxis_unit, xaxis_font, xaxis_color, \1062 is_ok, is_tick= self._on_axis_label(axis='x')1061 xaxis_label, xaxis_unit, xaxis_font, xaxis_color, is_ok, is_tick \ 1062 = self._on_axis_label(axis='x') 1063 1063 if not is_ok: 1064 1064 return … … 1073 1073 if self.data is not None: 1074 1074 # 2D 1075 self.xaxis(self.xaxis_label, self.xaxis_unit, \1076 1075 self.xaxis(self.xaxis_label, self.xaxis_unit, 1076 self.xaxis_font, self.xaxis_color, self.xaxis_tick) 1077 1077 self.subplot.figure.canvas.draw_idle() 1078 1078 else: … … 1106 1106 Allows you to add text to the plot 1107 1107 """ 1108 yaxis_label, yaxis_unit, yaxis_font, yaxis_color, \1109 is_ok, is_tick= self._on_axis_label(axis='y')1108 yaxis_label, yaxis_unit, yaxis_font, yaxis_color, is_ok, is_tick \ 1109 = self._on_axis_label(axis='y') 1110 1110 if not is_ok: 1111 1111 return … … 1120 1120 if self.data is not None: 1121 1121 # 2D 1122 self.yaxis(self.yaxis_label, self.yaxis_unit, \1122 self.yaxis(self.yaxis_label, self.yaxis_unit, 1123 1123 self.yaxis_font, self.yaxis_color, self.yaxis_tick) 1124 1124 self.subplot.figure.canvas.draw_idle() … … 1156 1156 is_tick = textdial.getTickLabel() 1157 1157 label_temp = textdial.getText() 1158 if label_temp.count("\%s" % "\\") > 0: 1158 if r"\\" in label_temp: 1159 label = label_temp.replace(r"\\", r"??") 1159 1160 if self.parent is not None: 1160 msg = "Add Label: Error.Can not use double '\\' "1161 msg = r"Add Label error: Can not use double '\\' " 1161 1162 msg += "characters..." 1162 1163 wx.PostEvent(self.parent, StatusEvent(status=msg)) … … 1533 1534 """ 1534 1535 # No qx or qy given in a vector format 1535 if self.qx_data is None or self.qy_data is None \1536 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1 :1536 if (self.qx_data is None or self.qy_data is None 1537 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1): 1537 1538 # do we need deepcopy here? 1538 1539 return copy.deepcopy(self.data) … … 1593 1594 """ 1594 1595 # No qx or qy given in a vector format 1595 if self.qx_data is None or self.qy_data is None \1596 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1 :1596 if (self.qx_data is None or self.qy_data is None 1597 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1): 1597 1598 # do we need deepcopy here? 1598 1599 return copy.deepcopy(self.data) … … 1644 1645 """ 1645 1646 # No image matrix given 1646 if image is None or np.ndim(image) != 2 \ 1647 or np.isfinite(image).all() \ 1648 or weights is None: 1647 if (image is None or np.ndim(image) != 2 1648 or np.isfinite(image).all() or weights is None): 1649 1649 return image 1650 1650 # Get bin size in y and x directions … … 1676 1676 # go 4 next nearest neighbors when no non-zero 1677 1677 # neighbor exists 1678 if n_y != 0 and n_x != 0 and \1679 np.isfinite(image[n_y - 1][n_x - 1]):1678 if (n_y != 0 and n_x != 0 1679 and np.isfinite(image[n_y - 1][n_x - 1])): 1680 1680 temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 1681 1681 weit[n_y][n_x] += 1 1682 if n_y != len_y - 1 and n_x != 0 and \1683 np.isfinite(image[n_y + 1][n_x - 1]):1682 if (n_y != len_y - 1 and n_x != 0 1683 and np.isfinite(image[n_y + 1][n_x - 1])): 1684 1684 temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 1685 1685 weit[n_y][n_x] += 1 1686 if n_y != len_y and n_x != len_x - 1 and \1687 np.isfinite(image[n_y - 1][n_x + 1]):1686 if (n_y != len_y and n_x != len_x - 1 1687 and np.isfinite(image[n_y - 1][n_x + 1])): 1688 1688 temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 1689 1689 weit[n_y][n_x] += 1 1690 if n_y != len_y - 1 and n_x != len_x - 1 and \1691 np.isfinite(image[n_y + 1][n_x + 1]):1690 if (n_y != len_y - 1 and n_x != len_x - 1 1691 and np.isfinite(image[n_y + 1][n_x + 1])): 1692 1692 temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 1693 1693 weit[n_y][n_x] += 1 … … 1784 1784 item.transformX(transform.toX2, transform.errToX2) 1785 1785 xunits = convert_unit(2, xunits) 1786 self.graph._xaxis_transformed("%s^ {2}" % xname, "%s" % xunits)1786 self.graph._xaxis_transformed("%s^2" % xname, "%s" % xunits) 1787 1787 if self.xLabel == "x^(4)": 1788 1788 item.transformX(transform.toX4, transform.errToX4) 1789 1789 xunits = convert_unit(4, xunits) 1790 self.graph._xaxis_transformed("%s^ {4}" % xname, "%s" % xunits)1790 self.graph._xaxis_transformed("%s^4" % xname, "%s" % xunits) 1791 1791 if self.xLabel == "ln(x)": 1792 1792 item.transformX(transform.toLogX, transform.errToLogX) 1793 self.graph._xaxis_transformed( "\ln{(%s)}" % xname, "%s" % xunits)1793 self.graph._xaxis_transformed(r"\ln(%s)" % xname, "%s" % xunits) 1794 1794 if self.xLabel == "log10(x)": 1795 1795 item.transformX(transform.toX_pos, transform.errToX_pos) … … 1799 1799 item.transformX(transform.toX4, transform.errToX4) 1800 1800 xunits = convert_unit(4, xunits) 1801 self.graph._xaxis_transformed("%s^ {4}" % xname, "%s" % xunits)1801 self.graph._xaxis_transformed("%s^4" % xname, "%s" % xunits) 1802 1802 _xscale = 'log' 1803 1803 if self.yLabel == "ln(y)": 1804 1804 item.transformY(transform.toLogX, transform.errToLogX) 1805 self.graph._yaxis_transformed( "\ln{(%s)}" % yname, "%s" % yunits)1805 self.graph._yaxis_transformed(r"\ln(%s)" % yname, "%s" % yunits) 1806 1806 if self.yLabel == "y": 1807 1807 item.transformY(transform.toX, transform.errToX) … … 1822 1822 item.transformY(transform.toYX2, transform.errToYX2) 1823 1823 xunits = convert_unit(2, self.xaxis_unit) 1824 self.graph._yaxis_transformed( "%s \ \ %s^{2}" % (yname, xname),1824 self.graph._yaxis_transformed(r"%s \ \ %s^2" % (yname, xname), 1825 1825 "%s%s" % (yunits, xunits)) 1826 1826 if self.yLabel == "y*x^(4)": 1827 1827 item.transformY(transform.toYX4, transform.errToYX4) 1828 1828 xunits = convert_unit(4, self.xaxis_unit) 1829 self.graph._yaxis_transformed( "%s \ \ %s^{4}" % (yname, xname),1829 self.graph._yaxis_transformed(r"%s \ \ %s^4" % (yname, xname), 1830 1830 "%s%s" % (yunits, xunits)) 1831 1831 if self.yLabel == "1/sqrt(y)": … … 1833 1833 transform.errOneOverSqrtX) 1834 1834 yunits = convert_unit(-0.5, yunits) 1835 self.graph._yaxis_transformed( "1/\sqrt{%s}" % yname,1835 self.graph._yaxis_transformed(r"1/\sqrt{%s}" % yname, 1836 1836 "%s" % yunits) 1837 1837 if self.yLabel == "ln(y*x)": 1838 1838 item.transformY(transform.toLogXY, transform.errToLogXY) 1839 self.graph._yaxis_transformed( "\ln{(%s \ \ %s)}" % (yname, xname),1839 self.graph._yaxis_transformed(r"\ln(%s \ \ %s)" % (yname, xname), 1840 1840 "%s%s" % (yunits, self.xaxis_unit)) 1841 1841 if self.yLabel == "ln(y*x^(2))": 1842 1842 item.transformY(transform.toLogYX2, transform.errToLogYX2) 1843 1843 xunits = convert_unit(2, self.xaxis_unit) 1844 self.graph._yaxis_transformed( "\ln (%s \ \ %s^{2})" % (yname, xname),1844 self.graph._yaxis_transformed(r"\ln(%s \ \ %s^2)" % (yname, xname), 1845 1845 "%s%s" % (yunits, xunits)) 1846 1846 if self.yLabel == "ln(y*x^(4))": 1847 1847 item.transformY(transform.toLogYX4, transform.errToLogYX4) 1848 1848 xunits = convert_unit(4, self.xaxis_unit) 1849 self.graph._yaxis_transformed( "\ln (%s \ \ %s^{4})" % (yname, xname),1849 self.graph._yaxis_transformed(r"\ln(%s \ \ %s^4)" % (yname, xname), 1850 1850 "%s%s" % (yunits, xunits)) 1851 1851 if self.yLabel == "log10(y*x^(4))": … … 1853 1853 xunits = convert_unit(4, self.xaxis_unit) 1854 1854 _yscale = 'log' 1855 self.graph._yaxis_transformed( "%s \ \ %s^{4}" % (yname, xname),1855 self.graph._yaxis_transformed(r"%s \ \ %s^4" % (yname, xname), 1856 1856 "%s%s" % (yunits, xunits)) 1857 1857 item.transformView() … … 1897 1897 # Saving value to redisplay in Fit Dialog when it is opened again 1898 1898 self.Avalue, self.Bvalue, self.ErrAvalue, \ 1899 1899 self.ErrBvalue, self.Chivalue = func 1900 1900 self.xminView = xminView 1901 1901 self.xmaxView = xmaxView
Note: See TracChangeset
for help on using the changeset viewer.