-1
我有2個文件數據,我試圖使用matplotlib創建一個數字:縮放地塊matplotlib
data1.csv:
T1,T2,Energy
-10.0,-10.0,-135.17209154
-9.0,-9.0,-135.15961763
-8.0,-8.0,-135.12933854
-7.0,-7.0,-135.08764644
-6.0,-6.0,-135.04017015
-5.0,-5.0,-134.9917753
-4.0,-4.0,-134.9465778
-3.0,-3.0,-134.90793353
-2.0,-2.0,-134.8782808
-1.0,-1.0,-134.86001462
0.0,0.0,-134.85401885
1.0,1.0,-134.86001461
2.0,2.0,-134.87828068
3.0,3.0,-134.90793366
4.0,4.0,-134.94657765
5.0,5.0,-134.99177495
6.0,6.0,-135.04017025
7.0,7.0,-135.08764629
8.0,8.0,-135.12933843
9.0,9.0,-135.15961751
10.0,10.0,-135.17209131
data2.csv:
T1,T2,Energy
-10.0,-10.0,-117.71068713
-9.0,-9.0,-117.80680053
-8.0,-8.0,-117.87570934
-7.0,-7.0,-117.92318137
-6.0,-6.0,-117.95416633
-5.0,-5.0,-117.97304758
-4.0,-4.0,-117.98349172
-3.0,-3.0,-117.9884913
-2.0,-2.0,-117.99017179
-1.0,-1.0,-117.99078073
0.0,0.0,-117.99109191
1.0,1.0,-117.99083075
2.0,2.0,-117.99029791
3.0,3.0,-117.98887774
4.0,4.0,-117.98440979
5.0,5.0,-117.97484573
6.0,6.0,-117.95727936
7.0,7.0,-117.92813366
8.0,8.0,-117.88311587
9.0,9.0,-117.81736874
10.0,10.0,-117.72521723
我寫的腳本:
!/usr/bin/env python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
FRAME1 = pd.read_csv('data1.csv')
FRAME2 = pd.read_csv('data2.csv')
FRAME1.columns = ['T1', 'T2', 'ENERGY']
FRAME2.columns = ['T1', 'T2', 'ENERGY']
FRAME1 = FRAME1.iloc[::-1]
FRAME2 = FRAME2.iloc[::-1]
plt.plot(FRAME1['T1'],FRAME1['ENERGY'], marker = 'o', label='1')
plt.plot(FRAME2['T1'],FRAME2['ENERGY'], marker = 'o', label='2')
plt.legend(loc='upper right')
plt.ylim = np.arange(-140.854019, -118.991092, 0.002)
plt.xlabel(r'$\Delta T$')
plt.ylabel('Eint')
plt.grid(True)
plt.savefig("test.png")
plt.show()
我的情節似乎幾乎是線性的。我想改變一個比例尺,並以真實的拋物線形狀顯示它們。
你可以改變比例' plt.ylim',但如果你想在同一張圖上繪製兩張圖,你的縮放比例將與圖片上顯示的相似(因爲y的最小值接近-135,最大接近-117)。您可以爲'ylim'分配不同的值,但最有可能之後只有一張圖將出現在圖片上。你喜歡什麼樣的身材? –