Skip to content

Commit b113184

Browse files
committed
potFitCurve takes ax argument
1 parent 8d60a8d commit b113184

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/fitFun.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def returnParamsFromResults(final_params, param_names=None):
386386

387387
def plotFitCurve(concentrations, subSeries, results,
388388
fitParameters, log_axis=None, func=None, use_default=None,
389-
fittype=None, errors=None, default_errors=None):
389+
fittype=None, errors=None, default_errors=None, ax=None):
390390
# default is to log axis
391391
if log_axis is None:
392392
log_axis = True
@@ -427,14 +427,15 @@ def plotFitCurve(concentrations, subSeries, results,
427427
eminus = eplus = default_errors/np.sqrt(numTests)
428428

429429
# plot binding points
430-
plt.figure(figsize=(2.5,2.3));
431-
plt.errorbar(concentrations, fluorescence,
430+
if ax is None:
431+
fig = plt.figure(figsize=(2.5,2.3));
432+
ax = fig.add_subplot(111)
433+
ax.errorbar(concentrations, fluorescence,
432434
yerr=[eminus, eplus], fmt='.', elinewidth=1,
433435
capsize=2, capthick=1, color='k', linewidth=1)
434436

435437
# plot fit
436438
if log_axis:
437-
ax = plt.gca()
438439
ax.set_xscale('log')
439440
more_concentrations = np.logspace(np.log10(concentrations.min()/2),
440441
np.log10(concentrations.max()*2),
@@ -445,7 +446,7 @@ def plotFitCurve(concentrations, subSeries, results,
445446
param_names = fitParameters.columns.tolist()
446447
params = returnParamsFromResults(results, param_names)
447448
fit = func(params, more_concentrations)
448-
plt.plot(more_concentrations, fit, 'r')
449+
ax.plot(more_concentrations, fit, 'r')
449450

450451
try:
451452
# find upper bound
@@ -479,7 +480,7 @@ def plotFitCurve(concentrations, subSeries, results,
479480
label='95% conf int', alpha=0.5)
480481
except:
481482
pass
482-
ax = plt.gca()
483+
483484
ax.tick_params(right='off', top='off')
484485
ax.tick_params(which="minor", right='off', top='off')
485486
ylim = ax.get_ylim()

0 commit comments

Comments
 (0)