Fork me on GitHub
#incanter2015-08-06
>
arathunku15:08:13

Hello, could someone help me with changing colors of histogram's DataSeries? I've following code:

(let [plot (histogram (sample-normal 20))
        _ (add-histogram plot (sample-normal 20))
        render (-> plot .getPlot .getRenderer)]
    (.setSeriesOutlinePaint render 1 java.awt.Color/BLUE)
    (.setSeriesFillPaint render 1 java.awt.Color/BLUE)
    (view plot))
and while it changes outline color correctly, the fill paint remains unchanged. šŸ˜•

arathunku17:08:27

Nothing changes. I've read that add-histogram returns new chart so I tried it with the following code

arathunku17:08:36

(let [base-plot (histogram (sample-normal 20))
        plot (add-histogram base-plot (sample-normal 20))
        render (-> plot .getPlot (.getRenderer 0))]
    (.setSeriesOutlinePaint render 1 Color/BLUE)
    (.setSeriesPaint render 1 Color/BLUE)
    (view plot))

surreal.analysis17:08:00

@arathunku: Perhaps try .setBaseFillPaint

surreal.analysis17:08:39

But Iā€™m not confident in that

arathunku17:08:58

It changes color of all histograms on the chart

surreal.analysis17:08:59

Oh, but you want the second series

arathunku17:08:19

I've fighting with this for few hours and can't get this working so I'm writing a wrapper around http://xeiam.com/xchart-example-code/ Simpler API, enough for my needs and clojure wrapper might be useful for community in the future.

nblumoe17:08:57

@arathunku: did you try .setPaint already?

arathunku17:08:05

@nblumoe: same case as in .setBaseFillPaint -> all data series change color šŸ˜•

nblumoe18:08:04

ah, oh yeah. sorry, of course

nblumoe18:08:38

well, tbh I don't ever use the jfreechart stuff. I ran into similar issues in the past šŸ˜ž

nblumoe18:08:16

you think you might want to try is using bar-chart directly though

nblumoe18:08:50

otherwise let me know how it goes with the xchart wrapper and don't forget dropping a link to the repo over here simple_smile

nblumoe18:08:12

if you find time to open an issue on github, that would be great, too. I will look a bit more into this once I find the time myself

arathunku18:08:51

@nblumoe: I'll definitely post a link to a xchart wrapper if everything will work for me without a problem. I'll open an issue on github later (I want to try some other charts before giving up on it), no problem šŸ˜‰

shriphani18:08:22

jfreechart is pathetic..

arathunku18:08:38

I'm open to alternatives, I've not found anything other than incanter for charts:/