Plotting API - Histogram#

This notebook provides the user a guide to how a histogram can be shown using a Blueback Investigation. Check out the API documentation to view all the functions available for the histogram view:

Import dependencies :

[1]:
import cegalprizm.investigator as investigator
from cegalprizm.investigator import InvestigatorConnection
from cegalprizm.investigator.views import HistogramView

Connect to investigator and assign the investigation to a variable :

[2]:
invconnection = InvestigatorConnection(use_licensed_features=True)
inv = invconnection.investigation_from_file("Wells.invpy")

To create a histogram view of the investigation use the HistogramView() function with the investigation(inv) as the input parameter. To plot the histogram, use the .plot() function which takes as input parameters the specific view, in this case the histogram view. You can also provide the width (defaults to 900) and the height (defaults to 600) of the figure.

[3]:
hist_view = HistogramView(inv)
investigator.plot(hist_view)
[3]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_7_0.png

You can add a legend to see from which well each point comes from using the show_legend() function:

[4]:
hist_view = HistogramView(inv)

hist_view.show_legend(True)

investigator.plot(hist_view)
[4]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_9_0.png

You can set the priority of the dataset (the order in which the points are plotted) using the .set_dataset_priority() function:

[5]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)

hist_view.set_dataset_priority(['Wells/B8','Wells/B2','Wells/B9','Wells/B4'])

investigator.plot(hist_view)
[5]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_11_0.png

You can create a plot for each of the wells using the set_split_by() function:

[6]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)

hist_view.set_split_by('Data sets')

investigator.plot(hist_view)
[6]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_13_0.png

By default, the histogram view will display all the points in your investigation coming from all the wells. You can select which well you want to visualize using the .set_datasets_visible() function which takes as an input a list of strings containing the well names. You can have one or multiple wells selected :

[7]:
hist_view = HistogramView(inv)

hist_view.show_legend(True)

hist_view.set_datasets_visible(['Wells/B8'])

investigator.plot(hist_view)
[7]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_15_0.png

By default, the histogram view will plot the first column in the dataframe, in this case the Permeability log. If you want to specify which column to plot use the set_dimension() function:

[8]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])

hist_view.set_dimension('Gamma')

investigator.plot(hist_view)
[8]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_17_0.png

You can select the color template using the .set_color_by function. To add the colorscale use the .show_colorscale function, set to true:

[9]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')

hist_view.set_color_by("Gamma")

hist_view.show_colorscale(True)

investigator.plot(hist_view)
[9]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_19_0.png

To change the colorscale location use the set_colorscale_location() . First input parameter is a boolean value that specifies if the color scale should be inside the view port (True) or not (False). The second input parameter is a string value that specifies the location (‘top-left’, ‘top-right’, ‘bottom-left’, ‘bottom-right’):

[10]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Gamma")
hist_view.show_colorscale(True)

hist_view.set_colorscale_location(True, 'top-right')


investigator.plot(hist_view)
[10]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_21_0.png

Similarly, you can also use the color template of discrete properties such as the facies log. Using the .set_split_by() you can create a histogram plot for each facies type. Furthermore, you can change the count axis values with the set_count_axis() function which takes as an input one of the following strings: ‘count’, ‘percentage’, ‘relative percentage’, ‘proportional’:

[11]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Porosity')


hist_view.set_color_by("Facies")
hist_view.set_split_by('Facies')
hist_view.set_count_axis('percentage')


investigator.plot(hist_view)
[11]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_23_0.png

To visualize the statistics(min/max values, Median and P10/P90 values) of the plotted values use the .set_draw_statistics() function:

[12]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Gamma")
hist_view.show_colorscale(True)
hist_view.set_colorscale_location(False, 'bottom-right')

hist_view.set_draw_statistics(True)

investigator.plot(hist_view)
[12]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_25_0.png

Similarly, you can change the location of the legend using the set_legend_location():

[13]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Gamma")
hist_view.show_colorscale(True)
hist_view.set_colorscale_location(False, 'bottom-right')


hist_view.set_draw_statistics(True)
hist_view.set_legend_location(True,'bottom-right')

investigator.plot(hist_view)
[13]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_27_0.png

To swap the axes, use the .swap_axes() function:

[14]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Gamma")
hist_view.show_colorscale(True)
hist_view.set_colorscale_location(False, 'bottom-right')

hist_view.set_draw_statistics(True)


hist_view.swap_axes()

investigator.plot(hist_view)
[14]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_29_0.png

You can create a barchart for each discrete property (in this case dataset,facies or zones) using the set_barchart():

[15]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Porosity')
hist_view.set_color_by("Facies")
hist_view.set_colorscale_location(True, 'bottom-right')
hist_view.set_draw_statistics(True)


hist_view.show_filled_histogram(True)
hist_view.set_barchart('Facies')


investigator.plot(hist_view)
[15]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_31_0.png

If you want to display empty histograms bars (not filled by any color) remove the .set_color_by() function and add the .show_filled_histogram() function set to false:

[16]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_colorscale_location(False, 'bottom-right')
hist_view.set_draw_statistics(True)


hist_view.show_filled_histogram(False)


investigator.plot(hist_view)
[16]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_33_0.png
[17]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_colorscale_location(False, 'bottom-right')
hist_view.set_draw_statistics(True)


hist_view.show_filled_histogram(True)


investigator.plot(hist_view)
[17]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_34_0.png

You can also change the appearance of the histogram from bars to lines using the show_histogram_as() function:

[18]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Facies")
hist_view.set_colorscale_location(False, 'bottom-right')
hist_view.set_draw_statistics(True)


hist_view.show_filled_histogram(True)
hist_view.show_histogram_as('lines')


investigator.plot(hist_view)
[18]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_36_0.png

The show_multi_histograms() function creates a histogram view for all the columns in the dataframe:

[19]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Gamma")
hist_view.show_colorscale(True)
hist_view.show_filled_histogram(True)
hist_view.set_colorscale_location(False, 'bottom-right')


hist_view.show_multi_histograms(True)

investigator.plot(hist_view)
[19]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_38_0.png

Alternatively, you can plot multiple histogram views using the set_dimension and selecting the columns you want to plot:

[20]:
hist_view = HistogramView(inv)
hist_view.show_legend(True)
hist_view.set_datasets_visible(['Wells/B8'])
hist_view.set_dimension('Gamma')
hist_view.set_color_by("Gamma")
hist_view.show_colorscale(True)
hist_view.set_colorscale_location(False, 'bottom-right')

hist_view.set_dimensions(['Gamma','Perm'])

investigator.plot(hist_view)
[20]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Histogram_40_0.png

The .copy() function returns a copy of the histogram view. This can be used to ensure that a common view setup can be the applied to multiple related views.