python 柱状图折线图共用一个图例_matplotlib:组合不同的图形并将它们放在一个子块中,共享一个共同的图例...

这能解决你的问题吗?x = [ 1, 2, 3, 5, 10, 100, 1000 ]

y1 = [ 1, 0.822, 0.763, 0.715, 0.680, 0.648, 0.645 ]

y2 = [ 1, 0.859, 0.812, 0.774, 0.746, 0.721, 0.718 ]

import matplotlib.pyplot as plt

from matplotlib.transforms import BlendedGenericTransform

# mode 01 from one case

fig1 = plt.figure()

ax1 = fig1.add_subplot(111)

line1, = ax1.plot( x, y1, label='mode 01' )

# mode 01 from other case

fig2 = plt.figure()

ax2 = fig2.add_subplot(111)

line2, = ax2.plot( x, y2, label='mode 01' )

# Create new figure and two subplots, sharing both axes

fig3, (ax3, ax4) = plt.subplots(1,2,sharey=True, sharex=True,figsize=(10,5))

# Plot data from fig1 and fig2

line3, = ax3.plot(line1.get_data()[0], line1.get_data()[1])

line4, = ax4.plot(line2.get_data()[0], line2.get_data()[1])

# If

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值