Changeset 5d80bbf in sasmodels


Ignore:
Timestamp:
Nov 19, 2015 6:50:00 PM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
525f3a9
Parents:
66ebdd6
Message:

don't plot empty plots on log scale

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/bumps_model.py

    rcd8dde1 r5d80bbf  
    3535import datetime 
    3636import warnings 
     37import traceback 
    3738 
    3839import numpy as np 
     
    216217        Boxcut(x_min=-np.inf, x_max=np.inf, y_min=-np.inf, y_max=cutoff)(data) 
    217218 
    218  
     219def protect(fn): 
     220    def wrapper(*args, **kw): 
     221        try:  
     222            return fn(*args, **kw) 
     223        except: 
     224            traceback.print_exc() 
     225    return wrapper 
     226 
     227@protect 
    219228def _plot_result1D(data, theory, resid, view, include_data=True): 
    220229    """ 
     
    234243        plt.subplot(121) 
    235244 
     245    positive = False 
    236246    if include_data: 
    237247        plt.errorbar(data.x, scale*mdata, yerr=data.dy, fmt='.') 
     248        positive = positive or (mdata>0).any() 
    238249    if theory is not None: 
    239250        mtheory = masked_array(theory, mdata.mask) 
    240251        plt.plot(data.x, scale*mtheory, '-', hold=True) 
     252        positive = positive or (mtheory>0).any() 
    241253    plt.xscale(view) 
    242     plt.yscale('linear' if view == 'q4' else view) 
     254    plt.yscale('linear' if view == 'q4' or not positive else view) 
    243255    plt.xlabel('Q') 
    244256    plt.ylabel('I(Q)') 
     
    252264 
    253265# pylint: disable=unused-argument 
     266@protect 
    254267def _plot_sesans(data, theory, resid, view): 
    255268    import matplotlib.pyplot as plt 
     
    264277    plt.ylabel('residuals (P/P0)') 
    265278 
     279@protect 
    266280def _plot_result2D(data, theory, resid, view): 
    267281    """ 
     
    290304    plt.colorbar() 
    291305 
     306@protect 
    292307def _plot_2d_signal(data, signal, vmin=None, vmax=None, view='log'): 
    293308    """ 
Note: See TracChangeset for help on using the changeset viewer.