用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - python代码库

python双轴折线图示例

2022-11-30 作者: Python自学举报

[python]代码库

import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(2000)
date = np.random.standard_normal((20, 2))
y = date.cumsum(axis=0)

y[:, 0] = y[:, 0] * 100

fig, ax1 = plt.subplots()
plt.plot(y[:, 0], 'b', label="1st")
plt.plot(y[:, 0], 'ro')

plt.grid(True)
plt.axis('tight')
plt.xlabel("Index")
plt.ylabel('Values of 1st')
plt.title("This is double axis label")

plt.legend(loc=0)

ax2 = ax1.twinx()
plt.plot(y[:, 1], 'g', label="2st")
plt.plot(y[:, 1], 'r*')
plt.ylabel("Values of 2st")
plt.legend(loc=0)

plt.show()

[代码运行效果截图]


python双轴折线图示例


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...