Plotting API - Matrix#

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

Import dependencies :

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

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 matrix view of the investigation use the MatrixView() function with the investigation(inv) as the input parameter. To plot the matrix, use the .plot() function which takes as input parameters the specific view, in this case the matrix view. You can also provide the width (defaults to 900) and the height (defaults to 600) of the figure.

[3]:
matrix_view = MatrixView(inv)
investigator.plot(matrix_view)
[3]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_7_0.png

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

[4]:
matrix_view = MatrixView(inv)

matrix_view.show_legend(True)

investigator.plot(matrix_view)
[4]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_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]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)

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

investigator.plot(matrix_view)
[5]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_11_0.png

By default, the matrix 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 :

[6]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)

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

investigator.plot(matrix_view)
[6]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_13_0.png

By default, the matrix view will plot all the columns in the dataframe. You can select the data you want to plot using the .set_dimensions function:

[7]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)
matrix_view.set_datasets_visible(['Wells/B8'])

matrix_view.set_dimensions(['Perm','Porosity'])

investigator.plot(matrix_view)
[7]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_15_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:

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

matrix_view.set_color_by('Perm')
matrix_view.show_colorscale(True)

investigator.plot(matrix_view)
[8]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_17_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’). Note that for this view the colorscale can only be placed to the right or left although the input parameters refer to top and bottom as well.

[9]:
matrix_view = MatrixView(inv)
matrix_view.set_datasets_visible(['Wells/B8'])
matrix_view.set_color_by('Perm')
matrix_view.show_colorscale(True)

matrix_view.show_colorscale(True)
matrix_view.set_colorscale_location(True, 'bottom-left')

investigator.plot(matrix_view)
[9]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_19_0.png

Similarly, you can also use the color template of discrete properties such as the facies log.

[10]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)
matrix_view.set_datasets_visible(['Wells/B8'])

matrix_view.set_color_by('Facies')

investigator.plot(matrix_view)
[10]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_21_0.png

Using the .set_split_by() you can create a matrix plot for each facies type:

[11]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)
#matrix_view.set_datasets_visible(['Wells/B8'])

matrix_view.set_color_by('Facies')
matrix_view.set_split_by('Facies')

investigator.plot(matrix_view)
[11]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_23_0.png

You can also display a histogram showing the distribution of each property using the .show_histogram() function:

[12]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)
matrix_view.set_datasets_visible(['Wells/B8'])

matrix_view.set_color_by('Facies')
matrix_view.show_histograms(True)

investigator.plot(matrix_view)
[12]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_25_0.png

Furthermore, you can change the count axis values of the histograms with the set_count_axis() function which takes as an input one of the following strings: ‘count’, ‘percentage’, ‘relative percentage’, ‘proportional’:

[13]:
matrix_view = MatrixView(inv)
matrix_view.show_legend(True)
matrix_view.set_datasets_visible(['Wells/B8'])

matrix_view.set_color_by('Facies')
matrix_view.show_histograms(True)

matrix_view.set_count_axis("percentage")

investigator.plot(matrix_view)
[13]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_27_0.png

The .set_draw_statistics() function will overlay the statistics of the plot :

[14]:
matrix_view = MatrixView(inv)
matrix_view.set_datasets_visible(['Wells/B8'])
matrix_view.set_color_by('Perm')
matrix_view.show_colorscale(True)

matrix_view.set_colorscale_location(True, 'bottom-right')

matrix_view.set_draw_statistics(True)
matrix_view.show_legend(True)
matrix_view.set_legend_location(True,'bottom-left')

investigator.plot(matrix_view)
[14]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_29_0.png

Alternatively, you can also add other statistics data such as the median, mean, minmax and percentile using the show_statistics_median(), show_statistics_mean(), show_statistics_minmax(), show_statistics_percentile() functions:

[15]:
matrix_view = MatrixView(inv)
matrix_view.set_datasets_visible(['Wells/B8'])
matrix_view.set_color_by('Perm')
matrix_view.show_colorscale(True)
matrix_view.set_colorscale_location(True, 'bottom-right')


matrix_view.show_legend(True)
matrix_view.set_draw_statistics(True)
matrix_view.show_statistics_median(True)
matrix_view.show_statistics_mean(True)
matrix_view.show_statistics_minmax(True)
matrix_view.show_statistics_percentile(True)

investigator.plot(matrix_view)
[15]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_31_0.png

You can add a 4th dimension to your plot by changing the appearance of the plotted points using the .set_appearance_by() function:

[16]:
matrix_view = MatrixView(inv)
matrix_view.set_datasets_visible(['Wells/B8'])
matrix_view.set_color_by('Perm')
matrix_view.show_colorscale(True)

matrix_view.set_appearance_by("Perm")
matrix_view.show_legend(True)
matrix_view.set_legend_location(True,'bottom-right')

investigator.plot(matrix_view)
[16]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_33_0.png

You can set contours using the set_contour_by() function:

[17]:
matrix_view = MatrixView(inv)
matrix_view.set_datasets_visible(['Wells/B8'])
matrix_view.set_color_by('Perm')
matrix_view.show_colorscale(True)

matrix_view.set_contour_by('Data sets')

investigator.plot(matrix_view)

[17]:
../../../../_images/products_Investigator_Workbooks_UserGuide_Plotting-Matrix_35_0.png

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