@@ -956,6 +956,8 @@ def plot_models(opts, result, limits=None, setnum=0):
956956 if have_comp :
957957 plt .subplot (131 )
958958 plot_theory (base_data , base_value , view = view , use_data = use_data , limits = limits )
959+ if setnum > 0 :
960+ plt .legend ([f"Set { k + 1 } " for k in range (setnum + 1 )], loc = 'best' )
959961 plt .title ("%s t=%.2f ms" % (base .engine , base_time ))
960962 #cbar_title = "log I"
961963 if have_comp :
@@ -984,7 +986,6 @@ def plot_models(opts, result, limits=None, setnum=0):
984986 # at each q
985987 plot_theory (base_data , None , resid = err , view = errview , use_data = use_data )
986988 plt .xscale ('log' if view == 'log' and not opts ['is2d' ] else 'linear' )
987- plt .legend (['P%d' % (k + 1 ) for k in range (setnum + 1 )], loc = 'best' )
988989 plt .title ("max %s = %.3g" % (errstr , abs (err ).max ()))
989990 #cbar_title = errstr if errview=="linear" else "log "+errstr
990991 #if is2D:
@@ -1610,7 +1611,6 @@ def __init__(self, opts):
16101611 # type: (Dict[str, Any]) -> None
16111612 from bumps .cli import config_matplotlib # type: ignore
16121613 from . import bumps_model
1613-
16141614 config_matplotlib ()
16151615 self .opts = opts
16161616 opts ['pars' ] = list (opts ['pars' ])
@@ -1678,34 +1678,19 @@ def plot(self, view='log'):
16781678 """
16791679 Plot the data and residuals.
16801680 """
1681- import matplotlib .pyplot as plt
1682-
16831681 pars = dict ((k , v .value ) for k , v in self .pars .items ())
16841682 pars .update (self .pd_types )
16851683 self .opts ['pars' ][0 ] = pars
16861684 if not self .fix_p2 :
16871685 self .opts ['pars' ][1 ] = pars
1688- try :
1689- result = run_models (self .opts )
1690- except Exception as exc :
1691- print ("Exception %s while evaluating" % (exc .__class__ .__name__ ))
1692- import traceback
1693- traceback .print_exc ()
1694- plt .clf ()
1695- return
1686+ result = run_models (self .opts )
16961687 limits = plot_models (self .opts , result , limits = self .limits )
1697- is_sf = self .opts ['info' ][0 ].structure_factor
16981688 if self .limits is None :
16991689 vmin , vmax = limits
1700- if is_sf :
1701- self .limits = 0.01 , 4
1702- else :
1703- self .limits = vmax * 1e-7 , 1.3 * vmax
1704- plt .clf ()
1690+ self .limits = vmax * 1e-7 , 1.3 * vmax
1691+ import pylab
1692+ pylab .clf ()
17051693 plot_models (self .opts , result , limits = self .limits )
1706- #if is_sf:
1707- # plt.yscale('linear')
1708- # plt.xscale('linear')
17091694
17101695
17111696def main (* argv ):
0 commit comments