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

时间:2016-12-15 19:58:56

标签: python matplotlib axis-labels

我正在尝试绘制这样的数据,

#!/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 我怎么能这样做?

0 个答案:

没有答案