python中怎么用matplotlib在一行里生成多个图?

  统计/机器学习 数据可视化 Python    浏览次数:9196        分享
0

比如这种效果


 

yangyang   2018-08-15 21:55



   1个回答 
5


import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 1, 100)
plt.figure(figsize=(10, 4))
# 一共有一行三列,现在画第一幅图
plt.subplot(1, 3, 1)
plt.plot(x, x ** 0.5)
# 一共有一行三列,现在画第二幅图
plt.subplot(1, 3, 2)
plt.plot(x, x ** 1)
# 一共有一行三列,现在画第三幅图
plt.subplot(1, 3, 3)
plt.plot(x, x ** 2)
plt.show()



SofaSofa数据科学社区DS面试题库 DS面经

abuu   2018-08-20 09:43



  相关讨论

python直方图y轴显示占比,而不是绝对数值

如何用matplotlib在3D空间呈现x^2+y^2?

%matplotlib inline什么意思?

matplotlib中bar plot横坐标的数字改成自定义的文字

seaborn如何显示图?

plt.plot作图,隐藏坐标轴

怎么给seaborn的heatmap里光谱柱添加名称?

怎么用matplotlib.pyplot画出堆积柱状图?

matplotlib.pyplot做折线图的时候,显示为虚线,或者点划线?

python做图自定义背景色

  随便看看

sota model是什么意思?

如何度量一个分布长尾的程度?

鞍点的数学定义是什么?

在使用PCA降维时,有哪些坑?

numpy.array转换为图片并显示出来