Changeset 275511c in sasmodels


Ignore:
Timestamp:
Feb 14, 2019 12:23:35 PM (4 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
4057e06
Parents:
3d7f364
Message:

restore matplotlib version of jitter viewer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/jitter.py

    r3d7f364 r275511c  
    5353from numpy import pi, cos, sin, sqrt, exp, degrees, radians 
    5454 
    55 def draw_beam(axes, view=(0, 0), alpha=0.5, steps=6): 
     55def draw_beam(axes, view=(0, 0), alpha=0.5, steps=25): 
    5656    """ 
    5757    Draw the beam going from source at (0, 0, 1) to detector at (0, 0, -1) 
     
    7676 
    7777    # TODO: draw endcaps on beam 
    78     ## Draw tiny balls on the end will work 
    79     draw_sphere(axes, radius=0.02, center=(0, 0, 1.3), color='yellow') 
    80     draw_sphere(axes, radius=0.02, center=(0, 0, -1.3), color='yellow') 
     78    ## Drawing tiny balls on the end will work 
     79    #draw_sphere(axes, radius=0.02, center=(0, 0, 1.3), color='yellow', alpha=alpha) 
     80    #draw_sphere(axes, radius=0.02, center=(0, 0, -1.3), color='yellow', alpha=alpha) 
    8181    ## The following does not work 
    8282    #triangles = [(0, i+1, i+2) for i in range(steps-2)] 
     
    200200 
    201201    x, y, z = transform_xyz(view, jitter, x, y, z) 
    202     axes.plot_trisurf(x, y, triangles=tri, Z=z, color=color, alpha=alpha) 
     202    axes.plot_trisurf(x, y, triangles=tri, Z=z, color=color, alpha=alpha, 
     203                      linewidth=0) 
    203204 
    204205    # Colour the c+ face of the box. 
     
    223224    ]) 
    224225 
    225 def draw_sphere(axes, radius=0.5, steps=25, center=(0,0,0), color='w'): 
     226def draw_sphere(axes, radius=0.5, steps=25, center=(0,0,0), color='w', alpha=1.): 
    226227    """Draw a sphere""" 
    227228    u = np.linspace(0, 2 * np.pi, steps) 
     
    231232    y = radius * np.outer(np.sin(u), np.sin(v)) + center[1] 
    232233    z = radius * np.outer(np.ones(np.size(u)), np.cos(v)) + center[2] 
    233     axes.plot_surface(x, y, z, color=color) 
     234    axes.plot_surface(x, y, z, color=color, alpha=alpha) 
    234235    #axes.plot_wireframe(x, y, z) 
    235236 
     
    981982        pass 
    982983 
    983     axcolor = 'lightgoldenrodyellow' 
     984    #axcolor = {'facecolor': 'lightgoldenrodyellow'} 
     985    axcolor = {} 
    984986 
    985987    ## add control widgets to plot 
    986     axes_theta = plt.axes([0.1, 0.15, 0.45, 0.04], facecolor=axcolor) 
    987     axes_phi = plt.axes([0.1, 0.1, 0.45, 0.04], facecolor=axcolor) 
    988     axes_psi = plt.axes([0.1, 0.05, 0.45, 0.04], facecolor=axcolor) 
     988    axes_theta = plt.axes([0.1, 0.15, 0.45, 0.04], **axcolor) 
     989    axes_phi = plt.axes([0.1, 0.1, 0.45, 0.04], **axcolor) 
     990    axes_psi = plt.axes([0.1, 0.05, 0.45, 0.04], **axcolor) 
    989991    stheta = Slider(axes_theta, u'Ξ', -90, 90, valinit=0) 
    990992    sphi = Slider(axes_phi, u'φ', -180, 180, valinit=0) 
    991993    spsi = Slider(axes_psi, u'ψ', -180, 180, valinit=0) 
    992994 
    993     axes_dtheta = plt.axes([0.75, 0.15, 0.15, 0.04], facecolor=axcolor) 
    994     axes_dphi = plt.axes([0.75, 0.1, 0.15, 0.04], facecolor=axcolor) 
    995     axes_dpsi = plt.axes([0.75, 0.05, 0.15, 0.04], facecolor=axcolor) 
     995    axes_dtheta = plt.axes([0.75, 0.15, 0.15, 0.04], **axcolor) 
     996    axes_dphi = plt.axes([0.75, 0.1, 0.15, 0.04], **axcolor) 
     997    axes_dpsi = plt.axes([0.75, 0.05, 0.15, 0.04], **axcolor) 
    996998    # Note: using ridiculous definition of rectangle distribution, whose width 
    997999    # in sasmodels is sqrt(3) times the given width.  Divide by sqrt(3) to keep 
     
    10311033 
    10321034        ## Move shape and draw scattering 
    1033         draw_beam(axes, (0, 0)) 
    1034         draw_jitter(axes, view, jitter, dist=dist, size=size, 
     1035        draw_beam(axes, (0, 0), alpha=1.) 
     1036        draw_jitter(axes, view, jitter, dist=dist, size=size, alpha=1., 
    10351037                    draw_shape=draw_shape, projection=projection, views=3) 
    10361038        draw_mesh(axes, view, jitter, dist=dist, n=mesh, projection=projection) 
     
    11631165            return h 
    11641166        def plot_trisurf(self, x, y, triangles=None, Z=None, **kw): 
     1167            kw.pop('linewidth', None) 
    11651168            ipv_fix_color(kw) 
    11661169            x, y, z = make_vec(x, y, Z) 
Note: See TracChangeset for help on using the changeset viewer.