Skip to content

y-axis extends beyond zero with no points below zero. #34

Description

@GregorySchwartz

In the line plot example: if I just add one point at the y-axis of 0 (mydata3 point 2), no data point goes below 0 yet the y-axis extends beyond 0 and looks unpleasant. I would expect this plot's axis to begin at 0 for both the x- and y-axis. However, I do not recommend cutting it at the lowest or highest datapoint automatically at all, I think it should be a special case for 0 in the x- and y-axis.

{-# LANGUAGE FlexibleContexts #-}

import Plots
import Diagrams.Prelude
import Plots.Axis.Line

import Data.Typeable

mydata1 = [(1,3), (2,5.5), (3.2, 6), (3.5, 6.1)]
mydata2 = mydata1 & each . _1 *~ 0.5
mydata3 = [V2 1.2 2.7, V2 1.7 0, V2 2 5.1, V2 3.2 2.6, V2 3.5 5]

myaxis :: Axis B V2 Double
myaxis = r2Axis &~ do
  linePlot' mydata1
  linePlot mydata2 $ do
    key "data 2"
    plotColor .= black

  linePlot mydata3 $ key "data 3"

  hideGridLines
  xAxis . axisLineType .= MiddleAxisLine
  yAxis . axisLineType .= LeftAxisLine

  lineStyle . _lineCap .= LineCapSquare
  lineStyle . _lineJoin .= LineJoinBevel

dia = renderAxis myaxis

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions