If your data is defined on a regular x-y grid you could reshape it to a 2D array, as in
gplot(with=>'image',$x->reshape($n,$m), $y->reshape($n,$m), $z->reshape($n,$m)) with $n and $m the number of pixels along x and along y. If the x-y data is irregular but almost on a grid, you could use gplot({trid=>1, view=>'map'},with=>'pm3d',$x->reshape($n,$m), $y->reshape($n,$m), $z->reshape($n,$m)) For example, the attached image was produced with $x=xvals(10,10)+random(10,10); $y=yvals(10,10)+random(10,10); $z=rvals(10,10); gplot({trid=>1, view=>'map'},with=>'pm3d',$x, $y, $z); Regards, Luis On Thu, Apr 18, 2024 at 02:19:29PM -0700, Jovan Trujillo wrote: > If you look at my example code it shows that the Excel data basically has > the coordinates flattened to a list: > > my $x = flat(xvals(10,10)); # This is basically how x-coordinates are > output from my machine. > my $y = flat(yvals(10,10)); # Same format as x-coordinates > my $z = sequence(100)*rand(1); # Some dummy data for this example. > > This is just an example to show the structure of the data coming in. A > sample of the data in the Excel file looks like this: > > X (um) Y (um) R (Ohms/sq) > 174466.6 148753.6 3.205395 > 174438.8 149112.8 2.041845 > 174410.4 149471.7 2.192256 > 174382.7 149830.3 2.345829 > 174354.9 150189.4 2.256398 > 174326.8 150548.4 2.134265 > 174299.2 150907.4 2.360153 > 174271.1 151265.9 2.303999 > 174243.3 151624.9 2.437044 > 174215.4 151983.8 2.454804 > 174187.4 152343 2.407471 > 174159.6 152701.7 2.339043 > 174131.5 153060.5 2.363042 > 174103.9 153419.6 2.399614 > 174075.8 153778.4 2.352736 > 174047.8 154137.4 2.267724 > 174020.1 154496.3 2.219654 > 173992.3 154855.3 2.157816 > > > > I have parsed that data into $x, $y, and $z but $z needs to be mapped into > an N x N matrix for image plotting using the coordinates given in $x and > $y. The machine walks along Y and then steps to the next X coordinate when > it reaches the end of Y. All points in X and Y are expected to be unique. I > need to create the matrix using zeroes(N,N) since I know how many points I > took in X and Y, and then create a sequence that interpolates $x and $y > into matrix index values. Then use matching to know where in the matrix the > $z values belong. If there is something built into PDL to do that let me > know. > > I hope this helps clarify the problem. > > Thanks, > Jovan > > On Thu, Apr 18, 2024 at 1:35 PM David Mertens <dcmertens.p...@gmail.com> > wrote: > > > Hello Jovan, > > > > Did you try this? > > my $z = sequence(10,10)*rand(1); > > > > Seems to me you just need a z-value pdl that has the same dimensions as > > the x and y coordinates. > > > > David > > > > On Thu, Apr 18, 2024, 1:11 PM Jovan Trujillo <jovan.trujil...@gmail.com> > > wrote: > > > >> Hi Greg, > >> Yes, I've been looking into a heat map or flattened 3d scatterplot. In > >> Mathematica, I can easily import the Excel spreadsheet and plot using > >> ListDensityPlot to give me a nice high-resolution image of the data. > >> > >> But my question is simply a mapping problem. If I have two piddles with > >> $x and $y coordinates and a third representing the $data, how do I create a > >> $matrix that maps the $data based on the coordinates from $x and $y? If I > >> had $matrix I can simply plot image($matrix) with PDL::Graphics::Gnuplot. > >> > >> Thank you, > >> Jovan > >> > >> On Thu, Apr 18, 2024 at 1:16 AM Grégory Vanuxem <g.vanu...@gmail.com> > >> wrote: > >> > >>> Hello, > >>> > >>> I haven’t carefully looked at your problem with GNUPlot but I wonder if > >>> what you are trying to achieve could not be done with surface routines, > >>> that’s with 3d ones ? Or maybe something like heatmap like this question: > >>> > >>> > >>> https://stackoverflow.com/questions/76577557/trying-to-create-heat-map-using-ggplot-similar-to-density-contour-plot-but-wh > >>> > >>> Just to give some hints on possible routines. > >>> > >>> - Greg > >>> > >>> Le jeu. 18 avr. 2024 à 01:53, Jovan Trujillo <jovan.trujil...@gmail.com> > >>> a écrit : > >>> > >>>> Hi all, > >>>> > >>>> I've been wracking my brain all morning trying to figure this out, but > >>>> how could I convert a set of 3 1D piddles containing xyz data into a > >>>> matrix > >>>> for plotting as an image using PDL::Graphics::Gnuplot? Say for example: > >>>> > >>>> use PDL; > >>>> use PDL::Graphics::Gnuplot qw/image gplot/; > >>>> > >>>> my $x = flat(xvals(10,10)); # This is basically how x-coordinates are > >>>> output from my machine. > >>>> my $y = flat(yvals(10,10)); # Same format as x-coordinates > >>>> my $z = sequence(100)*rand(1); # Some dummy data for this example. > >>>> > >>>> my $image; # How do I map $x,$y,$z into this 10x10 $image piddle? > >>>> image($image); > >>>> > >>>> That's my basic problem. How do I map $x,$y,$z data into an $image > >>>> matrix? > >>>> > >>>> Thank you, > >>>> Jovan > >>>> _______________________________________________ > >>>> pdl-general mailing list > >>>> pdl-general@lists.sourceforge.net > >>>> https://lists.sourceforge.net/lists/listinfo/pdl-general > >>>> > >>> _______________________________________________ > >> pdl-general mailing list > >> pdl-general@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/pdl-general > >> > > > _______________________________________________ > pdl-general mailing list > pdl-general@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-general -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | moc...@fis.unam.mx /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB
_______________________________________________ pdl-general mailing list pdl-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-general