Plotting API - Crossplot#
This notebook provides the user a guide to how a crossplot can be shown using a Blueback Investigation. Check out the API documentation to view all the functions available for the crossplot view:
Import dependencies :
[1]:
import cegalprizm.investigator as investigator
from cegalprizm.investigator import InvestigatorConnection
from cegalprizm.investigator.views import CrossplotView
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 crossplot view of the investigation use the CrossplotView() function with the investigation(inv) as the input parameter. To plot the crossplot, use the .plot() function which takes as input parameters the specific view, in this case the crossplot view. You can also provide the width (defaults to 900) and the height (defaults to 600) of the figure.
[3]:
cross_view = CrossplotView(inv)
investigator.plot(cross_view)
[3]:

You can add a legend to see from which well each point comes using the show_legend() function:
[4]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
investigator.plot(cross_view)
[4]:

You can set the priority of the dataset (the order in which the points are plotted) using the the .set_dataset_priority function:
[5]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_dataset_priority(['Wells/B4','Wells/B2','Wells/B9','Wells/B8'])
investigator.plot(cross_view)
[5]:

You can create a plot for each of the wells using the set_split_by() function:
[6]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_split_by('Data sets')
investigator.plot(cross_view)
[6]:

By default, the crossplot view will display all the points in your dataframe 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]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
investigator.plot(cross_view)
[7]:

By default, the crossplot view will plot the first two columns in the dataframe, in this case the ‘Gamma Ray’ and ‘Porosity’ logs. If you want to specify which columns to plot use the set_x_dimension() and set_y_dimension() functions:
[8]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
investigator.plot(cross_view)
[8]:

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]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
investigator.plot(cross_view)
[9]:

You can also use the color template of discrete properties :
[10]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Facies')
cross_view.show_colorscale(True)
investigator.plot(cross_view)
[10]:

Similarly, you can create Por-Perm plots for each facies type using the set_split_by() function:
[11]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Facies')
cross_view.set_split_by('Facies')
cross_view.show_colorscale(True)
investigator.plot(cross_view)
[11]:

[12]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Facies')
cross_view.show_colorscale(True)
investigator.plot(cross_view)
[12]:

The .set_draw_statistics function will overlay the statistics of the plot:
[13]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.set_draw_statistics(True)
investigator.plot(cross_view)
[13]:

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:
[14]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.set_draw_statistics(True)
cross_view.show_statistics_median(True)
cross_view.show_statistics_mean(True)
cross_view.show_statistics_minmax(True)
cross_view.show_statistics_percentile(True)
investigator.plot(cross_view)
[14]:

You can also display the histograms of the plotted values around the crossplot figure using the show_x_histogram() and show_y_histogram() functions:
[15]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.show_x_histogram(show=True)
cross_view.show_y_histogram(show=True)
investigator.plot(cross_view)
[15]:

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’:
[16]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.show_x_histogram(show=True)
cross_view.show_y_histogram(show=True)
cross_view.set_count_axis('percentage')
investigator.plot(cross_view)
[16]:

To reverse the position of the histograms, use the .reverse_histograms() function:
[17]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.show_x_histogram(show=True)
cross_view.show_y_histogram(show=True)
cross_view.set_count_axis('percentage')
cross_view.reverse_histograms(True)
investigator.plot(cross_view)
[17]:

To change the appearance of the plotted points you can use the .set_appearance_by() function. In order to prevent the overlapping of the colorscale and legend you can move the color scale inside the crossplot view using the .set_colorscale_location() function. The first input parameter of this function 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’):
[18]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.set_appearance_by("Porosity")
cross_view.set_colorscale_location(True,'bottom-right')
investigator.plot(cross_view)
[18]:

You can check for point clusters by setting contours using the set_contour_by() function:
[19]:
cross_view = CrossplotView(inv)
cross_view.show_legend(True)
cross_view.set_datasets_visible(['Wells/B2'])
cross_view.set_x_dimension("Perm")
cross_view.set_y_dimension("Porosity")
cross_view.set_color_by('Porosity')
cross_view.show_colorscale(True)
cross_view.set_contour_by('Data sets')
investigator.plot(cross_view)
[19]:

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