Changeset 4416 for trunk/GSASIIplot.py
- Timestamp:
- May 9, 2020 2:14:54 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r4415 r4416 290 290 fil.write(line+'\n') 291 291 292 # def MPLsubplots(figure, nrows=1, ncols=1, sharex=False, sharey=False,293 # squeeze=True, subplot_kw=None, gridspec_kw=None):294 # """295 # Add a set of subplots to this figure.296 297 # This is a copy of Figure.figure.subplots from matplotlib.figure.py.298 # Included here because this appears only in later versions of299 # matplotlib. When v2.2 is standard, this should be removed from GSAS-II.300 301 # :param int nrows, ncols: default: 1302 # Number of rows/cols of the subplot grid.303 # :param bool/str sharex, sharey: True/False or {'none', 'all', 'row', 'col'}, default: False304 305 # Controls sharing of properties among x (`sharex`) or y (`sharey`)306 # axes:307 308 # - True or 'all': x- or y-axis will be shared among all309 # subplots.310 # - False or 'none': each subplot x- or y-axis will be311 # independent.312 # - 'row': each subplot row will share an x- or y-axis.313 # - 'col': each subplot column will share an x- or y-axis.314 315 # When subplots have a shared x-axis along a column, only the x tick316 # labels of the bottom subplot are visible. Similarly, when317 # subplots have a shared y-axis along a row, only the y tick labels318 # of the first column subplot are visible.319 # :param bool squeeze: default: True320 321 # - If True, extra dimensions are squeezed out from the returned322 # axis object:323 324 # - if only one subplot is constructed (nrows=ncols=1), the325 # resulting single Axes object is returned as a scalar.326 # - for Nx1 or 1xN subplots, the returned object is a 1D numpy327 # object array of Axes objects are returned as numpy 1D328 # arrays.329 # - for NxM, subplots with N>1 and M>1 are returned as a 2D330 # arrays.331 332 # - If False, no squeezing at all is done: the returned Axes object333 # is always a 2D array containing Axes instances, even if it ends334 # up being 1x1.335 336 # :param dict subplot_kw: default: {}337 # Dict with keywords passed to the338 # :meth:`matplotlib.figure.Figure.add_subplot` call used to create339 # each subplots.340 # :param dict gridspec_kw: default: {}341 # Dict with keywords passed to the342 # :class:`matplotlib.gridspec.GridSpec` constructor used to create343 # the grid the subplots are placed on.344 345 # :returns: A single Axes object or array of Axes objects with346 # the added axes. The dimensions of the resulting array can be347 # controlled with the squeeze keyword, see above.348 349 # See also: pyplot.subplots: pyplot API; docstring includes examples.350 351 # """352 353 # # for backwards compatibility354 # if isinstance(sharex, bool):355 # sharex = "all" if sharex else "none"356 # if isinstance(sharey, bool):357 # sharey = "all" if sharey else "none"358 # share_values = ["all", "row", "col", "none"]359 # if sharex not in share_values:360 # # This check was added because it is very easy to type361 # # `subplots(1, 2, 1)` when `subplot(1, 2, 1)` was intended.362 # # In most cases, no error will ever occur, but mysterious behavior363 # # will result because what was intended to be the subplot index is364 # # instead treated as a bool for sharex.365 # if isinstance(sharex, int):366 # warnings.warn(367 # "sharex argument to subplots() was an integer. "368 # "Did you intend to use subplot() (without 's')?")369 370 # raise ValueError("sharex [%s] must be one of %s" %371 # (sharex, share_values))372 # if sharey not in share_values:373 # raise ValueError("sharey [%s] must be one of %s" %374 # (sharey, share_values))375 # if subplot_kw is None:376 # subplot_kw = {}377 # if gridspec_kw is None:378 # gridspec_kw = {}379 380 # # if figure.get_constrained_layout():381 # # gs = GridSpec(nrows, ncols, figure=figure, **gridspec_kw)382 # # else:383 # # # this should turn constrained_layout off if we don't want it384 # # gs = GridSpec(nrows, ncols, figure=None, **gridspec_kw)385 # gs = mpl.gridspec.GridSpec(nrows, ncols, **gridspec_kw)386 387 # # Create array to hold all axes.388 # axarr = np.empty((nrows, ncols), dtype=object)389 # for row in range(nrows):390 # for col in range(ncols):391 # shared_with = {"none": None, "all": axarr[0, 0],392 # "row": axarr[row, 0], "col": axarr[0, col]}393 # subplot_kw["sharex"] = shared_with[sharex]394 # subplot_kw["sharey"] = shared_with[sharey]395 # axarr[row, col] = figure.add_subplot(gs[row, col], **subplot_kw)396 397 # # turn off redundant tick labeling398 # if sharex in ["col", "all"]:399 # # turn off all but the bottom row400 # for ax in axarr[:-1, :].flat:401 # ax.xaxis.set_tick_params(which='both',402 # labelbottom=False, labeltop=False)403 # ax.xaxis.offsetText.set_visible(False)404 # if sharey in ["row", "all"]:405 # # turn off all but the first column406 # for ax in axarr[:, 1:].flat:407 # ax.yaxis.set_tick_params(which='both',408 # labelleft=False, labelright=False)409 # ax.yaxis.offsetText.set_visible(False)410 411 # if squeeze:412 # # Discarding unneeded dimensions that equal 1. If we only have one413 # # subplot, just return it instead of a 1-element array.414 # return axarr.item() if axarr.size == 1 else axarr.squeeze()415 # else:416 # # Returned axis array will be always 2-d, even if nrows=ncols=1.417 # return axarr418 292 419 293 class _tabPlotWin(wx.Panel): … … 512 386 self.nb.Bind(wx.EVT_KEY_UP,self.OnNotebookKey) 513 387 self.G2frame = G2frame 388 self.MPLwarn = False 514 389 515 390 self.plotList = [] # contains the tab label for each plot … … 666 541 self._addPage(name,page) 667 542 mplv = mpl.__version__.split('.') 668 if mplv[0] == '3' and (mplv[1] == '1' or mplv[1] == '2') : # patch for bad MPL 3D669 543 if mplv[0] == '3' and (mplv[1] == '1' or mplv[1] == '2') and not self.MPLwarn: # patch for bad MPL 3D 544 self.MPLwarn = True 670 545 G2G.G2MessageBox(self,'3D plots with Matplotlib 3.1.x and 3.2.x are distorted, we suggest regressing to MPL 3.0.3 until 3.3.x or later is available.. You have '+mpl.__version__, 671 546 'Avoid Matplotlib 3.1 & 3.2') … … 5866 5741 PHI = np.linspace(0.,360.,40,True) 5867 5742 PSI = np.linspace(0.,180.,40,True) 5868 X = np.outer(npcosd(PHI),npsind(PSI)) /2.5869 Y = np.outer(npsind(PHI),npsind(PSI)) /2.5870 Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI)) /2.5743 X = np.outer(npcosd(PHI),npsind(PSI)) 5744 Y = np.outer(npsind(PHI),npsind(PSI)) 5745 Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI)) 5871 5746 try: #temp patch instead of 'mustrain' for old files with 'microstrain' 5872 5747 if plotDict[plotType]: … … 5875 5750 return 5876 5751 if plotType in ['Mustrain','Size']: 5752 diam = 0.5 5753 if plotType == 'Mustrain': 5754 diam = 1.0 5877 5755 if coeff[0] == 'isotropic': 5878 X *= coeff[1][0]5879 Y *= coeff[1][0]5880 Z *= coeff[1][0]5756 X *= diam*coeff[1][0] 5757 Y *= diam*coeff[1][0] 5758 Z *= diam*coeff[1][0] 5881 5759 elif coeff[0] == 'uniaxial': 5882 5760 … … 5886 5764 sp = np.sqrt(1.-cp**2) 5887 5765 R = iso*aniso/np.sqrt((iso*cp)**2+(aniso*sp)**2) 5888 return R*xyz 5766 return R*xyz*diam 5889 5767 5890 5768 iso,aniso = coeff[1][:2] … … 5903 5781 def ellipseCalc(xyz,E,R): 5904 5782 XYZ = xyz*E.T 5905 return np.inner(XYZ.T,R) 5783 return np.inner(XYZ.T,R)*diam 5906 5784 5907 5785 S6 = coeff[4]
Note: See TracChangeset
for help on using the changeset viewer.