Digitizing plots with Mathematica (i.e. extracting data points from
- To: mathgroup at smc.vnet.net
- Subject: [mg107662] Digitizing plots with Mathematica (i.e. extracting data points from
- From: Will DeBeest <wildebeestz at gmail.com>
- Date: Mon, 22 Feb 2010 03:09:06 -0500 (EST)
I've just written a blog post showing how to make a plot digitizer
using Mathematica. It may be of interest to other Mathematica users
particularly anyone who wants to extract some data out of plots.
barChartDigitizer[g_Image] :=
DynamicModule[{min = {0, 0}, max = {0, 0}, xmin = -1., xmax = 1.,
pt = {0, 0}, data = {}, img = ImageDimensions[g], output},
Deploy@Column[{
Row[{
Column[{Button["Y Axis Min", min = pt],
InputField[Dynamic[xmin], Number, ImageSize -> 70]}],
Column[{Button["Y Axis Max", max = pt],
InputField[Dynamic[xmax], Number, ImageSize -> 70]}],
Column[{Button["Add point", AppendTo[data, pt]],
Button["Remove Last", data = Quiet@Check[Most@data, {}]]}],
Column[{Button["Start Over", data = {}],
Button["Print Output",
Print@Column[{BarChart[
output =
Rescale[#, {Last@min, Last@max}, {xmin, xmax}] & /@
data[[All, 2]],
PlotRange -> {Automatic, {xmin, xmax}},
ImageSize -> 400], output}],
Enabled -> Dynamic[data =!= {}]]}]
}],
Row[{
Graphics[{Inset[
Image[g, ImageSize -> img]], {Tooltip[Locator[Dynamic[pt]],
Dynamic[pt]]}},
ImageSize -> img, PlotRange -> 1,
AspectRatio -> img[[2]]/img[[1]]]}]
}]
]
A full description will a worked example can be found here:
http://www.wildebeests.net/2010/02/21/digitizing-plots-with-mathematica/