Changeset 4416 for trunk/GSASIIplot.py


Ignore:
Timestamp:
May 9, 2020 2:14:54 PM (21 months ago)
Author:
vondreele
Message:

fix 3D surface problem when changing mystrain/size axis
remove MPLsubplots - obsolete sine mpl 2.2
reduce mpl > 3.03 warnings to just one
fix plotting of 3D size/mustrain surfaces - now consistent with values & table
add size & mustrain columns to Reflection Lists - checked against plots
provide better escape from crashed sequential refinement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r4415 r4416  
    290290    fil.write(line+'\n')
    291291
    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 of
    299 #         matplotlib. When v2.2 is standard, this should be removed from GSAS-II.
    300        
    301 #         :param int nrows, ncols: default: 1
    302 #             Number of rows/cols of the subplot grid.
    303 #         :param bool/str sharex, sharey: True/False or {'none', 'all', 'row', 'col'}, default: False
    304 
    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 all
    309 #                   subplots.
    310 #                 - False or 'none': each subplot x- or y-axis will be
    311 #                   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 tick
    316 #             labels of the bottom subplot are visible.  Similarly, when
    317 #             subplots have a shared y-axis along a row, only the y tick labels
    318 #             of the first column subplot are visible.
    319 #         :param bool squeeze: default: True
    320 
    321 #             - If True, extra dimensions are squeezed out from the returned
    322 #               axis object:
    323              
    324 #                 - if only one subplot is constructed (nrows=ncols=1), the
    325 #                   resulting single Axes object is returned as a scalar.
    326 #                 - for Nx1 or 1xN subplots, the returned object is a 1D numpy
    327 #                   object array of Axes objects are returned as numpy 1D
    328 #                   arrays.
    329 #                 - for NxM, subplots with N>1 and M>1 are returned as a 2D
    330 #                   arrays.
    331                  
    332 #             - If False, no squeezing at all is done: the returned Axes object
    333 #               is always a 2D array containing Axes instances, even if it ends
    334 #               up being 1x1.
    335              
    336 #         :param dict subplot_kw: default: {}
    337 #             Dict with keywords passed to the
    338 #             :meth:`matplotlib.figure.Figure.add_subplot` call used to create
    339 #             each subplots.
    340 #         :param dict gridspec_kw: default: {}
    341 #             Dict with keywords passed to the
    342 #             :class:`matplotlib.gridspec.GridSpec` constructor used to create
    343 #             the grid the subplots are placed on.
    344            
    345 #         :returns: A single Axes object or array of Axes objects with
    346 #             the added axes.  The dimensions of the resulting array can be
    347 #             controlled with the squeeze keyword, see above.
    348            
    349 #         See also: pyplot.subplots: pyplot API; docstring includes examples.
    350        
    351 #         """
    352 
    353 #         # for backwards compatibility
    354 #         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 type
    361 #             # `subplots(1, 2, 1)` when `subplot(1, 2, 1)` was intended.
    362 #             # In most cases, no error will ever occur, but mysterious behavior
    363 #             # will result because what was intended to be the subplot index is
    364 #             # 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 it
    384 #         #     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 labeling
    398 #         if sharex in ["col", "all"]:
    399 #             # turn off all but the bottom row
    400 #             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 column
    406 #             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 one
    413 #             # 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 axarr
    418292
    419293class _tabPlotWin(wx.Panel):   
     
    512386        self.nb.Bind(wx.EVT_KEY_UP,self.OnNotebookKey)
    513387        self.G2frame = G2frame
     388        self.MPLwarn = False
    514389       
    515390        self.plotList = []   # contains the tab label for each plot
     
    666541        self._addPage(name,page)
    667542        mplv = mpl.__version__.split('.')
    668         if mplv[0] == '3' and (mplv[1] == '1' or mplv[1] == '2'): # patch for bad MPL 3D
    669 
     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
    670545            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__,
    671546                                 'Avoid Matplotlib 3.1 & 3.2')
     
    58665741    PHI = np.linspace(0.,360.,40,True)
    58675742    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))
    58715746    try:        #temp patch instead of 'mustrain' for old files with 'microstrain'
    58725747        if plotDict[plotType]:
     
    58755750        return
    58765751    if plotType in ['Mustrain','Size']:
     5752        diam = 0.5
     5753        if plotType == 'Mustrain':
     5754            diam = 1.0
    58775755        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]                               
    58815759        elif coeff[0] == 'uniaxial':
    58825760           
     
    58865764                sp = np.sqrt(1.-cp**2)
    58875765                R = iso*aniso/np.sqrt((iso*cp)**2+(aniso*sp)**2)
    5888                 return R*xyz
     5766                return R*xyz*diam
    58895767               
    58905768            iso,aniso = coeff[1][:2]
     
    59035781            def ellipseCalc(xyz,E,R):
    59045782                XYZ = xyz*E.T
    5905                 return np.inner(XYZ.T,R)
     5783                return np.inner(XYZ.T,R)*diam
    59065784               
    59075785            S6 = coeff[4]
Note: See TracChangeset for help on using the changeset viewer.