如何在R中绘制岩性柱?

问题描述 投票:0回答:1

我想在 R 中绘制测井记录的相图。我的数据有一个名为

LFC
的列,其中包含从 0 到 4 的整数,其中:

  • LFC=0:未定义
  • LFC=1:卤水砂
  • LFC=2:油砂
  • LFC=3:含气砂
  • LFC=4:页岩

我已经在Python中完成了,但我需要在R中完成,我的代码和结果是:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.colors as colors
logs = pd.read_csv('data/proyectoFinal/well_log.csv')
ccc = ['#B3B3B3','blue','green','red','#996633',]
cmap_facies = colors.ListedColormap(ccc[0:len(ccc)], 'indexed')
cluster=np.repeat(np.expand_dims(logs['LFC'].values,1), 100, 1)
im=plt.imshow(cluster, interpolation='none', aspect='auto',cmap=cmap_facies,vmin=0,vmax=4)
cbar=plt.colorbar(im)
cbar.set_label((12*' ').join(['undef', 'brine', 'oil', 'gas', 'shale']))
cbar.set_ticks(range(0,1)); cbar.set_ticklabels('')

lithofacies column in Python

同时在 R 中:

logs <- read.csv('data/proyectoFinal/well_log.csv')
ccc <- c('#B3B3B3', 'blue', 'green', 'red', '#996633')
cluster <- matrix(rep(logs$LFC, each = 100), nrow = 100)
colores <- as.vector(ccc)
image(t(cluster), col = colores, axes = FALSE, xlab = "", ylab = "")
axis(2, at = seq(1, nrow(cluster), length.out = length(ccc)), labels = c('undef', 'brine', 'oil', 'gas', 'shale'))
axis(1, at = seq(1, ncol(cluster), length.out = 10), labels = FALSE)
box()

lithofacies column in R

r plot
1个回答
0
投票

设置 z 限制:

image(t(cluster), col = colores, axes = FALSE, xlab = "", ylab = "", zlim=c(0, 4))

来自文档:

zlim

应绘制颜色的最小和最大
z
值,默认为
z
有限值的范围。每种给定的颜色都将用于对该范围的等距间隔进行着色。间隔的中点覆盖了范围,因此将绘制刚好超出范围的值。

这意味着默认情况下,

image()
会尽可能均匀地将您的
z
值分布在
col
的整个范围内。由于您的数据没有任何 0,因此它将 1 分配给 0、2 分配给 1、4 分配给 4。设置
zlim
会覆盖它。

此外,如果您希望垂直而不是水平绘制,只需删除转置(

t()
)即可。

© www.soinside.com 2019 - 2024. All rights reserved.