问题描述
我很确定这是一个关于 LAS 文件的非常琐碎的问题,但我不完全确定如何谷歌这个。对于上下文,我正在尝试根据 LAS 文件中的信息创建一个图。
import lasio as ls
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
well = ls.read(r'1051325649.las')
df = well.df()
fig = plt.subplots(figsize=(10,10))
#Set up the plot axes
ax1 = plt.subplot2grid((1,3),(0,0),rowspan=1,colspan = 1)
ax2 = plt.subplot2grid((1,1),colspan = 1)
ax3 = plt.subplot2grid((1,2),colspan = 1)
ax1.plot("GR","DEPT",data = df,color = "green") # Call the data from the well dataframe
ax1.set_title("Gamma") # Assign a track title
ax1.set_xlim(0,200) # Change the limits for the curve being plotted
ax1.set_ylim(400,1000) # Set the depth range
ax1.grid() # display the grid
LAS 文件看起来很像这样,我想在其中创建一个图,其中最左侧的列“DEPT”应该是 X 轴。但是,“DEPT”或深度列无法制作成允许我绘制它的格式。 **注意:右边有一个GR列不在这张图中,所以不用担心。任何提示都会有很大帮助。
解决方法
简答:
plt.plot
期望 "GR"
和 "DEPT"
都是 df
中的列,但是后者 (DEPT
) 不是列,而是索引.您可以通过将 df
中的索引转换为列来解决它:
df2 = df.reset_index()
ax1.plot("GR","DEPT",data = df2,color = "green")