Have you already seen a graphic on books, PDF article, sites or papers that you would like to have the data source, but there is not a reference for that data???
​
Now with artificial intelligence assistance (aid by AI) we can reverse engineer graphics with LLMs to get the original data and recreate the graphic with Wolfram Language and LLMs...
We can use LLMs to analyze an image with a graphic and reproduce it as code, here I am using Wolfram Notebook Assistant (Wolfram LLM Kit):
Can you please write a code in Wolfram Language in order to replicate this graphic in the image:​
To replicate the graphic shown in the image using Wolfram Language, you can create a plot with three functions: linear, quadratic, and cubic. Use different styles for each function and add labels and a legend to the plot. Here's the code: ​
Plot[​​{x,x^2,x^3},{x,0,2},​​PlotStyle->{Blue,Orange,Green},​​PlotLegends->Placed[{"linear","quadratic","cubic"},{0.8,0.5}],​​AxesLabel->{"x label","y label"},​​PlotLabel->"Simple Plot",​​ImageSize->Large​​]
Insert and evaluate
Insert
Copy
​This code uses
Plot
to draw the functions, specifies
PlotStyle
to set different colors, and applies
PlotLegends
to add a legend. The
AxesLabel
and
PlotLabel
options are used to set the labels for the axes and the title of the plot, respectively. Adjustments are made to the position of the legend to match the original style.
In[]:=
Plot[​​{x,x^2,x^3},{x,0,2},​​PlotStyle->{Blue,Orange,Green},​​PlotLegends->Placed[{"linear","quadratic","cubic"},{0.8,0.5}],​​AxesLabel->{"x label","y label"},​​PlotLabel->"Simple Plot",​​ImageSize->Large​​]
Out[]=
Now from a book image photo with smartphone:
This is a graphic from a book, photo taken with a cell phone. Can you please create a list with the point in red for x (Years of Education) and y (Income) axis, and reproduce the graphic in Wolfram Language code. Both graphics has the same data points:​​
To create a list of the red points and generate a similar plot in Wolfram Language, we need to approximate the data points from the image. Let's create a list of points and then plot them.​Here is an approximation of the data points for the plot: ​
data={{10,22},{11,25},{12,30},{13,35},{14,40},{15,45},{16,50},{17,60},{18,65},{19,70},{20,75},{21,80}};
Insert and evaluate
Insert
Copy
​You can use this data to plot the points: ​
ListPlot[data,​​PlotStyle->Red,​​AxesLabel->{"Years of Education","Income"},​​PlotRange->{{9,22},{15,85}},​​AspectRatio->1,​​ImageSize->Large]
Insert and evaluate
Insert
Copy
​This code uses
ListPlot
to plot the data points, setting the style to red to match the image. It also labels the axes and adjusts the plot range to fit the data as closely as possible. You can further refine the data points based on more precise measurements or additional information.
In[]:=
data={{10,22},{11,25},{12,30},{13,35},{14,40},{15,45},{16,50},{17,60},{18,65},{19,70},{20,75},{21,80}};
In[]:=
ListPlot[data,​​PlotStyle->Red,​​AxesLabel->{"Years of Education","Income"},​​PlotRange->{{9,22},{15,85}},​​AspectRatio->1,​​ImageSize->Large]
Out[]=
The image bellow has two graphics, can you please create the data points in a lists for those data graphics, extracting data from both images, and reproduce the graphics win Wolfram Language code:​​
To replicate the two subplots shown in the image using Wolfram Language, we need to create data points that approximate the plots. Here's how you can construct and visualize these data sets: ​
Data Points
​For the damped oscillation plot (upper plot), let's create some approximate data: ​
dampedData={{0,1},{0.5,0.1},{1,-0.6},{1.5,0.2},{2,0.5},{2.5,-0.1},{3,0.1},{4,0.05},{5,0}};
Insert and evaluate
Insert
Copy
​For the undamped oscillation plot (lower plot), let's create a simple sine wave: ​
undampedData=Table[{t,Sin[2Pit]},{t,0,2,0.1}];
Insert and evaluate
Insert
Copy
​​
Plotting the Data
​Now, let's plot these data sets in a similar layout: ​
GraphicsGrid[{​​{ListPlot[dampedData,Joined->True,PlotStyle->Blue,​​PlotMarkers->Automatic,​​PlotLabel->"Damped oscillation",​​AxesLabel->{"","Damped oscillation"},​​PlotRange->{{0,5},{-1,1.2}},AspectRatio->0.5]},​​{ListPlot[undampedData,Joined->True,PlotStyle->Blue,​​PlotMarkers->Automatic,​​PlotLabel->"Undamped",​​AxesLabel->{"time (s)","Undamped"},​​PlotRange->{{0,2},{-1,1}},AspectRatio->0.5]}​​},​​Spacings->{0,0.5},​​PlotLabel->Style["A tale of 2 subplots",Bold]​​]
Insert and evaluate
Insert
Copy
​This code uses
GraphicsGrid
to organize the two plots vertically, resembling the original layout. The plots are styled with
PlotMarkers
and
PlotStyle
to match the appearance of the image as closely as possible. Adjust the data points and plot settings further for greater accuracy based on the image.
In[]:=
dampedData={{0,1},{0.5,0.1},{1,-0.6},{1.5,0.2},{2,0.5},{2.5,-0.1},{3,0.1},{4,0.05},{5,0}};
In[]:=
undampedData=Table[{t,Sin[2Pit]},{t,0,2,0.1}];
In[]:=
GraphicsGrid[{​​{ListPlot[dampedData,Joined->True,PlotStyle->Blue,​​PlotMarkers->Automatic,​​PlotLabel->"Damped oscillation",​​AxesLabel->{"","Damped oscillation"},​​PlotRange->{{0,5},{-1,1.2}},AspectRatio->0.5]},​​{ListPlot[undampedData,Joined->True,PlotStyle->Blue,​​PlotMarkers->Automatic,​​PlotLabel->"Undamped",​​AxesLabel->{"time (s)","Undamped"},​​PlotRange->{{0,2},{-1,1}},AspectRatio->0.5]}​​},​​Spacings->{0,0.5},​​PlotLabel->Style["A tale of 2 subplots",Bold]​​]
Out[]=
The image bellow is build on top of a matrix X and Y, the points are represented in a color gradient square. We would like to extract the data from the image.Can you create the 6x6 matrix to represent this graphic with integer number and recreate the graphic with Wolfram Language code? ​​
To create a 6x6 matrix that approximates the color gradient square represented in the image, we'll assign integer values to each cell based on the color intensity. After constructing the matrix, we'll use Wolfram Language to plot it. ​
Approximate Matrix
​Here's an approximation of the 6x6 matrix based on the image: ​
matrix={​​{3,4,5,2,4,5},​​{2,1,3,4,5,3},​​{3,5,2,1,3,4},​​{4,2,3,4,5,1},​​{5,3,1,2,4,3},​​{4,5,3,2,1,5}​​};
Insert and evaluate
Insert
Copy
​​
Plotting the Matrix
​Now we can replicate the plot using
MatrixPlot
: ​
MatrixPlot[matrix,​​ColorFunction->"Rainbow",​​FrameTicks->{Range[0,5],Range[0,5]},​​FrameLabel->{"X","Y"},​​PlotLabel->"Matplotlib imshow() Example",​​ImageSize->Large​​]
Insert and evaluate
Insert
Copy
​This code uses
MatrixPlot
to visualize the matrix, with a
ColorFunction
set to
"Rainbow"
to mimic the gradient effect in the image. Adjust the matrix values if you need more precision based on the actual color intensities in the image.
In[]:=
matrix={​​{3,4,5,2,4,5},​​{2,1,3,4,5,3},​​{3,5,2,1,3,4},​​{4,2,3,4,5,1},​​{5,3,1,2,4,3},​​{4,5,3,2,1,5}​​};
In[]:=
MatrixPlot[matrix,​​ColorFunction->"Rainbow",​​FrameTicks->{Range[0,5],Range[0,5]},​​FrameLabel->{"X","Y"},​​PlotLabel->"Matplotlib imshow() Example",​​ImageSize->Large​​]
Out[]=
I would like to do a reverse engineering in the graphic below. Create a list for those blue dots average values, float for x and integer for y.Create a visualization for the dots list with a linear regression.​
To reverse engineer the graphic and create a list of the blue dots' average values, we'll approximate the data points from the image. Then, we'll perform a linear regression and visualize the result. ​
Data Points
​Let's approximate the data points from the image: ​
dataPoints={{1,4},{2,6},{3,7},{4,9},{5,10},{6,11},{7,13},{8,14},{9,15},{10,16}};
Insert and evaluate
Insert
Copy
​​
Visualization with Linear Regression
​We can use this data to plot the points and perform a linear regression: ​
fit=LinearModelFit[dataPoints,x,x];​​​​Show​​ ListPlot[dataPoints,PlotStyle->{Blue,PointSize[Medium]}],​​ Plot[fit[x],{x,0,10},PlotStyle->{Orange}],​​ PlotRange->{{0,10},{3,17}},​​ AxesLabel->{"x","y"},​​ PlotLabel->"Linear Regression",​​ ImageSize->Medium​​ 
Insert and evaluate
Insert
Copy
​This code uses
ListPlot
to display the data points and
LinearModelFit
to calculate and plot the linear regression line. The result is overlaid on the data points to visualize the trend. Adjust the data points for more accuracy as needed based on the image.
In[]:=
dataPoints={{1,4},{2,6},{3,7},{4,9},{5,10},{6,11},{7,13},{8,14},{9,15},{10,16}};
In[]:=
fit=LinearModelFit[dataPoints,x,x];​​​​Show​​ ListPlot[dataPoints,PlotStyle->{Blue,PointSize[Medium]}],​​ Plot[fit[x],{x,0,10},PlotStyle->{Orange}],​​ PlotRange->{{0,10},{3,17}},​​ AxesLabel->{"x","y"},​​ PlotLabel->"Linear Regression",​​ ImageSize->Medium​​ 
Out[]=
LLMs are getting good on reverse engineering graphics to get back to the original data...
You can keep the prompt conversation for refinement at the data extraction from graphics...
There is work needed, but it is a good point for now...

CITE THIS NOTEBOOK

Reverse engineering images of graphics to data and Wolfram code using LLMs​
by Daniel Carvalho​
Wolfram Community, STAFF PICKS, March 13, 2025
​https://community.wolfram.com/groups/-/m/t/3416125