Overlaying curves on top of an x-t contour plot

15 views
Skip to first unread message

Carlos

unread,
Dec 16, 2008, 4:07:20 PM12/16/08
to amrita-ebook
How would one go about plotting a curve on top of a contour plot?

Say we have a contour plot on an x-t diagram of say, pressure gradient
generated by a script similar to what is seen in the previous thread:
http://groups.google.com/group/amrita-ebook/browse_thread/thread/77b89c069c42b781

And we also have a file listing the x-t coordinates of a curve (say,
the x-t coordinates of a particle path or a C+ characteristic). What
is the best way to plot the curve on top of the contour plot? This can
be done by dumping the results extracted by AMRITA simulation into a
program like MATLAB or Mathematica and having those programs do the
plotting, but it may be better to do everything on the fly within
AMRITA

Right now I am thinking of plotting the curve using the "line" command
to connect the points (connecting the first point in the x-t file to
the second point, taking the second point and connecting it to the
third and so on) and overlaying what I get onto the contour plot (of
say pressure gradient). Would this be the right approach to take?

On a related note, is there a way to draw the lines differently, for
example making some lines slightly thicker than other lines, or adding
colour to the lines? Say we wanted to plot many C+ and C-
characteristics together. If we plotted a lot of those lines together,
the result could be a jumbled mess, and we want to colour code it so
that the C+ is red and the C- is blue. Is there a way to do something
like this within AMRITA?

Thanks,
Carlos

Carlos

unread,
Dec 16, 2008, 4:39:03 PM12/16/08
to amrita-ebook
Ahh, nevermind about my last question. I can use the rgb<x,y,z> to
colour code lines

James Quirk

unread,
Dec 16, 2008, 4:39:13 PM12/16/08
to Carlos, amrita-ebook
Carlos,
You can overlay a segmented curve using the commands:

move x,y
draw x,y
line x1,y1,x2,y2

The lines will be drawn using the current colour, which is set
using the commands:

m
rgb
hls

There isn't a command to set the line width directly, but you can change
the width by injecting raw PostScript into the plot file. For details,
check out the manual page for amrita:gl::ps .

If the built-in functionality is not sufficient, I would suggest you use
either Metapost or Asymptote to build an overlay. Both of these packages
are free and so are more accessible to people like myself who
cannot afford a Matlab licence.

James

>
> Thanks,
> Carlos
> >

Gary Sharpe

unread,
Dec 17, 2008, 5:31:50 AM12/17/08
to amrita-ebook


> And we also have a file listing the x-t coordinates of a curve (say,
> the x-t coordinates of a particle path or a C+ characteristic). What
> is the best way to plot the curve on top of the contour plot? This can
> be done by dumping the results extracted by AMRITA simulation into a
> program like MATLAB or Mathematica and having those programs do the
> plotting, but it may be better to do everything on the fly within
> AMRITA

Carlos, building on James' note about re-entrant folds and leveraging
off
other codes/languages, it is possible to both use an external plotting
routine and do it on the fly in AMRITA. Taking gnuplot as an example,
it is possible to write the script which creates the ps figure (which
can
be parameterized e.g. as a Proc.) from data files
generated by AMRITA and run it and display it to screen.
Below are some snippets from an example:

fold::print { gnuplot tracks script
fold> file=$gpfile
set terminal postscript eps enhanced color "Times-
Roman" 26
set output "$psfile"
set size 1,1
set title "$title"
plot [] "$tfile1" u 1:3 w l,"$tfile2" u 1:3 w
l,"$tfile3" u 1:3 w l
q
}
fold::amrita { gnuplot the data
fold::amrita { make Track figures

foreach Q (P,N)

if (!-e "$psfile") then
echo $psfile
execute gnuplot < $gpfile
endif
end foreach
}
fold::amrita { view plots?
if ("$Tracks::plotTracks" eq "Y") then

foreach Q (P,N)
set psfile = \$psfile$n$Q
expand psfile
execute ggv $psfile &
end foreach

endif
Reply all
Reply to author
Forward
0 new messages