You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I use Bokeh, Pane and Altair for all of my interactive python. I would like to make a bubble map for each well in an oil field where the size of the bubble relates to total oil production and bubble is actually a pie chart showing total oil and water production at each well.
In the example below the red piece of the pie chart is oil production and the blue piece is water production.
This is the bokeh code I use, but would like to use Altair to select certain wells and observe the data for the selected wells. This is my code in Bokeh:
`from bokeh.plotting import figure, show, output_notebook
from bokeh.models import ColumnDataSource
import numpy as np
Enable Bokeh output in the notebook
output_notebook()
Extract relevant columns and group by well, summing the production
min_radius = 0.02
max_radius = 0.04 # Maximum radius for the largest pie
grouped_data['radius'] = grouped_data['BOPM'] / grouped_data['BOPM'].max() * max_radius
Convert to a ColumnDataSource
source = ColumnDataSource(grouped_data)
Create the figure
p = figure(title="Sized Well Production with Pie Charts", width=800, height=1000, x_range=(0, 1), y_range=(0, 1))
What is your suggestion?
Hello, I use Bokeh, Pane and Altair for all of my interactive python. I would like to make a bubble map for each well in an oil field where the size of the bubble relates to total oil production and bubble is actually a pie chart showing total oil and water production at each well.
In the example below the red piece of the pie chart is oil production and the blue piece is water production.
This is the bokeh code I use, but would like to use Altair to select certain wells and observe the data for the selected wells. This is my code in Bokeh:
`from bokeh.plotting import figure, show, output_notebook
from bokeh.models import ColumnDataSource
import numpy as np
Enable Bokeh output in the notebook
output_notebook()
Extract relevant columns and group by well, summing the production
grouped_data = (
df[['Well', 'BOPM', 'BWPM', 'X_location', 'Y_location']]
.dropna()
.groupby(['Well', 'X_location', 'Y_location'], as_index=False)
.sum()
)
Calculate total production and proportions
grouped_data['Total'] = grouped_data['BOPM'] + grouped_data['BWPM']
grouped_data['BOPM_Fraction'] = grouped_data['BOPM'] / grouped_data['Total']
grouped_data['BWPM_Fraction'] = grouped_data['BWPM'] / grouped_data['Total']
Precompute angles for the wedges
grouped_data['start_angle_oil'] = 0
grouped_data['end_angle_oil'] = grouped_data['BOPM_Fraction'] * 2 * np.pi
grouped_data['start_angle_water'] = grouped_data['end_angle_oil']
grouped_data['end_angle_water'] = 2 * np.pi
Scale the radius based on BOPM
min_radius = 0.02
max_radius = 0.04 # Maximum radius for the largest pie
grouped_data['radius'] = grouped_data['BOPM'] / grouped_data['BOPM'].max() * max_radius
Convert to a ColumnDataSource
source = ColumnDataSource(grouped_data)
Create the figure
p = figure(title="Sized Well Production with Pie Charts", width=800, height=1000, x_range=(0, 1), y_range=(0, 1))
Add oil wedges
p.wedge(
x='X_location',
y='Y_location',
radius='radius',
start_angle='start_angle_oil',
end_angle='end_angle_oil',
color="red",
legend_label="Oil",
source=source
)
Add water wedges
p.wedge(
x='X_location',
y='Y_location',
radius='radius',
start_angle='start_angle_water',
end_angle='end_angle_water',
color="blue",
legend_label="Water",
source=source
)
Display the chart
show(p)
`
Have you considered any alternative solutions?
The bokeh example shown above, but want to use Altair interactivity. I can also do this in Spotfire, but want to use python only.
The text was updated successfully, but these errors were encountered: