Python 写入函数:plt的绘图栏,带有plt.title()的可选参数
您不能简单地将任意参数放入不需要它们的函数中 需要一个字符串作为输入 可以使用format方法生成字符串Python 写入函数:plt的绘图栏,带有plt.title()的可选参数,python,function,matplotlib,python-3.5,Python,Function,Matplotlib,Python 3.5,您不能简单地将任意参数放入不需要它们的函数中 需要一个字符串作为输入 可以使用format方法生成字符串 def plot_coexpression(new, gene1='', gene2='', gene3='', gene4='', gene5='', gene6=''): X, Y = zip(*new) import seaborn as sns sns.set() import matplotlib.pyplot as plt %matplo
def plot_coexpression(new, gene1='', gene2='', gene3='', gene4='', gene5='', gene6=''):
X, Y = zip(*new)
import seaborn as sns
sns.set()
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize = (20, 10))
plt.title('Genes most commonly co-expressed with' gene1="axin", gene2="lef", gene3="lgr", gene4="nkd", gene5="", gene6="", fontsize=40)
ax = plt.bar(range(len(X)), Y, 0.6, align='center', tick_label = X, color="green")
ax = plt.xticks(rotation=90)
File "<ipython-input-3-a3383d66ce8c>", line 8
plt.title('Genes most commonly co-expressed with' gene1="axin", gene2="lef", gene3="lgr", gene4="nkd", gene5="", gene6="", fontsize=40)
def plot_coexpression(new, gene1=None, gene2=None, gene3=None, gene4=None, gene5=None, gene6=None):
X, Y = zip(*new)
plt.figure(figsize = (20, 10))
plt.title('Genes most commonly co-expressed with' gene1, gene2, gene3, gene4, gene5, gene6,"'", fontsize=40)
ax = plt.bar(range(len(X)), Y, 0.6, align='center', tick_label = X, color="green")
ax = plt.xticks(rotation=90)
mytitle = "This is my title, containing {gene1}".format(gene1="axin")
plt.title(mytitle)