.CSV ファイルから同じプロットに 3 セットの (x, y) データをプロットしようと何週間も試みてきましたが、どこにも行きません。私のデータはもともと Excel ファイルでしたが、これを .CSV ファイルに変換しpandas
、次のコードに従って IPython に読み込むために使用しました。
from pandas import DataFrame, read_csv
import pandas as pd
# define data location
df = read_csv(Location)
df[['LimMag1.3', 'ExpTime1.3', 'LimMag2.0', 'ExpTime2.0', 'LimMag2.5','ExpTime2.5']][:7]
私のデータは次の形式です。
Type mag1 time1 mag2 time2 mag3 time3
M0 8.87 41.11 8.41 41.11 8.16 65.78;
...
M6 13.95 4392.03 14.41 10395.13 14.66 25988.32
time1
vs mag1
、time2
vs mag2
、およびtime3
vsをすべて同じプロットにプロットしようとしていますmag3
が、代わりにtime..
vsのプロットを取得しますType
。コードの場合:
df['ExpTime1.3'].plot()
私が欲しいのはvsで、x-labels -の場合、(y 軸)を(x'ExpTime1.3'
軸) に対してプロットします。M0
M6
'ExpTime1.3'
'LimMag1.3'
M0
M6
3 セットのデータすべてが同じプロットにある
'ExpTime..'
vsプロットを取得するにはどうすればよいですか?'LimMag..'
M0
値の x 軸 (x 軸も) の-M6
ラベルを取得するにはどうすればよい'LimMag..'
ですか?
不明な理由でプロットを返さなかったaskewchanのソリューションを試して以来ExpTime
、データフレームインデックス(df.index)をx軸の値(LimMag
LimMag1.3 df['ExpTime1.3'].plot(),
)。ただし、これは、必要な x 軸のすべての値を手動で入力してデータ インデックスにすることにより、必要な各 x 軸をデータフレーム インデックスに変換する必要があることを意味しているようです。私は非常に多くのデータを持っていますが、この方法は遅すぎます.1つのグラフに各データセットの3つのシリーズすべてをプロットする必要がある場合、一度に1つのデータセットしかプロットできません. この問題を回避する方法はありますか? または、askewchan が提供するソリューションで II がプロットをまったく得られなかった理由について、誰かが理由と解決策を提供できますか?\
nordev に応答して、最初のバージョンをもう一度試しましたが、プロットは作成されず、空の図も作成されません。コマンドの 1 つを入力するたびにax.plot
、 type: の出力が得られますが
[<matplotlib.lines.Line2D at 0xb5187b8>]
、コマンドを入力してplt.show()
も何も起こりません。plt.show()
askewchan の 2 番目のソリューションでループの後に入ると、次のエラーが返されます。AttributeError: 'function' object has no attribute 'show'
元のコードをもう少しいじって、インデックスを x 軸 (LimMag1.3) と同じにすることで、コードでExpTime1.3
vsのプロットを取得できるようになりましたが、他の 2 つのセットを取得できません同じプロット上のデータ。他にご提案がありましたら、よろしくお願いいたします。Anaconda 1.5.0 (64bit) 経由で ipython 0.11.0 を使用しており、Windows 7 (64bit) では spyder を使用しています。python のバージョンは 2.7.4 です。LimMag1.3
df['ExpTime1.3'][:7].plot()