[racket-dev] New plot library [Was: (to Jay) Re: What I'm working on]

From: Aaron Turon (aaron.turon at gmail.com)
Date: Sat Aug 27 13:26:16 EDT 2011

Hi Neil,

I've been using the new plot library for visualizing some benchmark
results in three dimensions (# threads, amount of work, throughput).
It's very easy to use, and the interactive 3d plots are great.  I also
plan to use the PDF export for my next paper.  Thanks for making this

My only request: a version of surface3d that takes as input a list of
discrete points.  I find the surface visualization more useful than a
scatter plot, but I've had to code my own interpolation to make it
work.  I'm guessing surface3d is already doing its own interpolation
(and of course sampling) so coding my own seems redundant.

Thanks again,

Aaron Turon

On Fri, Aug 5, 2011 at 6:40 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
> Redirecting this from Kevin back to the group, because I think at least
> plot2d is good enough for anyone to play with now.
> I've put all of it here:
>    https://github.com/ntoronto/plt-stuff/tree/master/plot
> The main module files are meant to be plot2d.rkt and plot3d.rkt. Both
> contain tests right now. In particular, Kevin, the tests in plot2d.rkt show
> how to generate simple 2D plots and save them to files.
> (In fact, I've just added plot2d->file, which writes a plot to a file or
> output stream using any bitmap or vector format that Racket supports. I
> haven't tested it much, but it appears to work.)
> This code is very young and fairly untested; standard warnings apply. (May
> pillage your families and murder your crops, etc.) The interface WILL
> change, so don't count on it.
> Neil T
> On 08/03/2011 09:41 AM, Kevin Tew wrote:
>> Have a github link yet?
>> I have a simple line graph I need to generate and would like to give
>> your 2d plot a try.
>> Kevin
>> On 08/02/2011 11:33 AM, Neil Toronto wrote:
>>> Re-routing this email exchange to [racket-dev] for comments.
>>> Long story short: Jay roped me into replacing the current `plot'
>>> module by wrapping a plot library I was working on for my own use.
>>> (FWIW, I'm happy to finally contribute something!) Intended features:
>>> 1. Doesn't depend on an FFI to libplplot
>>> 2. Can automatically place plot area on functions and points
>>> 3. Uses parameters for keyword argument default values
>>> 4. Uses only dc<%> primitives / Is very pretty
>>> 5. Is more flexible (when using the new plot2d and plot3d modules)
>>> Linux screenshots:
>>> http://students.cs.byu.edu/~ntoronto/plot2d.png
>>> http://students.cs.byu.edu/~ntoronto/plot3d.png
>>> The first shows off the almost-finished plot2d. It's as fast as the
>>> original `plot', and `shade' is twice as fast. Props to Matthew and
>>> Linux's foreign drawing libs for making it look so nice.
>>> The second shows off 3d-plot-area%, which wraps a dc<%> with 3d
>>> drawing primitives. The new plot3d will be 1.5x-2x slower, but the new
>>> features (e.g. compositing 3d plots, contours) should be worth it.
>>> I'll push code to github soon, and ask for volunteers to verify that
>>> it looks good on Mac and Windows.
>>> Specific questions
>>> ------------------
>>> Matthew: It should look good on Mac and Windows if their drawing libs
>>> do subpixel-accurate, high-quality antialiasing. Do they?
>>> Doug and other heavy `plot' users: What can I add to plot2d and plot3d
>>> to make your life easier?
>>> Noel: Do you happen to have a kernel density estimator implementation
>>> that uses FFT or is otherwise more efficient than O(n^2)? Currently,
>>> (plot2d (density samples)) works, but is slow on large samples.
>>> Anyone: Are there any original `plot' features that should *not* be
>>> emulated in the new `plot' wrapper module?
>>> Anyone: Is it easy/possible to manipulate snip%s with, say, a
>>> click-and-drag? How about placing edit boxes on them? If it's not
>>> hard, I would like to make the 3d plots manipulatable after rendering.
>>> Neil T
>>> On 07/30/2011 02:01 PM, Jay McCarthy wrote:
>>>> Yup, so that old programs will keep working.
>>>> Will you support the line fitting?
>>>> Jay
>>>> On Sat, Jul 30, 2011 at 1:56 PM, Neil Toronto<neil.toronto at gmail.com>
>>>> wrote:
>>>>> Sure can! Does "compatible source library" mean a bunch of wrappers
>>>>> for the
>>>>> functions "plot" currently exports?
>>>>> Neil
>>>>> On 07/30/2011 05:49 AM, Jay McCarthy wrote:
>>>>>> Awesome. We've been wanting to throw it out for a long time. Can you
>>>>>> make a compatible source library too... so we can replace it in the
>>>>>> core?
>>>>>> Jay
>>>>>> On Fri, Jul 29, 2011 at 10:35 PM, Neil Toronto<neil.toronto at gmail.com>
>>>>>> wrote:
>>>>>>> I've attached a screenshot of what I'm working on.
>>>>>>> It's a replacement for Racket's plot module. The plot module has
>>>>>>> these
>>>>>>> drawbacks:
>>>>>>> 1. It's not smart enough to automatically size plots to the things -
>>>>>>> "renderers" - you're plotting. A renderer is only a function that
>>>>>>> accepts
>>>>>>> an
>>>>>>> image snip, so the plotter can't compute a rectangle that contains
>>>>>>> it.
>>>>>>> 2. It depends on an external library, plplot.
>>>>>>> 3. It draws ugly curves because plplot can't draw lines with
>>>>>>> subpixel-accurate endpoints. Also, plplot messes up antialiasing
>>>>>>> when the
>>>>>>> curves are made of too many lines. Whatever Racket uses doesn't
>>>>>>> have this
>>>>>>> problem, at least on Linux.
>>>>>>> 4. It doesn't use parameters for things for which parameters make
>>>>>>> sense,
>>>>>>> like the size of the plots.
>>>>>>> I could probably alter the plot module for any one or two of these
>>>>>>> and
>>>>>>> submit patches. For all four, writing a replacement makes more sense.
>>>>>>> FWIW, this is related to my research. I've been using R to generate
>>>>>>> plots,
>>>>>>> but it's getting annoying to serialize samples in Racket and then
>>>>>>> unserialize them in R.
>>>>>>> Also, Bayesians make a LOT of plots. It's *really* nice to display
>>>>>>> them
>>>>>>> using image snips. That's very, very cool.
>>>>>>> This project feels vacation-y and relaxing. I figure it's because it
>>>>>>> doesn't
>>>>>>> require any more math than linear algebra. :D
>>>>>>> Neil
>>> _________________________________________________
>>> For list-related administrative tasks:
>>> http://lists.racket-lang.org/listinfo/dev
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev

Posted on the dev mailing list.