Matplotlib在X值python中绘制朱利安日

2024-09-27 04:22:54 发布

您现在位置:Python中文网/ 问答频道 /正文

您好,我在绘制从16000到17000的条形图x值时遇到问题,我不确定如何修复它。先谢谢你

plt.title("Site Data Availability")
plt.xlabel("Julian Year Dates (YYDDD)")
plt.ylabel("Instrument Sites")
plt.axhline(y="BTK", color='r', linestyle='-', linewidth=10)
plt.axhline(y="BTK", xmin=16000, xmax=17000, color='b', linestyle='-', linewidth=10) #issues with this line
plt.xlim(15000, 20000)
plt.xticks(rotation=90)

plt.show()

Tags: datatitle绘制sitepltyearcolor条形图
2条回答

编辑以下内容的行:

plt.axhline(y="BTK", xmin=.2, xmax=.4, color='b', linestyle='-', linewidth=10)

解释: xminxmax必须是介于0和1之间的值

在您的代码中,0由15000表示,1对应于20000

可以使用线性插值器,找出16000(0.2)和17000(0.4)的百分比

使用hlines

plt.title("Site Data Availability")
plt.xlabel("Julian Year Dates (YYDDD)")
plt.ylabel("Instrument Sites")
plt.axhline(y="BTK", color='r', linestyle='-', linewidth=10)
plt.hlines(y="BTK", xmin=16000, xmax=17000, color='b', linestyle='-', linewidth=10, zorder=10) #issues with this line
plt.xlim(15000, 20000)
plt.xticks(rotation=90)

plt.show()

输出:

enter image description here

其中

  • axhline在轴上添加一条水平线
  • hline在数据坐标中添加水平线。情节 从xmin到xmax的每个y处的水平线

相关问题 更多 >

    热门问题