Changeset 4781 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jan 19, 2021 11:34:26 AM (11 months ago)
Author:
vondreele
Message:

2D map contouring now fixed for matplotlib 3.3.2 - should work for earlier versions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r4770 r4781  
    126126    import wx.glcanvas
    127127    import matplotlib as mpl
    128     import matplotlib.pyplot as plt
    129128    if not mpl.get_backend():       #could be assigned by spyder debugger
    130129        mpl.use('wxAgg')
     
    12271226    Draw()
    12281227   
    1229        
    12301228################################################################################
    12311229##### Plot3DSngl
     
    17091707#    if firstCall: Draw('main') # draw twice the first time that graphics are displayed
    17101708
    1711        
    17121709################################################################################
    17131710##### PlotPatterns
     
    71227119                artist = Circle(spot[:2],radius=spot[2]/2,fc='none',ec='r',
    71237120                                picker=True)
    7124                 #GSASIIpath.IPyBreak()
    71257121                Page.figure.gca().add_artist(artist)
    71267122                artist.itemNumber = len(Masks['Points'])-1
     
    95739569            Z = np.where(Zslice<=Rmax,Zslice,Rmax)
    95749570            ZU = np.flipud(Z)
    9575             plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5)
    9576             oldSize = plt.rcParams['figure.figsize']
    9577             plt.rcParams['figure.figsize'] = [6.0,6.0]
    9578             plt.cla()
     9571            figure = mpl.figure.Figure(figsize=(6,6),facecolor=(1.,1.,1.,.5))
     9572            canvas = hcCanvas(figure)
     9573            figure.clf()
     9574            ax0 = figure.add_subplot(111)
    95799575            if drawingData.get('showSlice') in [1,]:
    9580                 contourSet = plt.contour(Z,colors='k',linewidths=1)
     9576                contourSet = ax0.contour(Z,colors='k',linewidths=1)
    95819577            if drawingData.get('showSlice') in [2,3]:
    95829578                acolor = mpl.cm.get_cmap(drawingData.get('contourColor','Paired'))                   
    9583                 plt.imshow(ZU,aspect='equal',cmap=acolor,alpha=0.7,interpolation='bilinear')
     9579                ax0.imshow(ZU,aspect='equal',cmap=acolor,alpha=0.7,interpolation='bilinear')
    95849580                if drawingData.get('showSlice') in [3,]:
    9585                     contourSet = plt.contour(ZU,colors='k',linewidths=1)
    9586             plt.axis("off")
    9587             plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.)
    9588             canvas = plt.get_current_fig_manager().canvas
     9581                    contourSet = ax0.contour(ZU,colors='k',linewidths=1)
     9582            ax0.axis("off")
     9583            figure.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.)
    95899584            agg = canvas.switch_backends(hcCanvas)
    95909585            agg.draw()
    95919586            img, (width, height) = agg.print_to_buffer()
    95929587            Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4))
    9593             plt.rcParams['figure.facecolor'] = (1.,1.,1.,1.)
    9594             plt.rcParams['figure.figsize'] = oldSize
    9595 #            agg = canvas.switch_backends(Canvas)
    95969588            RenderViewPlane(msize*eplane,Zimg,width,height)
    95979589        try:
Note: See TracChangeset for help on using the changeset viewer.