如何在Incanter图表中操纵图例 [英] How to manipulate legend in Incanter chart

查看:131
本文介绍了如何在Incanter图表中操纵图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Incanter图表中包含一个图例,但我遇到了一些麻烦,得到了我想要的:

I'm trying to include a legend in an Incanter chart, but I'm having some troubles getting what I want:


  1. 我想要能够实例化一个没有数据的图表(使用 [] [] 作为我的xy参数),然后在单独的步骤中添加数据点。然而,添加图例的唯一方法是在构造函数中给出初始x y点之后指定:legend true 。不能指定:legend true 没有xy参数,我没有找到任何 add-legend 函数。

  1. I want to be able to instantiate a chart with no data first (using [] [] 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 :legend true after the initial x y points are given in the constructor. Cannot specify :legend true without x y arguments, and I have not found any add-legend function.

图例选项捕获添加图表数据时使用的代码,这意味着如果我不想在图例中显示丑陋的代码,我必须创建一个nice-查找X和Y点的变量,而不是仅仅调用一行中的函数。

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.

因此,创建的图例包括创建空白图时使用的 [] [] 它包括获取点的数据时使用的函数调用,并且它包括名称被覆盖的匿名函数(fn * [p1__3813#](第二个p1__3813#))

Therefore the legend that is created includes the [][] 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 (fn*[p1__3813#](second p1__3813#)) which is non-communicative to consumers of my chart.

我只想将一个字符串与图例中的每一组点相关联,就像在matlab中一样, excel等。

I just want to be able to associate a string with each group of points in the legend like in matlab, excel, etc.

这是我当前的代码;

(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)))

因此在Incanter地图中有任何方法以指定每个(add-lines ...)(add-points ...)

Therefore is there any way in Incanter plots to specify a legend string with each (add-lines ...) or (add-points ...) call?

非常感谢

Michael

推荐答案

每个Incanter图表也是一个JFreeChart对象。因此,您可以使用任何JFreeChart方法来操作您的Incanter图表。

Every Incanter chart is also a JFreeChart object. So you could use any of the JFreeChart methods to manipulate your Incanter chart.

例如,删除图例(.removeLegend lux-ratios-plot)。还有一个 addLegend 方法。没有试过那个自己。希望这有助于。

For example to remove the legend you can do (.removeLegend lux-ratios-plot). There is also an addLegend method. Haven't tried that one myself. Hope this helps.

这篇关于如何在Incanter图表中操纵图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆