Вот комплексный метод clone (), который может клонировать любой объект JavaScript. Он обрабатывает почти все случаи:
function clone(src, deep) {
var toString = Object.prototype.toString;
if (!src && typeof src != "object") {
// Any non-object (Boolean, String, Number), null, undefined, NaN
return src;
}
// Honor native/custom clone methods
if (src.clone && toString.call(src.clone) == "[object Function]") {
return src.clone(deep);
}
// DOM elements
if (src.nodeType && toString.call(src.cloneNode) == "[object Function]") {
return src.cloneNode(deep);
}
// Date
if (toString.call(src) == "[object Date]") {
return new Date(src.getTime());
}
// RegExp
if (toString.call(src) == "[object RegExp]") {
return new RegExp(src);
}
// Function
if (toString.call(src) == "[object Function]") {
//Wrap in another method to make sure == is not true;
//Note: Huge performance issue due to closures, comment this :)
return (function(){
src.apply(this, arguments);
});
}
var ret, index;
//Array
if (toString.call(src) == "[object Array]") {
//[].slice(0) would soft clone
ret = src.slice();
if (deep) {
index = ret.length;
while (index--) {
ret[index] = clone(ret[index], true);
}
}
}
//Object
else {
ret = src.constructor ? new src.constructor() : {};
for (var prop in src) {
ret[prop] = deep
? clone(src[prop], true)
: src[prop];
}
}
return ret;
};
Не уверен, что это то, что вы хотите, но вы можете добавить suptitle или текст и установить для разных шрифтов следующим образом:
plt.title('Mean WRFv3.5 LHF\n', fontsize=40)
plt.suptitle('(September 16 - October 30, 2012)\n', fontsize=18)
plt.text(0.5, 1, 'the third line', fontsize=13, ha='center')
[/g1]
Надеюсь, это поможет.
Попробуйте:
import matplotlib.pyplot as plt
plt.rc('text', usetex=True)
plt.title(r'{\fontsize{30pt}{3em}\selectfont{}{Mean WRFv3.5 LHF\r}{\fontsize{18pt}{3em}\selectfont{}(September 16 - October 30, 2012)}')
plt.show()
То, что \r
может хотеть быть \n
в вашей системе.
Я использовал ответ Джоэля, чтобы ответить на ваш вопрос.
RuntimeError: LaTeX was not able to process the following string: 'lp'
в Mac. Кажется, решение предназначено для установки texlive-latex-extra . Я попробовал, но не работал.
– JeeYem
5 May 2017 в 23:29