timbod7 / haskell-chart

A 2D charting library for haskell
430 stars 85 forks source link

`scaledAxis` does not honor bounds #215

Open dschrempf opened 4 years ago

dschrempf commented 4 years ago

Hi,

when creating a plot with layout_y_axis . laxis_generate .= scaledAxis def (3, 28), the resulting plot has a y range from 0 to 30. I guess this is because the ticks are at 0 and 30. How can I create a plot with a specific axis range?

Thanks!

joehealy commented 4 years ago

Ive done it manually with code like:

degreeAxis = const AxisData
  { _axis_visibility = def
  , _axis_viewport   = linMap id (0, 360)
  , _axis_tropweiv   = invLinMap id id (0, 360)
  , _axis_ticks      = [ (i, 5) | i <- cardinals ]
                         <> [ (i + 45, 3) | i <- cardinals, i < 360 ]
  , _axis_grid       = [0, 90, 180, 270, 360]
  , _axis_labels     = [ [ (0.0, "North")
                         , (90 , "East")
                         , (180, "South")
                         , (270, "West")
                         , (360, "North")
                         ]
                       ]
  }

cardinals = [0, 90, 180, 270, 360]