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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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]:

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.