{
"cells": [
{
"cell_type": "markdown",
"id": "1ea7dc9b-172c-4723-833f-4e718c2ebc7e",
"metadata": {},
"source": [
"# Plot trace extraction example\n",
"This notebooks shows an example of how to use the `extract_traces_and_axis` fuction to extract the traces from a plot figures. \n",
"**Note**: This function was developed to extract the traces from the plots processed in the published article, therefore not all plots formats are supported"
]
},
{
"cell_type": "code",
"execution_count": 242,
"id": "b558660c-f7fa-44fc-a2aa-b2cf2643fd8b",
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import cv2 as cv\n",
"import numpy as np\n",
"import pandas as pd\n",
"import plotly.express as px"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c57154fc",
"metadata": {},
"outputs": [],
"source": [
"# Install ramanbiolib with extraction tag\n",
"#!pip install ramanbiolib[extraction]"
]
},
{
"cell_type": "code",
"execution_count": 245,
"id": "6e3befeb-9c48-4882-9b1b-db779b388502",
"metadata": {},
"outputs": [],
"source": [
"from ramanbiolib.db.extraction import extract_traces_and_axis"
]
},
{
"cell_type": "markdown",
"id": "089d7b6f-cdbd-468e-ad04-6f399d4714f2",
"metadata": {},
"source": [
"## Load image\n",
"We display the image"
]
},
{
"cell_type": "code",
"execution_count": 246,
"id": "067483b2-09e2-4278-9ffe-1ce808761e3e",
"metadata": {},
"outputs": [],
"source": [
"plot_img = cv.cvtColor(cv.imread(\"plot-example.png\"), cv.COLOR_BGR2RGB) "
]
},
{
"cell_type": "code",
"execution_count": 247,
"id": "bfe542e4-7fe4-4bd6-a4d0-853d270f517b",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "x: %{x}
y: %{y}
color: [%{z[0]}, %{z[1]}, %{z[2]}]