Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layout bug (?) when plotting histogram with logarithmic y axis #236

Open
rubenmoor opened this issue Nov 16, 2021 · 0 comments
Open

layout bug (?) when plotting histogram with logarithmic y axis #236

rubenmoor opened this issue Nov 16, 2021 · 0 comments

Comments

@rubenmoor
Copy link

image

Those lines going up there are the vertical drop line (I supposed) that all go somewhere top left. This is my code:

plotFrequencies
  :: IO ()
plotFrequencies = do
    ls <- lines <$> readFile "deu_news_2020_freq.txt"
    let ns = tail ls <&> \l -> case splitOn "\t" l of
          [_, n'] -> read $ Text.unpack n'
          _       -> error "missing tab character?"
    renderableToWindow (chart $ dropWhile (> 200) ns) 800 600
  where
    chart
      :: [Double]
      -> Renderable ()
    chart ns =
      toRenderable $ def
        & layout_plots .~ [histogram ns]
        & layout_title .~ "Frequency"
        & layout_x_axis . laxis_generate .~ scaledAxis
            ( def & la_nLabels .~ 200
                  & la_nTicks .~ 200
            ) (1, 200)
        & layout_y_axis . laxis_generate .~ autoScaledLogAxis def

    histogram
      :: [Double]
      -> Plot Double Double
    histogram ns =
      histToPlot $ defaultFloatPlotHist
        & plot_hist_values .~ ns
        & plot_hist_bins .~ 200
        & plot_hist_title .~ "#Total shown: " <> show (length ns)
        & plot_hist_range ?~ (0, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant