Hi Marshall,

On 17 October 2016 at 07:54, Mars0i <marsh...@logical.net> wrote:

> Looks very nice! Thanks Jean Niklas.  I've been using Incanter for charts,
> which has been fine so far for my needs, but clj-xchart looks like it will
> make it easier to make nicer charts, and it would avoid loading much of
> Incanter when you don't need some of the other things Incanter provides.
> (I also use nvd3 to generate charts in a browser with Clojurescript.)

Thanks! This was also parts of the rationale for clj-xchart as well:
Incanter is great, but it feels a bit strange to drag in both json and csv
dependencies if you only need to plot some charts.

> Since you've developed a charting library, maybe I'll mention a feature
> that I have wanted (I think!):
> I've been making plots with a large number of points--100K, sometimes even
> 1M or 2M per data sequence.  Sometimes I will sample a larger sequence
> every 10 or 100 steps to reduce the burden on the Incanter or nvd3 plotting
> function, but sometimes I want to see what the data looks like with all of
> the points.
> I generate the data in a lazy sequence, using iterate, where, let's say,
> each element of the sequence is a map containing several pieces  of y
> values for the x value corresponding to that element of the sequence, e.g.
> data = ({:a y-a-1, :b y-b-1, :c y-c-1}, {:a y-a-2, :b y-b-2, :c y-c-2},
> ...)
> In order to plot all three sequences of y values in Incanter or nvd3 (and
> clj-xchart?), I have to extract a new sequence of values for each data
> series, e.g. like this:
> (map :a data)
> (map :b data)
> (map :c data)
> and I have to generate several sequences of x values by calling (range)
> repeatedly.  I pass these six lazy sequences to the chart function, but at
> least in Incanter and nvd3, I don't believe Incanter does anything until it
> realizes all of the sequences.  That means that it realizes six distinct
> sequences, I think, and my initial sequence of maps will have been realized
> as well.
> But if I'm plotting several sequences of y values that are embedded in a
> sequence of maps or vectors, each with several y values for the same x, I
> wonder if it could be more to efficient pass the entire complex sequence to
> the plotting function at once, and only provide one set of x values if all
> of the y values will share the same x's.  If the plotting function extracts
> the y values as it reads through the sequence of maps/vectors, and needs
> only one sequence of x's, then only two sequences are realized.
> Maybe this is an unusual need, at present, but as Clojure is used for more
> scientific applications, it might become more common.

XChart (and consequently clj-xchart) can take the same x-axis as input. So
you can reuse the same x values instead of creating 3 distinct but
identical ones:

(let [x [1 2 3]
      y1 [1 2 3]
      y2 [2 4 6]
      y3 [3 6 9]]
  (c/xy-chart {"y1" {:x x :y y1}
               "y2" {:x x :y y2}
               "y3" {:x x :y y3}}))

I don't think this is unique to clj-xchart though, the same should apply to

Unfortunately, clj-xchart will indirectly realise almost all lists it is
given, as it calls .size() on them to ensure that the X/Y/error lists are
identical in size. It will also walk the lists to find the size/scale of
the chart to plot. I'm not sure if there's a way around that, except
perhaps if one pin the boundaries of the plot axes.

That being said, it doesn't seem like a bad idea to provide some sort of
efficient view over data to avoid creating a new list that will be realised
with the exact same data in another list. I made an issue
<https://github.com/hyPiRion/clj-xchart/issues/5> on this, it shouldn't be
too hard to implement either.

For what it's worth, I've had the same "issue" with large datasets as well
(10-20M elements). In my case there isn't that much interesting to look at
except the occational outlier, or if you have values which differ extremely
from one datapoint to another.

What I tend to do is rebin/shrink the data set, typically by computing the
average/max value of partitions (after filtering away outliers), depending
on what I need to plot. I have a small section in the "Gotchas" section
named Many Datapoints
of the page) which has a couple of lines on how one can do that. I haven't
found a good generic interface for it yet, so it's not provided by
clj-xchart as of now.

Jean Niklas L'orange

You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
For more options, visit this group at
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to