Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to manipulate legend in Incanter chart
    text
    copied!<p>I'm trying to include a legend in an Incanter chart, but I'm having some troubles getting what I want:</p> <ol> <li><p>I want to be able to instantiate a chart with no data first (using <code>[] []</code> as my x y arguments), then add the data points in a separate step. However the only way to add a legend is to specify <code>:legend true</code> after the initial x y points are given in the constructor. Cannot specify <code>:legend true</code> without x y arguments, and I have not found any <code>add-legend</code> function.</p></li> <li><p>The legend option captures the code I use when adding the chart data, which means if I don't want ugly code to appear in the legend I have to create a nice-looking vars for the X and Y points, rather than just calling a function in line. </p></li> <li><p>Therefore the legend that is created includes the <code>[][]</code> used when creating the blank plot, it includes the function calls used when getting the data for the points, and it includes the name-mangled anonymous function <code>(fn*[p1__3813#](second p1__3813#))</code> which is non-communicative to consumers of my chart.</p></li> <li><p>I just want to be able to associate a string with each group of points in the legend like in matlab, excel, etc.</p></li> </ol> <p>Here is my current code;</p> <pre><code>(def lux-ratios-plot (doto (scatter-plot [] [] :legend true :title "Lux/CH0 vs. CH1/CH0" :x-label "CH1/CH0" :y-label "Lux/CH0") (view))) (doseq [dut [incs hals cfls leds]] (add-points lux-ratios-plot (get-vals :CH1/CH0 dut) (get-vals :Lux/CH0 dut) :points true)) ; Show the trend line for each bulb (doseq [fit [inc-fit hal-fit cfl-fit led-fit]] (add-lines lux-ratios-plot (map #(second %) (:x fit)) (:fitted fit))) </code></pre> <p>Therefore is there any way in Incanter plots to specify a legend string with each <code>(add-lines ...)</code> or <code>(add-points ...)</code> call?</p> <p>Thanks a lot</p> <p>Michael</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload