-
Notifications
You must be signed in to change notification settings - Fork 20
/
plotting.py
81 lines (63 loc) · 3.32 KB
/
plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import streamlit as st
import pandas as pd
# Plotly imports
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly.figure_factory as ff
import plotly.express as px
def plot(las_file, well_data):
st.title('LAS File Visualisation')
if not las_file:
st.warning('No file has been uploaded')
else:
columns = list(well_data.columns)
st.write('Expand one of the following to visualise your well data.')
st.write("""Each plot can be interacted with. To change the scales of a plot/track, click on the left hand or right hand side of the scale and change the value as required.""")
with st.beta_expander('Log Plot'):
curves = st.multiselect('Select Curves To Plot', columns)
if len(curves) <= 1:
st.warning('Please select at least 2 curves.')
else:
curve_index = 1
fig = make_subplots(rows=1, cols= len(curves), subplot_titles=curves, shared_yaxes=True)
for curve in curves:
fig.add_trace(go.Scatter(x=well_data[curve], y=well_data['DEPTH']), row=1, col=curve_index)
curve_index+=1
fig.update_layout(height=1000, showlegend=False, yaxis={'title':'DEPTH','autorange':'reversed'})
fig.layout.template='seaborn'
st.plotly_chart(fig, use_container_width=True)
with st.beta_expander('Histograms'):
col1_h, col2_h = st.beta_columns(2)
col1_h.header('Options')
hist_curve = col1_h.selectbox('Select a Curve', columns)
log_option = col1_h.radio('Select Linear or Logarithmic Scale', ('Linear', 'Logarithmic'))
hist_col = col1_h.color_picker('Select Histogram Colour')
st.write('Color is'+hist_col)
if log_option == 'Linear':
log_bool = False
elif log_option == 'Logarithmic':
log_bool = True
histogram = px.histogram(well_data, x=hist_curve, log_x=log_bool)
histogram.update_traces(marker_color=hist_col)
histogram.layout.template='seaborn'
col2_h.plotly_chart(histogram, use_container_width=True)
with st.beta_expander('Crossplot'):
col1, col2 = st.beta_columns(2)
col1.write('Options')
xplot_x = col1.selectbox('X-Axis', columns)
xplot_y = col1.selectbox('Y-Axis', columns)
xplot_col = col1.selectbox('Colour By', columns)
xplot_x_log = col1.radio('X Axis - Linear or Logarithmic', ('Linear', 'Logarithmic'))
xplot_y_log = col1.radio('Y Axis - Linear or Logarithmic', ('Linear', 'Logarithmic'))
if xplot_x_log == 'Linear':
xplot_x_bool = False
elif xplot_x_log == 'Logarithmic':
xplot_x_bool = True
if xplot_y_log == 'Linear':
xplot_y_bool = False
elif xplot_y_log == 'Logarithmic':
xplot_y_bool = True
col2.write('Crossplot')
xplot = px.scatter(well_data, x=xplot_x, y=xplot_y, color=xplot_col, log_x=xplot_x_bool, log_y=xplot_y_bool)
xplot.layout.template='seaborn'
col2.plotly_chart(xplot, use_container_width=True)