python y轴分两段_将x轴分成两个以上的部分(Python)

这篇博客展示了如何在Python中创建一个图形,该图形的Y轴被分为三段,每段有自己的X轴范围和比例。作者使用matplotlib库,通过手动设置轴参数和数据绘制了这样一个图形,包括不同颜色的曲线和详细的X轴刻度。
摘要由CSDN通过智能技术生成

这是一个例子,展示了我是如何通过在图形中手动放置三个轴来完成的。在from __future__ import division, unicode_literals

import matplotlib.pyplot as plt

import numpy as np

plt.close('all')

# - PREPARE DATA

t = np.arange(0, 7 * 10**5, 10)

x = np.abs(np.sin(t/10.**2)) * 300

# - FIG CREATION

fig = plt.figure(figsize=(8, 5), facecolor='white')

# Margins (dimensions are in inches):

left_margin = 0.6 / fig.get_figwidth()

right_margin = 0.25 / fig.get_figwidth()

bottom_margin = 0.75 / fig.get_figheight()

top_margin = 0.25 / fig.get_figwidth()

mid_margin = 0.1 / fig.get_figwidth() # horizontal space between subplots

# - DEFINE PARAMETERS FOR EACH AXE

# Proportion of the figure's width taken by each axe (the sum must == 1):

f = [0.5, 0.3, 0.2]

xmin = [200,

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值