在一个图中而不是在多个图中绘制多个图形
Plotting multiple graphs in one figure instead of in multiple figures
我试图将来自三个文件的数据绘制在一张图中。截至目前,我尝试只做两个文件。他们都被绘制成图表,但是是两个不同的数字。
我希望它们合二为一 graph/figure/window。
如果我需要更新问题的任何部分而不降级,请告诉我。我真的很感激。我愿意接受任何建议。非常感谢!
示例数据 1:
20190601T034207 NAME cc130.aa.bb NAME-7600816.2005 1 1 NAME-37x161 37x161 d39c13 2821 0 0ce000 1283 JOBS/NAME-7600816.2005/blast-37-161.txt
20190601T034214 NAME cc128.aa.bb NAME-7600816.2004 1 1 NAME-37x161 37x161 d39c13 2815 0 0ce000 1283 JOBS/NAME-7600816.2004/blast-37-161.txt
20190601T034208 NAME nn019.aa.bb NAME-7600816.2008 1 1 NAME-37x161 37x161 d39c13 3465 0 0ce000 1283 JOBS/NAME-7600816.2008/blast-37-161.txt
20190601T034220 NAME nn058.aa.bb NAME-7600816.2010 1 1 NAME-37x161 37x161 d39c13 3462 0 0ce000 1283 JOBS/NAME-7600816.2010/blast-37-161.txt
20190601T034217 NAME nn011.aa.bb NAME-7600816.2014 1 1 NAME-37x161 37x161 d39c13 3469 0 0ce000 1283 JOBS/NAME-7600816.2014/blast-37-161.txt
20190601T034219 NAME nn224.aa.bb NAME-7600816.2015 1 1 NAME-37x161 37x161 d39c13 3468 0 0ce000 1283 JOBS/NAME-7600816.2015/blast-37-161.txt
更新:
def file_processing (file_name, scatter_color, ax):
ax.scatter(x,y, s=4, c=scatter_color, label=file_name)
if args.File1:
file1=args.File1
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file1, "blue", ax)
if args.File2:
file2=args.File2
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file2, "green",ax)
if args.File3:
file3=args.File3
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
x = fig.add_subplot(1,1,1)
file_processing(file3, "red",ax)
您需要从 file_processing
函数中取出 ax
并输入参数,如下所示:
def file_processing (file_name, scatter_color, ax):
# Move these 2 out of here:
# fig = plt.figure(figsize=(12.80,9.60),dpi=100)
# ax = fig.add_subplot(1,1,1)
if args.File1:
# Put it here:
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file1, "blue", ax)
更新,完整解决方案
def file_processing (file_name, scatter_color, ax):
ax.scatter(x,y, s=4, c=scatter_color, label=file_name)
if args.File1:
file1=args.File1
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file1, "blue", ax)
if args.File2:
file2=args.File2
file_processing(file2, "green",ax)
if args.File3:
file3=args.File3
file_processing(file3, "red",ax)
我试图将来自三个文件的数据绘制在一张图中。截至目前,我尝试只做两个文件。他们都被绘制成图表,但是是两个不同的数字。 我希望它们合二为一 graph/figure/window。
如果我需要更新问题的任何部分而不降级,请告诉我。我真的很感激。我愿意接受任何建议。非常感谢!
示例数据 1:
20190601T034207 NAME cc130.aa.bb NAME-7600816.2005 1 1 NAME-37x161 37x161 d39c13 2821 0 0ce000 1283 JOBS/NAME-7600816.2005/blast-37-161.txt
20190601T034214 NAME cc128.aa.bb NAME-7600816.2004 1 1 NAME-37x161 37x161 d39c13 2815 0 0ce000 1283 JOBS/NAME-7600816.2004/blast-37-161.txt
20190601T034208 NAME nn019.aa.bb NAME-7600816.2008 1 1 NAME-37x161 37x161 d39c13 3465 0 0ce000 1283 JOBS/NAME-7600816.2008/blast-37-161.txt
20190601T034220 NAME nn058.aa.bb NAME-7600816.2010 1 1 NAME-37x161 37x161 d39c13 3462 0 0ce000 1283 JOBS/NAME-7600816.2010/blast-37-161.txt
20190601T034217 NAME nn011.aa.bb NAME-7600816.2014 1 1 NAME-37x161 37x161 d39c13 3469 0 0ce000 1283 JOBS/NAME-7600816.2014/blast-37-161.txt
20190601T034219 NAME nn224.aa.bb NAME-7600816.2015 1 1 NAME-37x161 37x161 d39c13 3468 0 0ce000 1283 JOBS/NAME-7600816.2015/blast-37-161.txt
更新:
def file_processing (file_name, scatter_color, ax):
ax.scatter(x,y, s=4, c=scatter_color, label=file_name)
if args.File1:
file1=args.File1
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file1, "blue", ax)
if args.File2:
file2=args.File2
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file2, "green",ax)
if args.File3:
file3=args.File3
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
x = fig.add_subplot(1,1,1)
file_processing(file3, "red",ax)
您需要从 file_processing
函数中取出 ax
并输入参数,如下所示:
def file_processing (file_name, scatter_color, ax):
# Move these 2 out of here:
# fig = plt.figure(figsize=(12.80,9.60),dpi=100)
# ax = fig.add_subplot(1,1,1)
if args.File1:
# Put it here:
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file1, "blue", ax)
更新,完整解决方案
def file_processing (file_name, scatter_color, ax):
ax.scatter(x,y, s=4, c=scatter_color, label=file_name)
if args.File1:
file1=args.File1
fig = plt.figure(figsize=(12.80,9.60),dpi=100)
ax = fig.add_subplot(1,1,1)
file_processing(file1, "blue", ax)
if args.File2:
file2=args.File2
file_processing(file2, "green",ax)
if args.File3:
file3=args.File3
file_processing(file3, "red",ax)