Ok, I'm getting stumped by the Haskell Chart library. I've figured out this way to make a log-log line chart of a Vector
of values in Kronos Haskell:
import Data.Vector (Vector, (!))
import qualified Data.Vector as V
import Graphics.Rendering.Chart.Easy hiding (Vector)
logLogChart name points = toRenderable $ execEC $ plot chart
where chart = line name [V.toList $ V.imap makePoint points]
makePoint x y = (LogValue (fromIntegral (x+1)), LogValue y)
This certainly does render a reasonable log-log line chart, with automatically chosen ranges for the x and y axes based on the data. One example (as rendered in Kronos Haskell):
The problem is that I have a specialized application where I need these two things:
- The range of the two axes needs to be the same. (Since my x-axis is 1-based indices into a
Vector
, this could be simplified to have the range of the y-axis determined by that of the x-axis.) - The dimensions of the rendered chart should be square, not rectangular as in the example above.
I tried looking through the documentation for the library, but it's just got me completely stumped. Any pointers?
This will do but could be vastly improved (not least by removing the unsafePerformIO).