You can populate the ops
object with the common properties and then add others in your if statement:
// initalize ops with common properties
var ops = {
xaxis: {show: false},
yaxis: {show: false}
};
if (i == 1 && $('#ln').val() == 'true') {
ops.yaxis.transform = function (v) { return -v; };
ops.yaxis.inverseTransform = function (v) { return -v; };
}
$.plot($(gr), pdat, ops);