Python:如何更改绘图中最大值的标签?

2024-09-29 03:38:27 发布

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

我试着画出那样的数据

#!/usr/bin/env python
# -*- coding: utf-8 -*-


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import glob
import os
dfp = pd.read_csv('/home/foo/file.csv', sep=',', encoding='utf-8')
ax = plt.subplot(111)
ax.plot(dfp['col3'], dfp['col2'], ls = '-', color='red', marker='x', markersize = 25.0)
ax3.set_xticks(pf['col3'])

ax.errorbar(dfp['col1'], dfp['col2'], yerr=dfp['PN_6_FLUX_ERR'], ls='None', marker = '.')
ax.set_xlim((dfp['col1'].min()-0.1*(dfp['col1'].max()-dfp['col1'].min())), ((dfp['col1'].max()+0.1*(dfp['col1'].max()-dfp['col1'].min()))))
ax.set_ylim((dfp['col2'].min()-dfp['col2'].max()),((dfp['col2'].max()/2.0)+dfp['col2'].max())
ax.grid()
plt.xticks(dfp['col1'])
plt.yticks(dfp['col2'])
plt.xlabel('col1')
plt.ylabel('col2')
plt.title('col1 vs. col2')

plt.show()

我的结果是:

original

我想得到col2的最大值,并将col3中相关值的x tick标签更改为“0”。像这样:

image2 我该怎么做?


Tags: csvimportaspltaxminlsmax