Herkese merhaba, kısaca anlatmak gerekirse pythonda dataframe oluşturup bu dataframe verilerini çizimimde kullanmak istiyorum. Normalde dataframe oluşturma işini excelin kendisinde(formül yazarak) yapıyordum ancak pythonın içinde bu işlemi yapmamın daha doğru olacağını düşündüm. Kodlarım şu şekilde;
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_excel(‘C:/Users/gbilici/Desktop/xlsestimation/xlsestimation.xlsx’)
df.loc[(df.GR < 30) & (df.CALIPER > 20) , “Unit”] = ‘1’
df.Unit.fillna(‘2’, inplace=True)
data = df.loc[df[‘WELL’] == ‘V118A’][[‘DEPTH_MD’, ‘GR’, ‘CALIPER’,‘Unit’]]
lithology_numbers = {1: {‘lith’:‘Trona’, ‘lith_num’:1, ‘hatch’: ‘+’, ‘color’:‘aqua’},
2: {‘lith’:‘Shale’, ‘lith_num’:2, ‘hatch’:’-.’, ‘color’:’#ffe119’},
3: {‘lith’:‘Sst’, ‘lith_num’:3, ‘hatch’:’–’, ‘color’:’#bebebe’}}
def makeplot(well, top_depth, bottom_depth):
fig, ax = plt.subplots(figsize=(15,10))
ax1 = plt.subplot2grid((1,3), (0,0), rowspan=1, colspan = 1)
ax2 = plt.subplot2grid((1,3), (0,1), rowspan=1, colspan = 1, sharey = ax1)
ax3 = ax2.twiny() #Twins the y-axis for the density track with the neutron track
ax4 = plt.subplot2grid((1,3), (0,2), rowspan=1, colspan = 1, sharey = ax1)
ax10 = ax1.twiny()
ax10.xaxis.set_visible(False)
ax11 = ax2.twiny()
ax11.xaxis.set_visible(False)
ax13 = ax4.twiny()
ax13.xaxis.set_visible(False)
# Gamma Ray track
ax1.plot(well["GR"], well['DEPTH_MD'], color = "green", linewidth = 0.5)
ax1.set_xlabel("Gamma")
ax1.xaxis.label.set_color("green")
ax1.set_xlim(0, 150)
ax1.set_ylabel("Depth (m)")
ax1.tick_params(axis='x', colors="green")
ax1.spines["top"].set_edgecolor("green")
ax1.title.set_color('green')
ax1.set_xticks([0, 50, 100, 150, 200])
# Caliper track
ax2.plot(well["CALIPER"], well['DEPTH_MD'], color = "red", linewidth = 0.5)
ax2.set_xlabel("Caliper")
ax2.set_xlim(10, 35)
ax2.xaxis.label.set_color("red")
ax2.tick_params(axis='x', colors="red")
ax2.spines["top"].set_edgecolor("red")
ax2.set_xticks([5, 15, 25, 35])
# Lithology track
ax4.plot(well["Unit"], well['DEPTH_MD'], color = "black", linewidth = 0.5)
ax4.set_xlabel("Lithology")
ax4.set_xlim(0, 1)
ax4.xaxis.label.set_color("black")
ax4.tick_params(axis='x', colors="black")
ax4.spines["top"].set_edgecolor("black")
for key in lithology_numbers.keys():
color = lithology_numbers[key]['color']
hatch = lithology_numbers[key]['hatch']
ax4.fill_betweenx(well['DEPTH_MD'], 0, well['Unit'], where=(well['Unit']==key),
facecolor=color, hatch=hatch)
ax4.set_xticks([0, 1])
for ax in [ax1, ax2, ax4]:
ax.set_ylim(bottom_depth, top_depth)
ax.grid(which='major', color='lightgrey', linestyle='-')
ax.xaxis.set_ticks_position("top")
ax.xaxis.set_label_position("top")
ax.spines["top"].set_position(("axes", 1.02))
for ax in [ax2, ax3, ax4]:
plt.setp(ax.get_yticklabels(), visible = False)
plt.tight_layout()
fig.subplots_adjust(wspace = 0.15)
for key in lithology_numbers.keys():
color = lithology_numbers[key]['color']
hatch = lithology_numbers[key]['hatch']
ax4.fill_betweenx(well['DEPTH_MD'], 0, well['Unit'],
where=(well['Unit']==key),
facecolor=color, hatch=hatch)
makeplot(data, 250, 350)
Kodları çalıştırdığımda ise şu hatayı alıyorum;
TypeError Traceback (most recent call last)
in
74 facecolor=color, hatch=hatch)
75
—> 76 makeplot(data, 250, 350)
in makeplot(well, top_depth, bottom_depth)
46 color = lithology_numbers[key][‘color’]
47 hatch = lithology_numbers[key][‘hatch’]
—> 48 ax4.fill_betweenx(well[‘DEPTH_MD’], 0, well[‘Unit’], where=(well[‘Unit’]==key),
49 facecolor=color, hatch=hatch)
50
~\Anaconda3\lib\site-packages\matplotlib_init_.py in inner(ax, data, *args, **kwargs)
1436 def inner(ax, *args, data=None, **kwargs):
1437 if data is None:
→ 1438 return func(ax, *map(sanitize_sequence, args), **kwargs)
1439
1440 bound = new_sig.bind(ax, *args, **kwargs)
~\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in fill_betweenx(self, y, x1, x2, where, step, interpolate, **kwargs)
5313 def fill_betweenx(self, y, x1, x2=0, where=None,
5314 step=None, interpolate=False, **kwargs):
→ 5315 return self._fill_between_x_or_y(
5316 “y”, y, x1, x2,
5317 where=where, interpolate=interpolate, step=step, **kwargs)
~\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in fill_between_x_or_y(self, ind_dir, ind, dep1, dep2, where, interpolate, step, **kwargs)
5204 dep1 = ma.masked_invalid(
5205 getattr(self, f"convert{dep_dir}units")(dep1))
→ 5206 dep2 = ma.masked_invalid(
5207 getattr(self, f"convert_{dep_dir}units")(dep2))
5208
~\Anaconda3\lib\site-packages\numpy\ma\core.py in masked_invalid(a, copy)
2369 cls = type(a)
2370 else:
→ 2371 condition = ~(np.isfinite(a))
2372 cls = MaskedArray
2373 result = a.view(cls)
TypeError: ufunc ‘isfinite’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’
Yardımcı olabilecek var mı? teşekkürler.