I'm trying to plot a very simple bar plot using plot. However, I've gotten stuck with adding strings to the base of the bars along the X-axis.
My attempt:
import Graphics.Rendering.Plot.Figure
import Graphics.Rendering.Plot.Render
import Numeric.LinearAlgebra (vector, Vector)
test_bar :: Figure ()
test_bar = do
let ts = vector [1..5] :: Vector Double
ds = vector [1..5] :: Vector Double
barWidth = 10 :: Double
barBorder = 2 :: Double
setPlots 1 1
withPlot (1,1) $ do
setDataset (ts,[bar ds (barWidth, grey::Color,barBorder)])
addAxis XAxis (Side Lower) $ withAxisLabel $ setText "X-axis"
addAxis YAxis (Side Lower) $ withAxisLabel $ setText "Y-axis"
setRange XAxis Lower Linear 0 5
setRange YAxis Lower Linear 0 5
main :: IO ()
main = do writeFigure PNG "bars.png" (w,h) test_bar
where
w = 800
h = 600
To my understanding, here, ts represent the indices of the X-axis that we place values at, and ds represent the values, or the height of each bar.
How do I add string labels to the X-axis? Such that the display will be "A", "B", "C", etc, instead of "1.00","2.00","3.00" etc.

ts = vector [1..5], means a vector with1,2,3,4and5.