x/y轴数据很多,怎么画优雅清晰的折线图

  • x,y轴数据比较多,几千个,使用matplotlib绘制折线图后,坐标数据都重叠在一起了,如何是的坐标轴数据清晰不重叠呢
  • 以下是我的代码
    def test_plots(time, time_list):
      a1 = pl.subplot(311)
      # a1.set_title("间隔")
      a1.set_ylabel("time(s)")
      a1.plot(time, time_list)
      pl.tight_layout()
      pl.show()
  • 生成效果(x轴是时间,数据很多)
讨论数量: 2
Jason990420

没给个不好的, 代码例子? 图例?

给个范围小一点, 才好回答, 这范围太大了, 比如什么折线图才是清晰优雅易读??

要有清晰优雅易读的提问内容, 才好回答问题…

3年前 评论
haohongbin (楼主) 3年前
Jason990420 (作者) 3年前
haohongbin (楼主) 3年前
Jason990420

你可以使用少量X轴的 tick

比如使用1000个tick

import math
import numpy as np
import matplotlib.pyplot as pl

def test_plots(time, time_list):
  a1 = pl.subplot(311)
  # a1.set_title("间隔")
  a1.set_ylabel("time(s)")
  a1.set_xticks(np.linspace(min(time), max(time), 1000))   # <----- Here
  a1.plot(time, time_list)
  pl.tight_layout()
  pl.show()

time = [i for i in range(10801)]
time_list = [10*math.cos(i/180*math.pi) for i in range(10801)]

test_plots(time, time_list)

file

比如使用10个tick

  a1.set_xticks(np.linspace(min(time), max(time), 10))   # <----- Here

file

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!